upload tizen1.0 source
authorKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:04:36 +0000 (17:04 +0900)
committerKim Kibum <kb0929.kim@samsung.com>
Sun, 29 Apr 2012 08:04:36 +0000 (17:04 +0900)
674 files changed:
.gitignore [deleted file]
CMakeLists.txt
debian/changelog
debian/control
packaging/wrt-plugins-tizen.spec
src/platform/API/Account/AccountFactory.cpp [deleted file]
src/platform/API/Account/AccountServiceFilterProperty.cpp [deleted file]
src/platform/API/Account/AccountServiceFilterProperty.h [deleted file]
src/platform/API/Account/AccountServiceProviderProperty.cpp [deleted file]
src/platform/API/Account/AccountServiceProviderProperty.h [deleted file]
src/platform/API/Account/AccountServiceTypeProperty.cpp [deleted file]
src/platform/API/Account/AccountServiceTypeProperty.h [deleted file]
src/platform/API/Account/AccountServices.cpp [deleted file]
src/platform/API/Account/AccountServices.h [deleted file]
src/platform/API/Account/EventAccount.cpp [deleted file]
src/platform/API/Account/EventAccount.h [deleted file]
src/platform/API/Account/IAccountManager.cpp [deleted file]
src/platform/API/Account/IAccountManager.h [deleted file]
src/platform/API/Account/IAccountService.cpp [deleted file]
src/platform/API/Account/IAccountService.h [deleted file]
src/platform/API/Account/IEventAddAccount.h [deleted file]
src/platform/API/Account/IEventCreateAccount.h [deleted file]
src/platform/API/Account/IEventDeleteAccount.h [deleted file]
src/platform/API/Account/IEventFindAccounts.h [deleted file]
src/platform/API/Account/IEventFindProviders.h [deleted file]
src/platform/API/Account/IEventFindServiceTypes.h [deleted file]
src/platform/API/Account/IEventFindServices.h [deleted file]
src/platform/API/Account/IEventGetAccountById.h [deleted file]
src/platform/API/Account/IEventGetAccountServices.h [deleted file]
src/platform/API/Account/IEventGetProviderById.h [deleted file]
src/platform/API/Account/IEventGetServiceById.h [deleted file]
src/platform/API/Account/IEventGetServiceByName.h [deleted file]
src/platform/API/Account/IEventGetServiceTypeById.h [deleted file]
src/platform/API/Account/IEventUpdateAccount.h [deleted file]
src/platform/API/Account/OnAddEventsChanged.h [deleted file]
src/platform/API/Account/OnDeleteEventsChanged.h [deleted file]
src/platform/API/Account/OnUpdateEventsChanged.h [deleted file]
src/platform/API/Account/config.cmake [deleted file]
src/platform/API/Account/log.h [deleted file]
src/platform/API/Application/ApplicationService.cpp
src/platform/API/Application/ApplicationService.h
src/platform/API/Application/EventLaunchService.h
src/platform/API/Application/IApplication.h
src/platform/API/Bluetooth/EventBTCreateDestroyBonding.cpp [new file with mode: 0644]
src/platform/API/Bluetooth/EventBTCreateDestroyBonding.h
src/platform/API/Bluetooth/EventBTSocketNotification.cpp
src/platform/API/Bluetooth/IBluetoothAdapterManager.cpp
src/platform/API/Bluetooth/IBluetoothAdapterManager.h
src/platform/API/Bluetooth/IBluetoothDeviceManager.cpp
src/platform/API/Bluetooth/IBluetoothServiceHandlerManager.cpp
src/platform/API/Bluetooth/config.cmake
src/platform/API/Calendar/CalendarEvent.cpp
src/platform/API/Calendar/CalendarEvent.h
src/platform/API/Calendar/CalendarItemGeo.h [deleted file]
src/platform/API/Calendar/EventAlarm.cpp
src/platform/API/Calendar/EventAttendee.h
src/platform/API/Calendar/EventFilter.cpp [deleted file]
src/platform/API/Calendar/EventFilter.h [deleted file]
src/platform/API/Calendar/EventId.cpp
src/platform/API/Calendar/EventId.h
src/platform/API/Calendar/EventRecurrenceRule.cpp
src/platform/API/Calendar/EventRecurrenceRule.h
src/platform/API/Calendar/ICalendar.cpp
src/platform/API/Calendar/ICalendar.h
src/platform/API/Calendar/IEventCreateEvent.h [deleted file]
src/platform/API/Calendar/IEventFindEvents.h
src/platform/API/Calendar/OnAddEventsChanged.h [deleted file]
src/platform/API/Calendar/OnDeleteEventsChanged.h [deleted file]
src/platform/API/Calendar/OnUpdateEventsChanged.h [deleted file]
src/platform/API/Calendar/config.cmake
src/platform/API/Call/CallDefine.h
src/platform/API/Call/CallFactory.cpp
src/platform/API/Call/CallFactory.h
src/platform/API/Call/CallServiceFilter.cpp [deleted file]
src/platform/API/Call/CallServiceFilter.h [deleted file]
src/platform/API/Call/EventGetCallService.h [deleted file]
src/platform/API/Call/ICallManager.cpp
src/platform/API/Call/ICallManager.h
src/platform/API/Call/ICallService.h [deleted file]
src/platform/API/Call/RemoteParty.cpp
src/platform/API/Call/RemoteParty.h
src/platform/API/Call/config.cmake
src/platform/API/Contact/ContactFactory.cpp
src/platform/API/Contact/ContactFactory.h
src/platform/API/Contact/EventAddressBookAdd.h [new file with mode: 0755]
src/platform/API/Contact/EventAddressBookAddChangeListener.h [new file with mode: 0755]
src/platform/API/Contact/EventAddressBookGet.h [new file with mode: 0755]
src/platform/API/Contact/EventAddressBookRemove.h [new file with mode: 0755]
src/platform/API/Contact/EventAddressBookRemoveChangeListener.h [new file with mode: 0755]
src/platform/API/Contact/EventAddressBookUpdate.h [new file with mode: 0755]
src/platform/API/Contact/IAddressBook.cpp
src/platform/API/Contact/IAddressBook.h
src/platform/API/Contact/IContact.cpp
src/platform/API/Contact/IContact.h
src/platform/API/Filesystem/EventListNodes.cpp
src/platform/API/Filter/AnyType.cpp
src/platform/API/Filter/AnyType.h
src/platform/API/Filter/FilterValidator.cpp
src/platform/API/Geocoder/EventGeocoder.h [deleted file]
src/platform/API/Geocoder/GeocoderProperties.h [deleted file]
src/platform/API/Geocoder/IGeocoder.h [deleted file]
src/platform/API/Geocoder/config.cmake [deleted file]
src/platform/API/Mediacontent/IEventBrowseFolder.h
src/platform/API/Messaging/AttachmentFactory.cpp
src/platform/API/Messaging/AttachmentFactory.h
src/platform/API/Messaging/Attachments.cpp
src/platform/API/Messaging/EventAddDraftMessage.h
src/platform/API/Messaging/EventDeleteConversations.h
src/platform/API/Messaging/EventDeleteMessages.h
src/platform/API/Messaging/EventGetMessagingService.h
src/platform/API/Messaging/EventMessagingService.h
src/platform/API/Messaging/EventQueryConversations.h
src/platform/API/Messaging/EventQueryFolders.h
src/platform/API/Messaging/EventQueryMessages.h
src/platform/API/Messaging/EventUpdateMessages.h
src/platform/API/Messaging/IAttachment.cpp
src/platform/API/Messaging/IAttachment.h
src/platform/API/Messaging/IEmail.h
src/platform/API/Messaging/IMessage.h
src/platform/API/Messaging/IMessaging.h
src/platform/API/Messaging/IMessagingService.cpp
src/platform/API/Messaging/IMessagingService.h
src/platform/API/Messaging/MessageFactory.cpp
src/platform/API/Messaging/MessageFilterValidator.cpp
src/platform/API/Messaging/MessageFilterValidator.h
src/platform/API/Messaging/MessageFilterValidatorFactory.cpp
src/platform/API/Messaging/MessageFilterValidatorFactory.h
src/platform/API/Messaging/ReqReceiverMessage.cpp
src/platform/API/Messaging/ReqReceiverMessage.h
src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.h
src/platform/API/Messaging/StorageChangesConversationGenerator.cpp
src/platform/API/Messaging/StorageChangesConversationGenerator.h
src/platform/API/Messaging/StorageChangesFolderFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesFolderGenerator.cpp
src/platform/API/Messaging/StorageChangesFolderGenerator.h
src/platform/API/Messaging/StorageChangesMessageFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesMessageFilterValidatorFactory.h
src/platform/API/Messaging/StorageChangesMessageGenerator.cpp
src/platform/API/Messaging/StorageChangesMessageGenerator.h
src/platform/API/Messaging/VirtualMessage.cpp
src/platform/API/Messaging/VirtualMessage.h
src/platform/API/NFC/EventNFC.h
src/platform/API/NFC/EventNFCChanged.h
src/platform/API/NFC/EventTagMifareClassicAction.h [deleted file]
src/platform/API/NFC/EventTagMifareUltraAction.h [deleted file]
src/platform/API/NFC/INFCAdapter.cpp [moved from src/platform/API/NFC/INFCManager.cpp with 80% similarity]
src/platform/API/NFC/INFCAdapter.h [moved from src/platform/API/NFC/INFCManager.h with 62% similarity]
src/platform/API/NFC/INFCTag.h
src/platform/API/NFC/INFCTagMifareClassic.cpp [deleted file]
src/platform/API/NFC/INFCTagMifareClassic.h [deleted file]
src/platform/API/NFC/INFCTagMifareUltra.cpp [deleted file]
src/platform/API/NFC/INFCTagMifareUltra.h [deleted file]
src/platform/API/NFC/INFCTarget.h
src/platform/API/NFC/INdefMessage.h
src/platform/API/NFC/INdefRecord.h
src/platform/API/NFC/NFCFactory.cpp
src/platform/API/NFC/NFCFactory.h
src/platform/API/NFC/config.cmake
src/platform/API/Systeminfo/EventWatchSysteminfo.cpp
src/platform/API/Systeminfo/EventWatchSysteminfo.h
src/platform/API/Systeminfo/ISysteminfo.h
src/platform/API/Systeminfo/SysteminfoPropertyInfo.h [changed mode: 0755->0644]
src/platform/API/config.cmake
src/platform/Tizen/Account/AccountManager.cpp [deleted file]
src/platform/Tizen/Account/AccountManager.h [deleted file]
src/platform/Tizen/Account/AccountWrapper.cpp [deleted file]
src/platform/Tizen/Account/AccountWrapper.h [deleted file]
src/platform/Tizen/Account/config.cmake [deleted file]
src/platform/Tizen/Account/old/AccountService.cpp [deleted file]
src/platform/Tizen/Account/old/AccountService.h [deleted file]
src/platform/Tizen/Application/Application.cpp
src/platform/Tizen/Application/Application.h
src/platform/Tizen/Bluetooth/BluetoothAdapterManager.cpp
src/platform/Tizen/Bluetooth/BluetoothAdapterManager.h
src/platform/Tizen/Bluetooth/BluetoothDeviceManager.cpp
src/platform/Tizen/Bluetooth/BluetoothServiceHandlerManager.cpp
src/platform/Tizen/Bluetooth/BluetoothSocketManager.cpp
src/platform/Tizen/Calendar/Calendar.cpp
src/platform/Tizen/Calendar/Calendar.h
src/platform/Tizen/Calendar/CalendarFilter.cpp
src/platform/Tizen/Calendar/CalendarFilter.h
src/platform/Tizen/Calendar/CalendarFilterValidator.cpp
src/platform/Tizen/Calendar/CalendarManager.cpp
src/platform/Tizen/Calendar/CalendarQuery.c
src/platform/Tizen/Calendar/CalendarQuery.h
src/platform/Tizen/Calendar/EventWrapper.cpp
src/platform/Tizen/Calendar/EventWrapper.h
src/platform/Tizen/Call/CallHistory.cpp
src/platform/Tizen/Call/CallHistory.h
src/platform/Tizen/Call/CallHistoryFilter.cpp
src/platform/Tizen/Call/CallManager.cpp
src/platform/Tizen/Call/CallManager.h
src/platform/Tizen/Call/CallService.cpp [deleted file]
src/platform/Tizen/Call/CallService.h [deleted file]
src/platform/Tizen/Call/config.cmake
src/platform/Tizen/Contact/AddressBook.cpp
src/platform/Tizen/Contact/AddressBook.h
src/platform/Tizen/Contact/Contact.cpp
src/platform/Tizen/Contact/Contact.h
src/platform/Tizen/Contact/ContactSearchEngine.cpp
src/platform/Tizen/Contact/ContactSearchEngine.h
src/platform/Tizen/Contact/ContactWrapper.cpp
src/platform/Tizen/Contact/ContactWrapper.h
src/platform/Tizen/Contact/query-svc/query-svc.c
src/platform/Tizen/Contact/query-svc/query-type.h
src/platform/Tizen/Contact/query-svc/query-utility.c
src/platform/Tizen/Contact/query-svc/query-utility.h
src/platform/Tizen/Filesystem/Command.cpp [deleted file]
src/platform/Tizen/Filesystem/Command.h [deleted file]
src/platform/Tizen/Filesystem/CopyCommand.cpp [deleted file]
src/platform/Tizen/Filesystem/CopyCommand.h [deleted file]
src/platform/Tizen/Filesystem/Manager.cpp
src/platform/Tizen/Filesystem/Manager.h
src/platform/Tizen/Filesystem/MoveCommand.cpp [deleted file]
src/platform/Tizen/Filesystem/MoveCommand.h [deleted file]
src/platform/Tizen/Filesystem/Node.cpp
src/platform/Tizen/Filesystem/RemoveCommand.cpp [deleted file]
src/platform/Tizen/Filesystem/Stream.cpp
src/platform/Tizen/Filesystem/config.cmake
src/platform/Tizen/Geocoder/Geocoder.cpp [deleted file]
src/platform/Tizen/Geocoder/Geocoder.h [deleted file]
src/platform/Tizen/Geocoder/config.cmake [deleted file]
src/platform/Tizen/Mediacontent/MediaFilterValidator.cpp
src/platform/Tizen/Mediacontent/MediaSearchVisitor.cpp
src/platform/Tizen/Mediacontent/MediaSearchVisitor.h
src/platform/Tizen/Mediacontent/Mediacontent.cpp
src/platform/Tizen/Mediacontent/Mediacontent.h
src/platform/Tizen/Messaging/Attachment.cpp
src/platform/Tizen/Messaging/Attachment.h
src/platform/Tizen/Messaging/BinarySms.cpp
src/platform/Tizen/Messaging/BinarySms.h
src/platform/Tizen/Messaging/Conversation.cpp
src/platform/Tizen/Messaging/ConversationQueryGenerator.cpp
src/platform/Tizen/Messaging/ConversationQueryGenerator.h
src/platform/Tizen/Messaging/Email.cpp
src/platform/Tizen/Messaging/Email.h
src/platform/Tizen/Messaging/EmailConverter.cpp
src/platform/Tizen/Messaging/EmailConverter.h
src/platform/Tizen/Messaging/EmailService.cpp
src/platform/Tizen/Messaging/EmailService.h
src/platform/Tizen/Messaging/FolderQueryGenerator.cpp [changed mode: 0644->0755]
src/platform/Tizen/Messaging/MailSender.cpp
src/platform/Tizen/Messaging/MailSync.cpp
src/platform/Tizen/Messaging/MessageFolder.cpp
src/platform/Tizen/Messaging/MessageFolder.h
src/platform/Tizen/Messaging/MessageQueryGenerator.cpp
src/platform/Tizen/Messaging/MessageQueryGenerator.h
src/platform/Tizen/Messaging/Messaging.cpp
src/platform/Tizen/Messaging/Messaging.h
src/platform/Tizen/Messaging/MessagingService.cpp
src/platform/Tizen/Messaging/MessagingService.h
src/platform/Tizen/Messaging/MessagingServiceManager.cpp
src/platform/Tizen/Messaging/Mms.cpp
src/platform/Tizen/Messaging/Mms.h
src/platform/Tizen/Messaging/ScopedMail.h
src/platform/Tizen/Messaging/ScopedMailAttachment.h [new file with mode: 0755]
src/platform/Tizen/Messaging/ScopedMailbox.h
src/platform/Tizen/Messaging/Sms.cpp
src/platform/Tizen/Messaging/Sms.h
src/platform/Tizen/Messaging/messageDB/MessageStorageReader.cpp
src/platform/Tizen/Messaging/messageDB/MessageStorageReader.h
src/platform/Tizen/NFC/NFCAdapter.cpp [new file with mode: 0755]
src/platform/Tizen/NFC/NFCAdapter.h [moved from src/platform/Tizen/NFC/NFCManager.h with 67% similarity]
src/platform/Tizen/NFC/NFCManager.cpp [deleted file]
src/platform/Tizen/NFC/NFCTag.cpp
src/platform/Tizen/NFC/NFCTag.h
src/platform/Tizen/NFC/NFCTagMifareClassic.cpp [deleted file]
src/platform/Tizen/NFC/NFCTagMifareClassic.h [deleted file]
src/platform/Tizen/NFC/NFCTagMifareUltra.cpp [deleted file]
src/platform/Tizen/NFC/NFCTagMifareUltra.h [deleted file]
src/platform/Tizen/NFC/NFCTarget.cpp
src/platform/Tizen/NFC/NFCTarget.h
src/platform/Tizen/NFC/NFCUtil.cpp
src/platform/Tizen/NFC/NFCUtil.h
src/platform/Tizen/NFC/NdefMessage.cpp
src/platform/Tizen/NFC/NdefMessage.h
src/platform/Tizen/NFC/NdefRecord.cpp
src/platform/Tizen/NFC/NdefRecord.h
src/platform/Tizen/NFC/config.cmake
src/platform/Tizen/Systeminfo/Systeminfo.cpp
src/platform/Tizen/Systeminfo/Systeminfo.h
src/platform/Tizen/Systeminfo/config.cmake [changed mode: 0755->0644]
src/platform/Tizen/TimeUtil/TZDate.cpp
src/platform/Tizen/TimeUtil/TimeUtil.cpp
src/platform/Tizen/TimeUtil/TimeUtilTools.cpp
src/platform/Tizen/TimeUtil/TimeUtilTools.h
src/platform/Tizen/config.cmake
src/standards/Tizen/Account/AccountConverter.cpp [deleted file]
src/standards/Tizen/Account/AccountConverter.h [deleted file]
src/standards/Tizen/Account/AccountManagerController.cpp [deleted file]
src/standards/Tizen/Account/CMakeLists.txt [deleted file]
src/standards/Tizen/Account/JSAccount.cpp [deleted file]
src/standards/Tizen/Account/JSAccount.h [deleted file]
src/standards/Tizen/Account/JSAccountManager.cpp [deleted file]
src/standards/Tizen/Account/JSAccountManager.h [deleted file]
src/standards/Tizen/Account/JSAccountServiceProvider.cpp [deleted file]
src/standards/Tizen/Account/JSAccountServiceProvider.h [deleted file]
src/standards/Tizen/Account/JSAccountServiceType.cpp [deleted file]
src/standards/Tizen/Account/JSAccountServiceType.h [deleted file]
src/standards/Tizen/Account/JSAccountServices.cpp [deleted file]
src/standards/Tizen/Account/JSAccountServices.h [deleted file]
src/standards/Tizen/Account/JSFeatureArray.cpp [deleted file]
src/standards/Tizen/Account/JSFeatureArray.h [deleted file]
src/standards/Tizen/Account/ResponseDispatcher.cpp [deleted file]
src/standards/Tizen/Account/ResponseDispatcher.h [deleted file]
src/standards/Tizen/Account/config.xml [deleted file]
src/standards/Tizen/Account/old/JSAccountService.cpp [deleted file]
src/standards/Tizen/Account/old/JSAccountService.h [deleted file]
src/standards/Tizen/Account/plugin_config.cpp [deleted file]
src/standards/Tizen/Account/plugin_config.h [deleted file]
src/standards/Tizen/Account/plugin_initializer.cpp [deleted file]
src/standards/Tizen/Alarm/AlarmConverter.cpp
src/standards/Tizen/Alarm/AlarmConverter.h
src/standards/Tizen/Alarm/CMakeLists.txt
src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp
src/standards/Tizen/Alarm/JSAlarmManager.cpp
src/standards/Tizen/Alarm/JSAlarmRelative.cpp
src/standards/Tizen/Alarm/plugin_config.h
src/standards/Tizen/Alarm/plugin_initializer.cpp
src/standards/Tizen/Application/ApplicationAnswerReceiver.h
src/standards/Tizen/Application/ApplicationConverter.cpp
src/standards/Tizen/Application/ApplicationListener.cpp
src/standards/Tizen/Application/ApplicationUtil.cpp
src/standards/Tizen/Application/ApplicationUtil.h
src/standards/Tizen/Application/CMakeLists.txt
src/standards/Tizen/Application/JSApplication.cpp
src/standards/Tizen/Application/JSApplication.h
src/standards/Tizen/Application/JSApplicationContext.cpp
src/standards/Tizen/Application/JSApplicationContext.h
src/standards/Tizen/Application/JSApplicationEvent.cpp
src/standards/Tizen/Application/JSApplicationInformation.cpp
src/standards/Tizen/Application/JSApplicationInformation.h
src/standards/Tizen/Application/JSApplicationInformationArray.h
src/standards/Tizen/Application/JSApplicationService.cpp
src/standards/Tizen/Application/JSApplicationService.h
src/standards/Tizen/Application/JSApplicationServiceData.cpp
src/standards/Tizen/Application/LaunchServicePrivateData.cpp
src/standards/Tizen/Application/config.xml
src/standards/Tizen/Application/plugin_config.cpp
src/standards/Tizen/Application/plugin_config.h
src/standards/Tizen/Application/plugin_initializer.cpp
src/standards/Tizen/Bluetooth/BluetoothAdapterListener.cpp
src/standards/Tizen/Bluetooth/BluetoothConverter.cpp
src/standards/Tizen/Bluetooth/BluetoothConverter.h
src/standards/Tizen/Bluetooth/BluetoothMultiCallback.cpp
src/standards/Tizen/Bluetooth/BluetoothSocketListener.cpp
src/standards/Tizen/Bluetooth/JSBluetoothAdapter.cpp
src/standards/Tizen/Bluetooth/JSBluetoothAdapter.h
src/standards/Tizen/Bluetooth/JSBluetoothClass.cpp
src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMajor.cpp
src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceMinor.cpp
src/standards/Tizen/Bluetooth/JSBluetoothClassDeviceService.cpp
src/standards/Tizen/Bluetooth/JSBluetoothDevice.cpp
src/standards/Tizen/Bluetooth/JSBluetoothManager.cpp
src/standards/Tizen/Bluetooth/JSBluetoothServiceHandler.cpp
src/standards/Tizen/Bluetooth/JSBluetoothSocket.cpp
src/standards/Tizen/Bluetooth/config.xml
src/standards/Tizen/Bluetooth/plugin_config.cpp
src/standards/Tizen/Bluetooth/plugin_config.h
src/standards/Tizen/Bluetooth/plugin_initializer.cpp
src/standards/Tizen/CMakeLists.txt
src/standards/Tizen/Calendar/CMakeLists.txt
src/standards/Tizen/Calendar/CalendarConverter.cpp
src/standards/Tizen/Calendar/CalendarConverter.h
src/standards/Tizen/Calendar/CalendarResponseDispatcher.cpp
src/standards/Tizen/Calendar/CalendarResponseDispatcher.h
src/standards/Tizen/Calendar/JSCalendar.cpp
src/standards/Tizen/Calendar/JSCalendar.h
src/standards/Tizen/Calendar/JSCalendarAlarm.cpp
src/standards/Tizen/Calendar/JSCalendarAttendee.cpp
src/standards/Tizen/Calendar/JSCalendarEvent.cpp
src/standards/Tizen/Calendar/JSCalendarEventId.cpp
src/standards/Tizen/Calendar/JSCalendarEventId.h
src/standards/Tizen/Calendar/JSCalendarItem.cpp [deleted file]
src/standards/Tizen/Calendar/JSCalendarItem.h [deleted file]
src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp [deleted file]
src/standards/Tizen/Calendar/JSCalendarItemGeo.h [deleted file]
src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp
src/standards/Tizen/Calendar/JSCalendarManager.cpp
src/standards/Tizen/Calendar/JSCalendarManager.h
src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp
src/standards/Tizen/Calendar/JSCalendarTask.cpp
src/standards/Tizen/Calendar/JSCalendarTask.h
src/standards/Tizen/Calendar/plugin_config.cpp
src/standards/Tizen/Calendar/plugin_config.h
src/standards/Tizen/Calendar/plugin_initializer.cpp
src/standards/Tizen/Call/CMakeLists.txt
src/standards/Tizen/Call/CallAsyncEventPrivateData.cpp [moved from src/platform/API/Call/EventSendUSSD.cpp with 61% similarity]
src/standards/Tizen/Call/CallAsyncEventPrivateData.h [moved from src/platform/API/Call/EventLaunchDialer.h with 51% similarity]
src/standards/Tizen/Call/CallStaticController.cpp
src/standards/Tizen/Call/Converter.cpp
src/standards/Tizen/Call/Converter.h
src/standards/Tizen/Call/JSCallHistory.cpp
src/standards/Tizen/Call/JSCallHistoryEntry.cpp
src/standards/Tizen/Call/JSCallHistoryEntry.h
src/standards/Tizen/Call/JSCallManager.cpp
src/standards/Tizen/Call/JSCallManager.h
src/standards/Tizen/Call/JSCallService.cpp [deleted file]
src/standards/Tizen/Call/JSCallService.h [deleted file]
src/standards/Tizen/Call/JSCellularCallService.cpp [deleted file]
src/standards/Tizen/Call/JSCellularCallService.h [deleted file]
src/standards/Tizen/Call/JSRemoteParty.cpp
src/standards/Tizen/Call/JSRemoteParty.h
src/standards/Tizen/Call/ResponseDispatcher.cpp
src/standards/Tizen/Call/ResponseDispatcher.h
src/standards/Tizen/Call/config.xml
src/standards/Tizen/Call/plugin_config.cpp
src/standards/Tizen/Call/plugin_config.h
src/standards/Tizen/Call/plugin_initializer.cpp
src/standards/Tizen/Common/CMakeLists.txt
src/standards/Tizen/Common/JSGlobalContextFactory.cpp [deleted file]
src/standards/Tizen/Common/JSGlobalContextFactory.h [deleted file]
src/standards/Tizen/Common/JSTizenException.cpp
src/standards/Tizen/Common/JSTizenException.h
src/standards/Tizen/Common/JSTizenExceptionFactory.cpp
src/standards/Tizen/Common/JSWebAPIError.cpp [new file with mode: 0644]
src/standards/Tizen/Common/JSWebAPIError.h [new file with mode: 0644]
src/standards/Tizen/Common/TizenExceptionData.cpp
src/standards/Tizen/Common/TizenExceptionData.h [changed mode: 0644->0755]
src/standards/Tizen/Contact/AddressBookController.cpp
src/standards/Tizen/Contact/AddressBookController.h
src/standards/Tizen/Contact/ContactConverter.cpp
src/standards/Tizen/Contact/ContactManagerController.cpp
src/standards/Tizen/Contact/ContactManagerController.h
src/standards/Tizen/Contact/JSAddressBook.cpp
src/standards/Tizen/Contact/JSAddressBookChangeCallbackManager.cpp
src/standards/Tizen/Contact/JSAddressBookChangeCallbackManager.h
src/standards/Tizen/Contact/JSContact.cpp
src/standards/Tizen/Contact/JSContact.h
src/standards/Tizen/Contact/JSContactAccount.cpp
src/standards/Tizen/Contact/JSContactAddress.cpp
src/standards/Tizen/Contact/JSContactAnniversary.cpp
src/standards/Tizen/Contact/JSContactEmailAddress.cpp
src/standards/Tizen/Contact/JSContactManager.cpp
src/standards/Tizen/Contact/JSContactName.cpp
src/standards/Tizen/Contact/JSContactOrganization.cpp
src/standards/Tizen/Contact/JSContactPhoneNumber.cpp
src/standards/Tizen/Contact/JSContactRef.cpp
src/standards/Tizen/Contact/JSContactWebSite.cpp
src/standards/Tizen/Contact/plugin_config.h
src/standards/Tizen/Contact/plugin_initializer.cpp
src/standards/Tizen/Filesystem/Converter.cpp
src/standards/Tizen/Filesystem/Converter.h
src/standards/Tizen/Filesystem/FilesystemUtils.cpp
src/standards/Tizen/Filesystem/JSFile.cpp
src/standards/Tizen/Filesystem/JSFile.h
src/standards/Tizen/Filesystem/JSFilestream.cpp
src/standards/Tizen/Filesystem/JSFilesystemManager.cpp
src/standards/Tizen/Filesystem/ResponseDispatcher.cpp
src/standards/Tizen/Filesystem/plugin_config.h
src/standards/Tizen/Filesystem/plugin_initializer.cpp
src/standards/Tizen/Geocoder/CMakeLists.txt [changed mode: 0755->0644]
src/standards/Tizen/Geocoder/DefaultGeocoderProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/DefaultGeocoderProvider.h [new file with mode: 0755]
src/standards/Tizen/Geocoder/GeocodeOptions.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/GeocodeOptions.h [moved from src/platform/API/Call/EventGetCallService.cpp with 57% similarity]
src/standards/Tizen/Geocoder/GeocoderACE.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/GeocoderACE.h [moved from src/platform/API/Account/AccountFilter.h with 54% similarity]
src/standards/Tizen/Geocoder/GeocoderController.cpp [deleted file]
src/standards/Tizen/Geocoder/GeocoderController.h [deleted file]
src/standards/Tizen/Geocoder/GeocoderProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/GeocoderProvider.h [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSAddress.cpp [deleted file]
src/standards/Tizen/Geocoder/JSAddress.h [deleted file]
src/standards/Tizen/Geocoder/JSCoordinates.cpp [deleted file]
src/standards/Tizen/Geocoder/JSCoordinates.h [deleted file]
src/standards/Tizen/Geocoder/JSGeocodeResult.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSGeocodeResult.h [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSGeocoder.cpp [deleted file]
src/standards/Tizen/Geocoder/JSGeocoder.h [deleted file]
src/standards/Tizen/Geocoder/JSGeocoderProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSGeocoderProvider.h [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSGeocoderServiceManager.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/JSGeocoderServiceManager.h [new file with mode: 0755]
src/standards/Tizen/Geocoder/ReverseGeocodeOptions.cpp [new file with mode: 0755]
src/standards/Tizen/Geocoder/ReverseGeocodeOptions.h [moved from src/platform/API/Call/EventLaunchDialer.cpp with 52% similarity]
src/standards/Tizen/Geocoder/config.xml [changed mode: 0644->0755]
src/standards/Tizen/Geocoder/plugin_config.cpp [deleted file]
src/standards/Tizen/Geocoder/plugin_initializer.cpp [changed mode: 0644->0755]
src/standards/Tizen/LBS/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/LBS/ConvertibleJSObject.h [moved from src/platform/API/Geocoder/GeocoderFactory.h with 61% similarity, mode: 0755]
src/standards/Tizen/LBS/GeoAddress.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/GeoAddress.h [new file with mode: 0755]
src/standards/Tizen/LBS/JSLBS.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/JSLBS.h [new file with mode: 0755]
src/standards/Tizen/LBS/JSLBSPending.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/JSLBSPending.h [new file with mode: 0755]
src/standards/Tizen/LBS/JSLocationServiceProvider.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/JSLocationServiceProvider.h [new file with mode: 0755]
src/standards/Tizen/LBS/LBS.cpp [moved from src/platform/API/Call/ICallService.cpp with 65% similarity]
src/standards/Tizen/LBS/LBS.h [moved from src/platform/API/Calendar/CalendarItemGeo.cpp with 56% similarity]
src/standards/Tizen/LBS/LBSAce.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/LBSAce.h [new file with mode: 0755]
src/standards/Tizen/LBS/LBSConverter.h [new file with mode: 0755]
src/standards/Tizen/LBS/LBSPending.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/LBSPending.h [moved from src/platform/API/Account/AccountFilter.cpp with 57% similarity]
src/standards/Tizen/LBS/LBSUtil.cpp [new file with mode: 0755]
src/standards/Tizen/LBS/LBSUtil.h [new file with mode: 0755]
src/standards/Tizen/LBS/LocationServiceProvider.h [new file with mode: 0755]
src/standards/Tizen/LBS/config.xml [new file with mode: 0755]
src/standards/Tizen/LBS/plugin_initializer.cpp [new file with mode: 0755]
src/standards/Tizen/Log/plugin_initializer.cpp
src/standards/Tizen/Mediacontent/JSAudio.cpp
src/standards/Tizen/Mediacontent/JSFolder.cpp
src/standards/Tizen/Mediacontent/JSImage.cpp
src/standards/Tizen/Mediacontent/JSMedia.cpp
src/standards/Tizen/Mediacontent/JSMediaLyrics.cpp
src/standards/Tizen/Mediacontent/JSMediacontent.cpp
src/standards/Tizen/Mediacontent/JSMediacontent.h
src/standards/Tizen/Mediacontent/JSMediacontentManager.cpp
src/standards/Tizen/Mediacontent/JSVideo.cpp
src/standards/Tizen/Mediacontent/MediaConverter.cpp
src/standards/Tizen/Mediacontent/MediaConverter.h
src/standards/Tizen/Mediacontent/MediacontentController.cpp
src/standards/Tizen/Mediacontent/plugin_config.cpp
src/standards/Tizen/Mediacontent/plugin_config.h
src/standards/Tizen/Mediacontent/plugin_initializer.cpp
src/standards/Tizen/Messaging/ConverterMessage.cpp
src/standards/Tizen/Messaging/EventMessagingServicePrivateData.cpp
src/standards/Tizen/Messaging/EventMessagingServicePrivateData.h
src/standards/Tizen/Messaging/JSMessage.cpp
src/standards/Tizen/Messaging/JSMessageAttachment.cpp
src/standards/Tizen/Messaging/JSMessagingService.cpp
src/standards/Tizen/Messaging/JSMessagingService.h
src/standards/Tizen/Messaging/JSMessagingServiceManager.cpp
src/standards/Tizen/Messaging/JSMessagingStorage.cpp
src/standards/Tizen/Messaging/JSMessagingStorage.h
src/standards/Tizen/Messaging/MessagingController.cpp
src/standards/Tizen/Messaging/MessagingListener.cpp
src/standards/Tizen/Messaging/MessagingListener.h
src/standards/Tizen/Messaging/MessagingStorageMultiCallback.cpp
src/standards/Tizen/Messaging/MessagingStorageMultiCallback.h
src/standards/Tizen/Messaging/config.xml
src/standards/Tizen/Messaging/plugin_config.cpp
src/standards/Tizen/Messaging/plugin_config.h
src/standards/Tizen/Messaging/plugin_initializer.cpp
src/standards/Tizen/NFC/CMakeLists.txt
src/standards/Tizen/NFC/JSNFCAdapter.cpp [new file with mode: 0644]
src/standards/Tizen/NFC/JSNFCAdapter.h [moved from src/standards/Tizen/NFC/JSNFCTagMifareUltra.h with 55% similarity, mode: 0644]
src/standards/Tizen/NFC/JSNFCManager.cpp
src/standards/Tizen/NFC/JSNFCManager.h
src/standards/Tizen/NFC/JSNFCTag.cpp [changed mode: 0755->0644]
src/standards/Tizen/NFC/JSNFCTagMifareClassic.cpp [deleted file]
src/standards/Tizen/NFC/JSNFCTagMifareClassic.h [deleted file]
src/standards/Tizen/NFC/JSNFCTagMifareUltra.cpp [deleted file]
src/standards/Tizen/NFC/JSNFCTarget.cpp [changed mode: 0755->0644]
src/standards/Tizen/NFC/JSNdefMessage.cpp
src/standards/Tizen/NFC/JSNdefRecord.cpp
src/standards/Tizen/NFC/JSNdefRecord.h
src/standards/Tizen/NFC/JSNdefRecordArray.cpp
src/standards/Tizen/NFC/JSNdefRecordMedia.cpp
src/standards/Tizen/NFC/JSNdefRecordText.cpp
src/standards/Tizen/NFC/JSNdefRecordURI.cpp
src/standards/Tizen/NFC/NFCChangedCallback.h
src/standards/Tizen/NFC/NFCConverter.cpp
src/standards/Tizen/NFC/NFCConverter.h
src/standards/Tizen/NFC/NFCStaticController.cpp
src/standards/Tizen/NFC/NFCStaticController.h
src/standards/Tizen/NFC/ResponseDispatcher.cpp
src/standards/Tizen/NFC/ResponseDispatcher.h
src/standards/Tizen/NFC/plugin_config.cpp
src/standards/Tizen/NFC/plugin_config.h
src/standards/Tizen/NFC/plugin_initializer.cpp
src/standards/Tizen/POI/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/POI/DefaultPOIProvider.cpp [new file with mode: 0755]
src/standards/Tizen/POI/DefaultPOIProvider.h [new file with mode: 0755]
src/standards/Tizen/POI/GeoBounds.cpp [new file with mode: 0755]
src/standards/Tizen/POI/GeoBounds.h [new file with mode: 0755]
src/standards/Tizen/POI/GeometryFilter.cpp [moved from src/platform/API/Call/CallServiceObject.cpp with 50% similarity]
src/standards/Tizen/POI/GeometryFilter.h [moved from src/platform/API/Geocoder/GeocoderFactory.cpp with 59% similarity, mode: 0755]
src/standards/Tizen/POI/JSGeoCircleBounds.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSGeoCircleBounds.h [new file with mode: 0755]
src/standards/Tizen/POI/JSGeoPolyBounds.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSGeoPolyBounds.h [new file with mode: 0755]
src/standards/Tizen/POI/JSGeoRectBounds.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSGeoRectBounds.h [new file with mode: 0755]
src/standards/Tizen/POI/JSGeometryFilter.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSGeometryFilter.h [new file with mode: 0755]
src/standards/Tizen/POI/JSPOI.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSPOI.h [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIFilter.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIFilter.h [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIGeometry.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIGeometry.h [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIProvider.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIProvider.h [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIServiceManager.cpp [new file with mode: 0755]
src/standards/Tizen/POI/JSPOIServiceManager.h [new file with mode: 0755]
src/standards/Tizen/POI/POI.cpp [new file with mode: 0755]
src/standards/Tizen/POI/POI.h [new file with mode: 0755]
src/standards/Tizen/POI/POIAce.cpp [new file with mode: 0755]
src/standards/Tizen/POI/POIAce.h [new file with mode: 0755]
src/standards/Tizen/POI/POIFilter.cpp [new file with mode: 0755]
src/standards/Tizen/POI/POIFilter.h [moved from src/platform/API/Geocoder/IGeocoder.cpp with 64% similarity, mode: 0755]
src/standards/Tizen/POI/POIGeometry.cpp [new file with mode: 0755]
src/standards/Tizen/POI/POIGeometry.h [moved from src/platform/Tizen/Filesystem/RemoveCommand.h with 52% similarity]
src/standards/Tizen/POI/POIProvider.cpp [new file with mode: 0755]
src/standards/Tizen/POI/POIProvider.h [new file with mode: 0755]
src/standards/Tizen/POI/RequestOptions.cpp [new file with mode: 0755]
src/standards/Tizen/POI/RequestOptions.h [new file with mode: 0755]
src/standards/Tizen/POI/config.xml [new file with mode: 0755]
src/standards/Tizen/POI/plugin_initializer.cpp [new file with mode: 0755]
src/standards/Tizen/Route/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/Route/DefaultRouteProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Route/DefaultRouteProvider.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteDistance.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteDistance.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteDuration.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteDuration.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteProvider.h [moved from src/standards/Tizen/Sensors/JSSensorError.h with 50% similarity, mode: 0755]
src/standards/Tizen/Route/JSRouteResult.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteResult.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteResultSummary.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteResultSummary.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteSegment.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteSegment.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteServiceManager.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteServiceManager.h [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteStep.cpp [new file with mode: 0755]
src/standards/Tizen/Route/JSRouteStep.h [new file with mode: 0755]
src/standards/Tizen/Route/RouteAce.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteAce.h [moved from src/standards/Tizen/Geocoder/plugin_config.h with 50% similarity]
src/standards/Tizen/Route/RouteDistance.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteDistance.h [moved from src/platform/API/Call/CallServiceObject.h with 53% similarity]
src/standards/Tizen/Route/RouteDuration.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteDuration.h [moved from src/platform/API/Call/EventSendUSSD.h with 54% similarity]
src/standards/Tizen/Route/RouteProvider.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteProvider.h [new file with mode: 0755]
src/standards/Tizen/Route/RouteRequestOptions.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteRequestOptions.h [new file with mode: 0755]
src/standards/Tizen/Route/RouteResult.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteResult.h [new file with mode: 0755]
src/standards/Tizen/Route/RouteResultSummary.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteResultSummary.h [moved from src/platform/API/Account/AccountFactory.h with 50% similarity]
src/standards/Tizen/Route/RouteSegment.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteSegment.h [new file with mode: 0755]
src/standards/Tizen/Route/RouteStep.cpp [new file with mode: 0755]
src/standards/Tizen/Route/RouteStep.h [new file with mode: 0755]
src/standards/Tizen/Route/config.xml [new file with mode: 0755]
src/standards/Tizen/Route/plugin_initializer.cpp [new file with mode: 0755]
src/standards/Tizen/Sensors/CMakeLists.txt
src/standards/Tizen/Sensors/JSSensorConnection.cpp [changed mode: 0755->0644]
src/standards/Tizen/Sensors/JSSensorDataEvent.cpp
src/standards/Tizen/Sensors/JSSensorDataEvent.h
src/standards/Tizen/Sensors/JSSensorError.cpp [deleted file]
src/standards/Tizen/Sensors/JSSensorManager.cpp
src/standards/Tizen/Sensors/JSSensorRequest.cpp
src/standards/Tizen/Sensors/SensorType.cpp
src/standards/Tizen/Sensors/SensorType.h
src/standards/Tizen/Sensors/plugin_initializer.cpp
src/standards/Tizen/Systeminfo/JSCellularNetworkInfo.cpp [changed mode: 0755->0644]
src/standards/Tizen/Systeminfo/JSSysteminfo.cpp
src/standards/Tizen/Systeminfo/plugin_config.h
src/standards/Tizen/Systeminfo/plugin_initializer.cpp
src/standards/Tizen/TimeUtil/JSTZDate.cpp
src/standards/Tizen/TimeUtil/JSTimeDuration.cpp
src/standards/Tizen/TimeUtil/JSTimeDuration.h
src/standards/Tizen/TimeUtil/JSTimeUtil.cpp
src/standards/Tizen/TimeUtil/TimeUtilConverter.cpp
src/standards/Tizen/TimeUtil/TimeUtilConverter.h
src/standards/Tizen/TimeUtil/plugin_config.h
src/standards/Tizen/TimeUtil/plugin_initializer.cpp
src/standards/Tizen/Tizen/CMakeLists.txt
src/standards/Tizen/Tizen/JSAttributeFilter.cpp
src/standards/Tizen/Tizen/JSAttributeRangeFilter.cpp
src/standards/Tizen/Tizen/JSCompositeFilter.cpp
src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp
src/standards/Tizen/Tizen/JSSortMode.cpp
src/standards/Tizen/Tizen/JSTizen.cpp
src/standards/Tizen/Tizen/PluginOnDemandPriv.cpp
src/standards/Tizen/Tizen/PluginOnDemandPriv.h
src/standards/Tizen/Tizen/plugin_initializer.cpp

diff --git a/.gitignore b/.gitignore
deleted file mode 100644 (file)
index e6d02f4..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-.cproject
-.project
-.settings
-*.wgt
-Debug
-*.so
-*.swp
-CMakeCache.txt
-CMakeFiles
-build-stamp
-cmake_install.cmake
-configure-stamp
-debian/debhelper.log
-debian/files
-debian/wrt-plugins-tizen-dbg.debhelper.log
-debian/wrt-plugins-tizen-dbg.substvars
-debian/wrt-plugins-tizen-dbg/
-debian/wrt-plugins-tizen.debhelper.log
-debian/wrt-plugins-tizen.install
-debian/wrt-plugins-tizen.postinst.debhelper
-debian/wrt-plugins-tizen.postrm.debhelper
-debian/wrt-plugins-tizen.substvars
-debian/wrt-plugins-tizen/
-debian/substvars
-debian/tmp/
-install_manifest.txt
-Makefile
-config.guess
-config.sub
-
index 8795534..d3b3ec8 100755 (executable)
@@ -10,7 +10,7 @@ project(wrt-plugins-tizen)
 include(FindPkgConfig)
 
 pkg_search_module(webkit REQUIRED ewebkit>=0.1.0)
-pkg_search_module(dpl REQUIRED dpl-efl>=1.0.0)
+pkg_search_module(dpl REQUIRED dpl-efl)
 pkg_search_module(dpl-event REQUIRED dpl-event-efl)
 pkg_search_module(wrt-plugin-api REQUIRED wrt-plugin-api>=0.7.0)
 pkg_search_module(wrt-deviceapis-commons REQUIRED wrt-plugins-commons)
index de82edc..8232caf 100644 (file)
@@ -1,3 +1,322 @@
+wrt-plugins-tizen (0.2.31) unstable; urgency=low
+
+  * NFC Bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.31
+
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Mon, 23 Apr 2012 18:29:52 +0900
+
+wrt-plugins-tizen (0.2.30) unstable; urgency=low
+
+  * Fix Message build break
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.30
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Mon, 23 Apr 2012 17:04:31 +0900
+
+wrt-plugins-tizen (0.2.29) unstable; urgency=low
+
+  * Fix Application module bug
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.29
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Sun, 22 Apr 2012 20:15:07 +0900
+
+wrt-plugins-tizen (0.2.28) unstable; urgency=low
+
+  * Fix bug on BT, Calendar, Messaging and NFC
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.28
+
+ -- Kisub Song <kisubs.song@samsung.net>  Sat, 21 Apr 2012 19:48:50 +0900
+
+wrt-plugins-tizen (0.2.27) unstable; urgency=low
+
+  * Bug patch for Calendar API
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.27
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 20 Apr 2012 16:49:49 +0900
+
+wrt-plugins-tizen (0.2.26) unstable; urgency=low
+
+  * Apply API change on calendar-svc
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.26
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 20 Apr 2012 14:44:32 +0900
+
+wrt-plugins-tizen (0.2.25) unstable; urgency=low
+
+  * Fix bug on MediaContent
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.25
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 19 Apr 2012 16:44:55 +0900
+
+wrt-plugins-tizen (0.2.24) unstable; urgency=low
+
+  * Fix bug on MediaContent and Sensor
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.24
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 19 Apr 2012 14:59:55 +0900
+
+wrt-plugins-tizen (0.2.23) unstable; urgency=low
+
+  * Fix bug on Filesystem and Call
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.23
+
+ -- Kisub Song <kisubs.song@samsung.com>  Mon, 16 Apr 2012 22:43:00 +0900
+
+wrt-plugins-tizen (0.2.22) unstable; urgency=low
+
+  * Fix TC Bug on Contact, Calendar and Geocoder
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.22
+
+ -- Kisub Song <kisubs.song@samsung.com>  Mon, 16 Apr 2012 18:42:19 +0900
+
+wrt-plugins-tizen (0.2.21) unstable; urgency=low
+
+  * Raise version for public merge
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.21
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 12 Apr 2012 19:20:34 +0900
+
+wrt-plugins-tizen (0.2.20) unstable; urgency=low
+
+  * Bug fix on Calendar and Filesystem
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.20
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 12 Apr 2012 16:36:40 +0900
+
+wrt-plugins-tizen (0.2.19) unstable; urgency=low
+
+  * NFC, Calendar, MediaContents bugfix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.19
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Mon, 09 Apr 2012 15:12:23 +0900
+
+wrt-plugins-tizen (0.2.18) unstable; urgency=low
+
+  * Bug fix on NFC
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.18
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 06 Apr 2012 13:44:40 +0900
+
+wrt-plugins-tizen (0.2.17) unstable; urgency=low
+
+  * Bug fix on Application and Calendar
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.17
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 06 Apr 2012 13:27:41 +0900
+
+wrt-plugins-tizen (0.2.16) unstable; urgency=low
+
+  * Change WebAPIError
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.16
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 05 Apr 2012 17:12:29 +0900
+
+wrt-plugins-tizen (0.2.15) unstable; urgency=low
+
+  * Apply spec change on NFC
+  * Bug fix on Filesystem, Systeminfo and Application
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.15
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 05 Apr 2012 15:08:18 +0900
+
+wrt-plugins-tizen (0.2.14) unstable; urgency=low
+
+  * Bug fix on Calendar.
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.14
+
+ -- Kisub Song <kisubs.song@samsung.com>  Wed, 04 Apr 2012 16:54:51 +0900
+
+wrt-plugins-tizen (0.2.13) unstable; urgency=low
+
+  * Bug fix on NFC, Messaging, Bluetooth, MediaContent
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.13
+
+ -- Kisub Song <kisubs.song@samsung.com>  Tue, 03 Apr 2012 12:21:53 +0900
+
+wrt-plugins-tizen (0.2.12) unstable; urgency=low
+
+  * Contact, Calendar, Geocoder bug fix.
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.12
+
+ -- Kisub Song <kisubs.song@samsung.com>  Tue, 03 Apr 2012 00:05:59 +0900
+
+wrt-plugins-tizen (0.2.11) unstable; urgency=low
+
+  * POI, SystemInfo bug fix.
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.11
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 30 Mar 2012 14:48:39 +0900
+
+wrt-plugins-tizen (0.2.10) unstable; urgency=low
+
+  * Bug fix - Bluetooth, POI
+  * Remove PendingOperation
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.10
+
+ -- Kisub Song <kisubs.song@samsung.com>  Thu, 29 Mar 2012 15:59:32 +0900
+
+wrt-plugins-tizen (0.2.9) unstable; urgency=low
+
+  * Messaging error fix.
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.9
+
+ -- Kisub Song <kisubs.song@samsung.com>  Wed, 28 Mar 2012 16:44:48 +0900
+
+wrt-plugins-tizen (0.2.8) unstable; urgency=low
+
+  * Remove Account code from Call
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.8
+
+ -- Kisub Song <kisubs.song@samsung.com>  Wed, 28 Mar 2012 15:42:33 +0900
+
+wrt-plugins-tizen (0.2.7) unstable; urgency=low
+
+  * NFC, MediaContent applied new API style.
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.7
+
+ -- Kisub Song <kisubs.song@samsung.com>  Wed, 28 Mar 2012 13:46:22 +0900
+
+wrt-plugins-tizen (0.2.6) unstable; urgency=low
+
+  * POI Changed
+  * Apply new API styles
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.6
+
+ -- Kisub Song <kisubs.song@samsung.com>  Mon, 26 Mar 2012 22:47:36 +0900
+
+wrt-plugins-tizen (0.2.5) unstable; urgency=low
+
+  * Update Test Cases
+  * Bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.5
+
+ -- Kisub Song <kisubs.song@samsung.com>  Mon, 26 Mar 2012 12:03:53 +0900
+
+wrt-plugins-tizen (0.2.4) unstable; urgency=low
+
+  * NFC undated
+  * Argument checking rule changed
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.4
+
+ -- Kisub Song <kisubs.song@samsung.com>  Fri, 23 Mar 2012 13:19:16 +0900
+
+wrt-plugins-tizen (0.2.3) unstable; urgency=low
+
+  * Messaging, Time bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.3
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Wed, 21 Mar 2012 15:24:57 +0900
+
+wrt-plugins-tizen (0.2.2) unstable; urgency=low
+
+  * LBS, Messaging bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.2
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Tue, 20 Mar 2012 14:05:13 +0900
+
+wrt-plugins-tizen (0.2.1) unstable; urgency=low
+
+  * Change APIs to SEC style
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.1
+
+
+ -- Taehee Lee <th219.lee@samsung.com>  Fri, 16 Mar 2012 22:54:12 +0900
+
+wrt-plugins-tizen (0.2.0-20) unstable; urgency=low
+
+  * Change APIs to SEC style
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-20
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Thu, 15 Mar 2012 11:11:57 +0900
+
+wrt-plugins-tizen (0.2.0-19) unstable; urgency=low
+
+  * Apply changed interfaces regarding plugins start function and security check
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-19
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Wed, 14 Mar 2012 16:46:13 +0900
+
+wrt-plugins-tizen (0.2.0-18) unstable; urgency=low
+
+  * fix NFC Build error
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-18
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Tue, 13 Mar 2012 10:48:47 +0900
+
+wrt-plugins-tizen (0.2.0-17) unstable; urgency=low
+
+  * Call, Calendar bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-17
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Fri, 02 Mar 2012 15:41:29 +0900
+
+wrt-plugins-tizen (0.2.0-16) unstable; urgency=low
+
+  * fix build error. change dpl-efl dependency version
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-16
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Wed, 29 Feb 2012 14:55:06 +0900
+
+wrt-plugins-tizen (0.2.0-15) unstable; urgency=low
+
+  * Filesystem, Messaging, Mediacontents bug fix
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-15
+
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Tue, 28 Feb 2012 19:19:46 +0900
+
+wrt-plugins-tizen (0.2.0-14) unstable; urgency=low
+
+  * Apply wrt chages. remove plugins APIs
+  * Git : slp/pkgs/w/wrt-plugins-tizen
+  * Tag : wrt-plugins-tizen_0.2.0-14
+
+ -- Sangtai Kim <sangtai.kim@samsung.com>  Mon, 27 Feb 2012 11:09:30 +0900
+
 wrt-plugins-tizen (0.2.0-13) unstable; urgency=low
 
   * Alarm bug fix
index 124a01d..749b7b6 100755 (executable)
@@ -1,14 +1,14 @@
 Source: wrt-plugins-tizen
 Section: devel
 Priority: extra
-Maintainer: Taehee Lee <th219.lee@samsung.com>, Sangtai Kim <sangtai.kim@samsung.com>, Jaehyun Park <jaehyun77.park@samsung.com>, KeeDuck Kim <keeduck.kim@samsung.com>
-Build-Depends: debhelper (>= 5), wrt-dev (>=0.8.5), wrt-commons-dev (>=0.2.6), libwebkit-engine-dev, capi-location-geocoder-dev, libmm-camcorder-dev, capi-network-bluetooth-dev, capi-appfw-app-manager-dev, capi-appfw-application-dev, libslp-calendar-dev, capi-system-sensor-dev, libappsvc-dev, email-service-dev, libslp-msg-service-dev (>=0.5.0), capi-telephony-call-dev, libicu-dev, libnetwork-dev, libslp-setting-dev, libdevman-dev, capi-social-call-log-dev, libdownload-agent-dev,libaccounts-svc-dev , libslp-tapi-dev, wrt-plugins-common-dev (>=0.3.7), capi-network-nfc-dev, libaul-1-dev, libmm-fileinfo-dev, libcontacts-service-dev
-Uploaders: Sangtai Kim <sangtai.kim@samsung.com>
+Maintainer: Taehee Lee <th219.lee@samsung.com>, Sangtai Kim <sangtai.kim@samsung.com>, Jaehyun Park <jaehyun77.park@samsung.com>, KeeDuck Kim <keeduck.kim@samsung.com>, Kisub Song <kisubs.song@samsung.com>
+Build-Depends: debhelper (>= 5), wrt-dev (>=0.8.27), wrt-commons-dev (>=0.2.6), libwebkit-engine-dev, capi-location-manager-dev, capi-location-geocoder-dev, libmm-camcorder-dev, capi-network-bluetooth-dev, capi-appfw-app-manager-dev, capi-appfw-application-dev, libslp-calendar-dev, capi-system-sensor-dev, libappsvc-dev, email-service-dev, libslp-msg-service-dev (>=0.5.0), capi-telephony-call-dev, libicu-dev, libnetwork-dev, libslp-setting-dev, libdevman-dev, capi-social-call-log-dev, libdownload-agent-dev,libaccounts-svc-dev , libslp-tapi-dev, wrt-plugins-common-dev (>=0.3.7), capi-network-nfc-dev, libaul-1-dev, libmm-fileinfo-dev, libcontacts-service-dev, capi-system-power-dev
+Uploaders: Sangtai Kim <sangtai.kim@samsung.com>, Kisub Song <kisubs.song@samsung.com>
 
 Package: wrt-plugins-tizen
 Architecture: any
 Section: libs
-Depends: ${shlibs:Depends}, ${misc:Depends}, wrt (>=0.8.5), wrt-commons (>=0.2.6), wrt-plugins-common (>=0.3.7)
+Depends: ${shlibs:Depends}, ${misc:Depends}, wrt-commons (>=0.2.6), wrt-plugins-common (>=0.3.7)
 Description: JavaScript plugins for WebRuntime
 
 Package: wrt-plugins-tizen-dbg
index dbdb40c..4ae9432 100644 (file)
-Name:           wrt-plugins-tizen
-Version:       0.2.0
-Release:       1
-License:       Apache-2.0
-Summary:       Tizen Web APIs
-Group:         API
-Source:                %{name}-%{version}.tar.bz2
-BuildRequires: pkgconfig(wrt-engine)
-BuildRequires: pkgconfig(ewebkit)
-BuildRequires: pkgconfig(location)
-BuildRequires: pkgconfig(mm-player)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(tapi)
-BuildRequires: pkgconfig(sqlite3)
-BuildRequires: pkgconfig(libssl)
-BuildRequires: pkgconfig(calendar)
-BuildRequires: pkgconfig(mm-camcorder)
-BuildRequires: pkgconfig(email-service)
-BuildRequires: pkgconfig(msg-service)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(glib-2.0)
-BuildRequires: pkgconfig(mm-sound)
-BuildRequires: pkgconfig(dpl-efl)
-BuildRequires: pkgconfig(devman)
-BuildRequires: pkgconfig(appcore-efl)
-BuildRequires: pkgconfig(contacts-service)
-BuildRequires: pkgconfig(iniparser)
-BuildRequires: pkgconfig(pmapi)
-BuildRequires: pkgconfig(avsystem)
-BuildRequires: pkgconfig(appcore-common)
-BuildRequires: pkgconfig(audio-session-mgr)
-BuildRequires: pkgconfig(libdownload-agent)
-BuildRequires: pkgconfig(capi-system-sensor)
-BuildRequires: pkgconfig(capi-location-geocoder) 
-BuildRequires: pkgconfig(capi-network-nfc) 
-BuildRequires: pkgconfig(network)
-BuildRequires: pkgconfig(icu-i18n)
-BuildRequires: pkgconfig(capi-appfw-application)
-BuildRequires: pkgconfig(capi-appfw-app-manager)
-BuildRequires: pkgconfig(capi-network-bluetooth)
-BuildRequires: pkgconfig(capi-social-call-log)
-BuildRequires: pkgconfig(capi-telephony-network-info)
-BuildRequires: pkgconfig(libpcrecpp)
-BuildRequires: pkgconfig(wrt-plugins-commons)
-BuildRequires: pkgconfig(aul)
-BuildRequires: pkgconfig(mm-fileinfo)
-BuildRequires: pkgconfig(contacts-service)
-BuildRequires: pkgconfig(accounts-svc)
-BuildRequires: pkgconfig(capi-telephony-call)
-BuildRequires: expat-devel
-BuildRequires: cmake
-BuildRequires: gettext-tools
-BuildRequires: edje-tools
+Name:       wrt-plugins-tizen
+Summary:    JavaScript plugins for WebRuntime
+Version:    0.2.31
+Release:    0
+Group:      TO_BE_FILLED
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  pkgconfig(mm-fileinfo)
+BuildRequires:  pkgconfig(libpcrecpp)
+BuildRequires:  pkgconfig(calendar-service)
+BuildRequires:  pkgconfig(contacts-service)
+BuildRequires:  pkgconfig(msg-service)
+BuildRequires:  pkgconfig(email-service)
+BuildRequires:  pkgconfig(accounts-svc)
+BuildRequires:  pkgconfig(libdownload-agent)
+BuildRequires:  pkgconfig(tapi)
+BuildRequires:  pkgconfig(icu-i18n)
+BuildRequires:  pkgconfig(icu-io)
+BuildRequires:  pkgconfig(icu-le)
+BuildRequires:  pkgconfig(icu-lx)
+BuildRequires:  pkgconfig(icu-uc)
+BuildRequires:  pkgconfig(network)
+BuildRequires:  pkgconfig(devman)
+BuildRequires:  pkgconfig(ewebkit)
+BuildRequires:  pkgconfig(dpl-efl)
+BuildRequires:  pkgconfig(dpl-event-efl)
+BuildRequires:  pkgconfig(wrt-plugin-api)
+BuildRequires:  pkgconfig(wrt-plugins-commons)
+BuildRequires:  pkgconfig(wrt-plugins-commons-javascript)
+BuildRequires:  pkgconfig(wrt-plugins-plugin-manager)
+BuildRequires:  pkgconfig(capi-appfw-application)
+BuildRequires:  pkgconfig(capi-appfw-app-manager)
+BuildRequires:  pkgconfig(capi-network-nfc)
+BuildRequires:  pkgconfig(capi-location-geocoder)
+BuildRequires:  pkgconfig(capi-location-manager)
+BuildRequires:  pkgconfig(capi-network-bluetooth)
+BuildRequires:  pkgconfig(capi-social-call-log)
+BuildRequires:  pkgconfig(capi-telephony-call)
+BuildRequires:  pkgconfig(capi-system-sensor)
+BuildRequires:  pkgconfig(capi-system-power)
+BuildRequires:  expat-devel
+BuildRequires:  cmake
+BuildRequires:  gettext-devel
 
 %description
-Tizen Web APIs
+JavaScript plugins for WebRuntime
 
 
 %prep
 %setup -q
 
 %build
-export LDFLAGS+="-Wl,--rpath=%{_libdir} -Wl,--as-needed -Wl,--hash-style=both -Wl"
-cmake . -DCMAKE_INSTALL_PREFIX=%{_libdir}/wrt-plugins
+
+%define PREFIX "/usr/lib/wrt-plugins"
+
+export LDFLAGS+="-Wl,--rpath=%{PREFIX}/lib -Wl,--as-needed"
+
+cmake . -DCMAKE_INSTALL_PREFIX=%{PREFIX} -DDPL_LOG="OFF"
 
 make %{?jobs:-j%jobs}
 
 %install
+rm -rf %{buildroot}
 %make_install
 
+%post
+
+%postun
+
 
 %files
-/usr/etc/tizen-apis/config.dtd
-%{_libdir}/wrt-plugins/tizen-1.0-application/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-application/libwrt-plugins-tizen-1.0-application.so
-%{_libdir}/wrt-plugins/tizen-1.0-bluetooth/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-bluetooth/libwrt-plugins-tizen-1.0-bluetooth.so
-%{_libdir}/wrt-plugins/tizen-1.0-calendar/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-calendar/libwrt-plugins-tizen-1.0-calendar.so
-%{_libdir}/wrt-plugins/tizen-1.0-call/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-call/libwrt-plugins-tizen-1.0-call.so
-%{_libdir}/wrt-plugins/tizen-1.0-contact/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-contact/libwrt-plugins-tizen-1.0-contact.so
-%{_libdir}/wrt-plugins/tizen-1.0-geocoder/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-geocoder/libwrt-plugins-tizen-1.0-geocoder.so
-%{_libdir}/wrt-plugins/tizen-1.0-messaging/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-messaging/libwrt-plugins-tizen-1.0-messaging.so
-%{_libdir}/wrt-plugins/tizen-1.0-nfc/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-nfc/libwrt-plugins-tizen-1.0-nfc.so
-%{_libdir}/wrt-plugins/tizen-1.0-sensors/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-sensors/libwrt-plugins-tizen-1.0-sensors.so
-%{_libdir}/wrt-plugins/tizen-1.0-systeminfo/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-systeminfo/libwrt-plugins-tizen-1.0-systeminfo.so
-%{_libdir}/wrt-plugins/tizen-1.0-time/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-time/libwrt-plugins-tizen-1.0-time.so
-%{_libdir}/wrt-plugins/tizen-1.0-tizen/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-tizen/libwrt-plugins-tizen-1.0-tizen.so
-%{_libdir}/wrt-plugins/tizen-1.0-alarm/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-alarm/libwrt-plugins-tizen-1.0-alarm.so
-%{_libdir}/wrt-plugins/tizen-1.0-contact/libwrt-plugins-tizen-1.0-contact-impl.so
-%{_libdir}/wrt-plugins/tizen-1.0-filesystem/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-filesystem/libwrt-plugins-tizen-1.0-filesystem-impl.so
-%{_libdir}/wrt-plugins/tizen-1.0-filesystem/libwrt-plugins-tizen-1.0-filesystem.so
-%{_libdir}/wrt-plugins/tizen-1.0-mediacontent/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-mediacontent/libwrt-plugins-tizen-1.0-mediacontent.so
-%{_libdir}/wrt-plugins/tizen-1.0-time/libwrt-plugins-tizen-1.0-time-impl.so
-%{_libdir}/wrt-plugins/tizen-1.0-tizen/libwrt-plugins-tizen-1.0-common.so
-%{_libdir}/wrt-plugins/tizen-1.0-tizen/libwrt-plugins-tizen-1.0-tizen-impl.so
-%{_libdir}/wrt-plugins/tizen-1.0-tizenlog/config.xml
-%{_libdir}/wrt-plugins/tizen-1.0-tizenlog/libwrt-plugins-tizen-1.0-tizenlog.so
+/usr/lib/wrt-plugins/*
+/usr/etc/tizen-apis/*
 
diff --git a/src/platform/API/Account/AccountFactory.cpp b/src/platform/API/Account/AccountFactory.cpp
deleted file mode 100755 (executable)
index 41b3a1f..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#include "AccountFactory.h"
-#include "IAccountManager.h"
-#include "IAccountService.h"
-#include <Account/AccountManager.h>
-
-using namespace TizenApis::Platform::Account;
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-IAccountManagerPtr AccountFactory::createAccountManagerObject()
-{
-    LogDebug("entered");
-    IAccountManagerPtr result(new AccountManager());
-    return result;
-}
-
-//TODO: which is right, account or accountservice?
-//IAccountServicePtr AccountFactory::createAccountObject()
-//{
-//    LogDebug("entered");
-//    IAccountServicePtr result(new AccountService());
-//    return result;
-//}
-
-AccountFactory& AccountFactory::getInstance()
-{
-    LogDebug("entered");
-    static AccountFactory theInstance;
-    return theInstance;
-}
-
-
-}
-}
-}
diff --git a/src/platform/API/Account/AccountServiceFilterProperty.cpp b/src/platform/API/Account/AccountServiceFilterProperty.cpp
deleted file mode 100644 (file)
index 4617f85..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * AccountServiceFilterProperty.cpp
- *
- *  Created on: 2012. 2. 2.
- *      Author: sangtai
- */
-
-#include "AccountServiceFilterProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       AccountServiceFilterProperty::AccountServiceFilterProperty() {
-                       }
-
-                       AccountServiceFilterProperty::~AccountServiceFilterProperty() {
-                       }
-
-                       std::string AccountServiceFilterProperty::getServiceTypeId() const{
-                               return m_serviceTypeId;
-                       }
-
-                       void AccountServiceFilterProperty::setServiceTypeId(const std::string &value){
-                               m_serviceTypeId = value;
-                       }
-
-                       std::string AccountServiceFilterProperty::getProvider() const{
-                               return m_provider;
-                       }
-                       void AccountServiceFilterProperty::setProvider(const std::string &value){
-                               m_provider = value;
-                       }
-
-                       std::vector<std::string > AccountServiceFilterProperty::getTags() const{
-                               return m_tags;
-                       }
-                       void AccountServiceFilterProperty::setTags(const std::vector<std::string >& value){
-                               m_tags = value;
-                       }
-
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
diff --git a/src/platform/API/Account/AccountServiceFilterProperty.h b/src/platform/API/Account/AccountServiceFilterProperty.h
deleted file mode 100644 (file)
index ebebeb5..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * AccountServiceFilterProperty.h
- *
- *  Created on: 2012. 2. 2.
- *      Author: sangtai
- */
-
-#ifndef ACCOUNTSERVICEFILTERPROPERTY_H_
-#define ACCOUNTSERVICEFILTERPROPERTY_H_
-
-#include <string>
-#include <vector>
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class AccountServiceFilterProperty {
-                               public:
-                                       AccountServiceFilterProperty();
-                                       virtual ~AccountServiceFilterProperty();
-
-                                       std::string getServiceTypeId() const;
-                                       void setServiceTypeId(const std::string &value);
-
-                                       std::string getProvider() const;
-                                       void setProvider(const std::string &value);
-
-                                       std::vector<std::string > getTags() const;
-                                       void setTags(const std::vector<std::string >& value);
-
-                               private:
-                                       std::string m_serviceTypeId;
-                                       std::string m_provider;
-                                       std::vector<std::string > m_tags;
-                       };
-
-                       typedef DPL::SharedPtr<AccountServiceFilterProperty> AccountServiceFilterPropertyPtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* ACCOUNTSERVICEFILTERPROPERTY_H_ */
diff --git a/src/platform/API/Account/AccountServiceProviderProperty.cpp b/src/platform/API/Account/AccountServiceProviderProperty.cpp
deleted file mode 100755 (executable)
index e494dfb..0000000
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-/*
- * AccountServiceProviderProperty.cpp
- *
- *  Created on: 2012. 2. 1.
- *      Author: sangtai
- */
-
-#include "AccountServiceProviderProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       AccountServiceProviderProperty::AccountServiceProviderProperty() {
-                       }
-
-                       AccountServiceProviderProperty::~AccountServiceProviderProperty() {
-                       }
-
-                       std::string AccountServiceProviderProperty::getId() const{
-                               return m_id;
-                       }
-                       void AccountServiceProviderProperty::setId(const std::string &value){
-                               m_id = value;
-                       }
-
-                       std::string AccountServiceProviderProperty::getDisplayName() const{
-                               return m_displayName;
-                       }
-                       void AccountServiceProviderProperty::setDisplayName(const std::string &value){
-                               m_displayName = value;
-                       }
-
-                       std::string AccountServiceProviderProperty::getIconPath() const{
-                               return m_icon;
-                       }
-                       void AccountServiceProviderProperty::setIconPath(const std::string &value){
-                               m_icon = value;
-                       }
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
diff --git a/src/platform/API/Account/AccountServiceProviderProperty.h b/src/platform/API/Account/AccountServiceProviderProperty.h
deleted file mode 100755 (executable)
index 7a6fff6..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-
-
-/*
- * AccountServiceProviderProperty.h
- *
- *  Created on: 2012. 2. 1.
- *      Author: sangtai
- */
-
-#ifndef ACCOUNTSERVICEPROVIDERPROPERTY_H_
-#define ACCOUNTSERVICEPROVIDERPROPERTY_H_
-
-#include <string>
-#include <dpl/shared_ptr.h>
-#include <vector>
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-
-
-                       class AccountServiceProviderProperty {
-                               public:
-                                       AccountServiceProviderProperty();
-                                       virtual ~AccountServiceProviderProperty();
-
-                                       std::string getId() const;
-                                       void setId(const std::string &value);
-
-                                       std::string getDisplayName() const;
-                                       void setDisplayName(const std::string &value);
-
-                                       std::string getIconPath() const;
-                                       void setIconPath(const std::string &value);
-
-
-                               private:
-                                       std::string m_id;
-                                       std::string m_displayName;
-                                       std::string m_icon;
-                       };
-
-                       typedef DPL::SharedPtr<AccountServiceProviderProperty> AccountServiceProviderPropertyPtr;
-                       typedef std::vector<AccountServiceProviderPropertyPtr> AccountServiceProviderPropertyArray;
-                       typedef DPL::SharedPtr<AccountServiceProviderPropertyArray> AccountServiceProviderPropertyArrayPtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* ACCOUNTSERVICEPROVIDERPROPERTY_H_ */
diff --git a/src/platform/API/Account/AccountServiceTypeProperty.cpp b/src/platform/API/Account/AccountServiceTypeProperty.cpp
deleted file mode 100755 (executable)
index b3d1cce..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * AccountServiceTypeProperty.cpp
- *
- *  Created on: 2012. 1. 30.
- *      Author: sangtai
- */
-
-#include "AccountServiceTypeProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       AccountServiceTypeProperty::AccountServiceTypeProperty() {
-                       }
-
-                       AccountServiceTypeProperty::~AccountServiceTypeProperty() {
-                       }
-
-                       std::string AccountServiceTypeProperty::getId() const{
-                               return m_id;
-                       }
-                       void AccountServiceTypeProperty::setId(const std::string &value){
-                               m_id = value;
-                       }
-
-                       std::string AccountServiceTypeProperty::getDisplayName() const{
-                               return m_displayName;
-                       }
-                       void AccountServiceTypeProperty::setDisplayName(const std::string &value){
-                               m_displayName = value;
-                       }
-
-                       std::string AccountServiceTypeProperty::getIconPath() const{
-                               return m_icon;
-                       }
-                       void AccountServiceTypeProperty::setIconPath(const std::string &value){
-                               m_icon = value;
-                       }
-
-                       std::vector<std::string > AccountServiceTypeProperty::getTags() const{
-                               return m_tags;
-                       }
-                       void AccountServiceTypeProperty::setTags(const std::vector<std::string >& value){
-                               m_tags =value;
-                       }
-
-               } // namespace Account
-       }
-}
diff --git a/src/platform/API/Account/AccountServiceTypeProperty.h b/src/platform/API/Account/AccountServiceTypeProperty.h
deleted file mode 100755 (executable)
index 3892134..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * AccountServiceTypeProperty.h
- *
- *  Created on: 2012. 1. 30.
- *      Author: sangtai
- */
-
-#ifndef ACCOUNTSERVICETYPEPROPERTY_H_
-#define ACCOUNTSERVICETYPEPROPERTY_H_
-
-#include <string>
-#include <dpl/shared_ptr.h>
-#include <vector>
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class AccountServiceTypeProperty;
-
-                       typedef DPL::SharedPtr<AccountServiceTypeProperty> AccountServiceTypePropertyPtr;
-                       typedef std::vector<AccountServiceTypePropertyPtr> AccountServiceTypePropertyArray;
-                       typedef DPL::SharedPtr<AccountServiceTypePropertyArray> AccountServiceTypePropertyArrayPtr;
-
-                       class AccountServiceTypeProperty {
-                               public:
-                                       AccountServiceTypeProperty();
-                                       virtual ~AccountServiceTypeProperty();
-
-                                       std::string getId() const;
-                                       void setId(const std::string &value);
-
-                                       std::string getDisplayName() const;
-                                       void setDisplayName(const std::string &value);
-
-                                       std::string getIconPath() const;
-                                       void setIconPath(const std::string &value);
-
-                                       std::vector<std::string > getTags() const;
-                                       void setTags(const std::vector<std::string >& value);
-
-                               private :
-                                       std::string m_id;
-                                       std::string m_displayName;
-                                       std::string m_icon;
-
-                                       std::vector<std::string > m_tags;
-                       };
-               }               // namespace Account
-       }
-}
-
-#endif /* ACCOUNTSERVICETYPEPROPERTY_H_ */
diff --git a/src/platform/API/Account/AccountServices.cpp b/src/platform/API/Account/AccountServices.cpp
deleted file mode 100755 (executable)
index 1a15272..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        AccountServices.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief
- */
-
-#include "AccountServices.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       AccountServices::AccountServices() {
-                       }
-
-                       AccountServices::~AccountServices() {
-                       }
-
-                       std::string AccountServices::getId() const{
-                               return m_id;
-                       }
-                       void AccountServices::setId(const std::string &value){
-                                m_id = value;
-                       }
-
-                       std::string AccountServices::getName() const{
-                               return m_name;
-                       }
-                       void AccountServices::setName(const std::string &value){
-                               m_name = value;
-                       }
-
-                       std::string AccountServices::getApplicationId() const{
-                               return m_applicationId;
-                       }
-                       void AccountServices::setApplicationId(const std::string &value){
-                               m_applicationId = value;;
-                       }
-
-                       std::string AccountServices::getDisplayName() const{
-                               return m_displayName;
-                       }
-                       void AccountServices::setDisplayName(const std::string &value){
-                               m_displayName = value;
-                       }
-
-                       std::string AccountServices::getIcon() const{
-                               return m_icon;
-                       }
-                       void AccountServices::setIcon(const std::string &value){
-                               m_icon = value;
-                       }
-
-                       std::string AccountServices::getAccountId() const{
-                               return m_accountId;
-                       }
-                       void AccountServices::setAccountId(const std::string &value){
-                                m_accountId = value;
-                       }
-
-                       std::string AccountServices::getServiceTypeId() const{
-                               return m_serviceTypeId;
-                       }
-                       void AccountServices::setServiceTypeId(const std::string &value){
-                               m_serviceTypeId = value;
-                       }
-
-                       std::string AccountServices::getProviderId() const{
-                               return m_providerId;
-                       }
-                       void AccountServices::setProviderId(const std::string &value){
-                               m_providerId = value;
-                       }
-
-                       std::vector<std::string> AccountServices::getTags() const{
-                               return m_tags;
-                       }
-                       void AccountServices::setTags(const std::vector<std::string> &value){
-                               m_tags = value;
-                       }
-
-                       std::string AccountServices::getSettings() const{
-                               return m_setttings;
-                       }
-                       void AccountServices::setSettings(const std::string &value){
-                               m_setttings = value;
-                       }
-
-               } // Account
-       } // Api
-}
-
diff --git a/src/platform/API/Account/AccountServices.h b/src/platform/API/Account/AccountServices.h
deleted file mode 100755 (executable)
index 37465be..0000000
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        AccountServices.h
- * @author      Jihwa park(jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief
- */
-
-#ifndef _API_ACCOUNT_SERVICE_H_
-#define _API_ACCOUNT_SERVICE_H_
-
-#include <vector>
-#include <string>
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account {
-
-class AccountServices;
-typedef DPL::SharedPtr<AccountServices> AccountServicesPtr;
-typedef std::vector<AccountServicesPtr> AccountServicesArray;
-typedef DPL::SharedPtr<AccountServicesArray> AccountServicesArrayPtr;
-
-class AccountServices
-{
-public:
-       AccountServices();
-       ~AccountServices();
-
-       std::string getId() const;
-       void setId(const std::string &value);
-
-       std::string getName() const;
-       void setName(const std::string &value);
-
-       std::string getApplicationId() const;
-       void setApplicationId(const std::string &value);
-
-       std::string getDisplayName() const;
-       void setDisplayName(const std::string &value);
-
-       std::string getIcon() const;
-       void setIcon(const std::string &value);
-
-       std::string getAccountId() const;
-       void setAccountId(const std::string &value);
-
-       std::string getServiceTypeId() const;
-       void setServiceTypeId(const std::string &value);
-
-       std::string getProviderId() const;
-       void setProviderId(const std::string &value);
-
-       std::vector<std::string> getTags() const;
-       void setTags(const std::vector<std::string> &value);
-
-       std::string getSettings() const;
-       void setSettings(const std::string &value);
-
-private:
-       std::string m_id;
-       std::string m_name;
-       std::string m_applicationId;
-       std::string m_displayName;
-       std::string m_icon;
-       std::string m_accountId;
-       std::string m_serviceTypeId;
-       std::string m_providerId;
-       std::vector<std::string> m_tags;
-       std::string m_setttings;
-};
-
-} // Account
-} // Api
-} // TizenApis
-
-#endif // _API_ACCOUNT_SERVICE_H_
-
diff --git a/src/platform/API/Account/EventAccount.cpp b/src/platform/API/Account/EventAccount.cpp
deleted file mode 100755 (executable)
index 78bde02..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "EventAccount.h"
-#include <dpl/log/log.h>
-
-/**
- * @file        EventAccount.cpp
- *
- * @version     0.1
- */
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-EventAccount::EventAccount():
-             m_accountid(UNDEFINED_ACCOUNT_ID)
-{
-}
-
-EventAccount::~EventAccount()
-{
-}
-
-
-bool EventAccount::validate() const
-{
-//TODO: is this necessary?
-/*
-    if (m_status == INVALID_STATUS) {
-        LogError("Incorrect status value detected");
-        return false;
-    }*/
-    return true;
-}
-
-
-int EventAccount::getID() const
-{
-    LogDebug("entered");
-    return m_accountid;
-}
-
-void EventAccount::setID(const int &value)
-{
-    m_accountid = value;
-}
-
-std::string EventAccount::getAccountId() const
-{
-    LogDebug("entered");
-    return m_AccountId;
-}
-
-void EventAccount::setAccountId(const std::string &value)
-{
-    LogDebug("entered ");
-    m_AccountId = value;
-}
-
-std::string EventAccount::getDisplayName() const
-{
-    LogDebug("entered");
-    return m_displayname;
-}
-
-void EventAccount::setDisplayName(const std::string &value)
-{
-    LogDebug("entered");
-    m_displayname = value;
-}
-
-std::string EventAccount::getIconPath() const
-{
-    LogDebug("entered");
-    return m_iconPath;
-}
-
-void EventAccount::setIconPath(const std::string &value)
-{
-    LogDebug("entered");
-    m_iconPath = value;
-}
-
-std::string EventAccount::getProviderName() const
-{
-    LogDebug("entered");
-    return m_providername;
-}
-
-void EventAccount::setProviderName(const std::string &value)
-{
-    LogDebug("entered");
-    m_providername = value;
-}
-
-bool EventAccount::getEnabled() const
-{
-    LogDebug("entered");
-    return m_enabled;
-}
-
-void EventAccount::setEnabled(bool &value)
-{
-    LogDebug("entered");
-    m_enabled = value;
-}
-
-std::string EventAccount::getCredentailId() const
-{
-    LogDebug("entered");
-    return m_credentialId;
-}
-
-void EventAccount::setCredentailId(const std::string &value)
-{
-    LogDebug("entered");
-    m_credentialId = value;
-}
-
-std::string EventAccount::getSettings() const
-{
-    LogDebug("entered");
-    return m_settings;
-}
-
-void EventAccount::setSettings(const std::string &value)
-{
-    LogDebug("<<< value:[" << value << "]");
-    m_settings = value;
-}
-
-std::string EventAccount::getServiceTypeId() const
-{
-    LogDebug("entered");
-    return m_serviceTypeId;
-}
-
-void EventAccount::setServiceTypeId(const std::string &value)
-{
-    LogDebug("entered");
-    m_serviceTypeId = value;
-}
-
-std::string EventAccount::getProviderId() const
-{
-    LogDebug("entered");
-    return m_providerId;
-}
-
-void EventAccount::setProviderId(const std::string &value)
-{
-    LogDebug("entered");
-    m_providerId = value;
-}
-
-std::string EventAccount::getprefix() const
-{
-    LogDebug("entered");
-    return m_prefix;
-}
-
-void EventAccount::setprefix(const std::string &value)
-{
-    LogDebug("entered");
-    m_prefix = value;
-}
-
-std::string EventAccount::getUserName() const
-{
-    LogDebug("entered");
-    return m_username;
-}
-
-void EventAccount::setUserName(const std::string &value)
-{
-    LogDebug("entered");
-    m_username = value;
-}
-
-std::string EventAccount::getPackageName() const
-{
-    LogDebug("entered");
-    return m_packagename;
-}
-
-void EventAccount::setPackageName(const std::string &value)
-{
-    LogDebug("entered");
-    m_packagename = value;
-}
-
-std::string EventAccount::getEmailAddress() const
-{
-    LogDebug("entered");
-    return m_emailaddress;
-}
-
-void EventAccount::setEmailAddress(const std::string &value)
-{
-    LogDebug("entered");
-    m_emailaddress = value;
-}
-
-std::string EventAccount::getDomainName() const
-{
-    LogDebug("entered");
-    return m_domainname;
-}
-
-void EventAccount::setDomainName(const std::string &value)
-{
-    LogDebug("entered");
-    m_domainname = value;
-}
-
-AccountServicesArrayPtr EventAccount::getService() const
-{
-    LogDebug("<<<");
-    return m_service;
-}
-
-void EventAccount::setService(const AccountServicesArrayPtr &value)
-{
-    LogDebug("entered");
-       m_service = value;
-}
-
-}
-}
-}
diff --git a/src/platform/API/Account/EventAccount.h b/src/platform/API/Account/EventAccount.h
deleted file mode 100755 (executable)
index f6369c5..0000000
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        EventAccount.h
- *
- * @version     0.1
- */
-
-#ifndef _ABSTRACT_LAYER_EVENT_ATTENDEE_H_
-#define _ABSTRACT_LAYER_EVENT_ATTENDEE_H_
-
-#include <string>
-#include <vector>
-#include <dpl/shared_ptr.h>
-#include "AccountServices.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-typedef std::vector<std::string> FeatureList;
-typedef DPL::SharedPtr<FeatureList> FeatureListPtr;
-
-class EventAccount
-{
-  public:
-
-       static const int UNDEFINED_ACCOUNT_ID = -1;
-       EventAccount();
-       virtual ~EventAccount();
-
-       bool validate() const;
-
-       int getID() const;
-       void setID(const int &value);
-
-       std::string getAccountId() const;
-       void setAccountId(const std::string &value);
-
-       std::string getDisplayName() const;
-       void setDisplayName(const std::string &value);
-
-       std::string getIconPath() const;
-       void setIconPath(const std::string &value);
-
-       std::string getProviderName() const;
-       void setProviderName(const std::string &value);
-
-       bool getEnabled() const;
-       void setEnabled(bool &value);
-
-       std::string getCredentailId() const;
-       void setCredentailId(const std::string &value);
-
-       std::string getSettings() const;
-       void setSettings(const std::string &value);
-
-       std::string getServiceTypeId() const;
-       void setServiceTypeId(const std::string &value);
-
-       std::string getProviderId() const;
-       void setProviderId(const std::string &value);
-
-       std::string getprefix() const;
-       void setprefix(const std::string &value);
-
-       std::string getUserName() const;
-       void setUserName(const std::string &value);
-
-       std::string getPackageName() const;
-       void setPackageName(const std::string &value);
-
-       std::string getEmailAddress() const;
-       void setEmailAddress(const std::string &value);
-
-       std::string getDomainName() const;
-       void setDomainName(const std::string &value);
-
-       AccountServicesArrayPtr getService() const;
-       void setService(const AccountServicesArrayPtr &value);
-
-  protected:
-       int m_accountid;
-       std::string m_AccountId;
-       std::string m_displayname;
-       std::string m_iconPath;
-       std::string m_providername;
-       bool m_enabled;
-       std::string m_credentialId;
-       std::string m_settings;
-
-       std::string m_serviceTypeId;
-       std::string m_providerId;
-       std::string m_prefix;
-
-       std::string m_username;
-       std::string m_packagename;
-       std::string m_emailaddress;
-       std::string m_domainname;
-
-       AccountServicesArrayPtr                         m_service;
-
-};
-
-typedef DPL::SharedPtr<EventAccount> EventAccountPtr;
-typedef std::vector<EventAccountPtr> EventAccountList;
-typedef DPL::SharedPtr<EventAccountList> EventAccountListPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_EVENT_ATTENDEE_H_ */
diff --git a/src/platform/API/Account/IAccountManager.cpp b/src/platform/API/Account/IAccountManager.cpp
deleted file mode 100755 (executable)
index 85df38b..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        IAccountManager.cpp
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-#include "IAccountManager.h"
-#include <Commons/ThreadPool.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-IAccountManager::IAccountManager() :
-//    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountServices >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceTypeById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetProviderById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindProviders>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-         WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServiceTypes>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-         WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServices>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-         WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceByName>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-         WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceById>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD)
-{
-    LogDebug("entered");
-}
-
-IAccountManager::~IAccountManager()
-{
-    LogDebug("entered");
-}
-
-
-//void IAccountManager::getAccountServices(const IEventGetAccountServicesPtr &event)
-//{
-//    LogDebug("entered");
-//    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountServices>::PostRequest(event);
-//}
-
-void IAccountManager::addAccount(const IEventAddAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>::PostRequest(event);
-}
-
-void IAccountManager::deleteAccount(const IEventDeleteAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>::PostRequest(event);
-}
-
-void IAccountManager::findAccounts(const IEventFindAccountsPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>::PostRequest(event);
-}
-
-void IAccountManager::findServices(const IEventFindServicesPtr &event) {
-       LogDebug("<<<");
-       WrtDeviceApis::Commons::EventRequestReceiver<IEventFindServices>::PostRequest(event);
-}
-
-void IAccountManager::findServiceTypes(const IEventFindServiceTypesPtr &event){
-       LogDebug("<<<");
-       WrtDeviceApis::Commons::EventRequestReceiver<IEventFindServiceTypes>::PostRequest(event);
-}
-
-
-void IAccountManager::updateAccount(const IEventUpdateAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>::PostRequest(event);
-}
-
-void IAccountManager::getAccountById(const IEventGetAccountByIdPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountById>::PostRequest(event);
-}
-
-void IAccountManager::getServiceTypeById(const IEventGetServiceTypeByIdPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceTypeById>::PostRequest(event);
-}
-
-void IAccountManager::getServiceByName(const IEventGetServiceByNamePtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceByName>::PostRequest(event);
-}
-
-void IAccountManager::getServiceById(const IEventGetServiceByIdPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetServiceById>::PostRequest(event);
-}
-
-void IAccountManager::getProviderById(const IEventGetProviderByIdPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetProviderById>::PostRequest(event);
-}
-
-void IAccountManager::FindProviders(const IEventFindProvidersPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindProviders>::PostRequest(event);
-}
-
-}
-}
-}
diff --git a/src/platform/API/Account/IAccountManager.h b/src/platform/API/Account/IAccountManager.h
deleted file mode 100755 (executable)
index c9f7cf2..0000000
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        IAccountManager.h
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-#ifndef _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_
-#define _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_
-
-#include "IAccountService.h"
-#include "IEventGetAccountServices.h"
-#include "IEventFindServiceTypes.h"
-#include "IEventFindServices.h"
-#include "IEventGetServiceByName.h"
-#include "IEventGetServiceById.h"
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-class IAccountManager :
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount > ,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindAccounts >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateAccount >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountById >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceTypeById >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProviderById >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindProviders >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServiceTypes >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServices >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceByName >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceById >
-{
-  public:
-       IAccountManager();
-
-       virtual ~IAccountManager();
-
-//     virtual void getAccountServices(const IEventGetAccountServicesPtr &event);
-
-       virtual void addAccount(const IEventAddAccountPtr &event);
-
-       virtual void deleteAccount(const IEventDeleteAccountPtr &event);
-
-       virtual void findAccounts(const IEventFindAccountsPtr &event);
-
-       virtual void findServices(const IEventFindServicesPtr &event);
-
-       virtual void findServiceTypes(const IEventFindServiceTypesPtr &event);
-
-       virtual void updateAccount(const IEventUpdateAccountPtr &event);
-
-       virtual void getAccountById(const IEventGetAccountByIdPtr &event);
-
-       virtual void getServiceTypeById(const IEventGetServiceTypeByIdPtr &event);
-
-       virtual void getServiceByName(const IEventGetServiceByNamePtr &event);
-       virtual void getServiceById(const IEventGetServiceByIdPtr &event);
-
-       virtual void getProviderById(const IEventGetProviderByIdPtr &event);
-
-       virtual void FindProviders(const IEventFindProvidersPtr &event);
-
-
-  protected:
-//     virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventAddAccountPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventDeleteAccountPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventFindAccountsPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventUpdateAccountPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventGetAccountByIdPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventGetServiceTypeByIdPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventGetProviderByIdPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventFindProvidersPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventFindServiceTypesPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventFindServicesPtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventGetServiceByNamePtr &event) = 0;
-
-       virtual void OnRequestReceived(const IEventGetServiceByIdPtr &event) = 0;
-
-};
-
-typedef DPL::SharedPtr<IAccountManager> IAccountManagerPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_IACCOUNT_MANAGER_H_ */
diff --git a/src/platform/API/Account/IAccountService.cpp b/src/platform/API/Account/IAccountService.cpp
deleted file mode 100755 (executable)
index e953d60..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/**
- * @file        IAccount.cpp
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-#include "IAccountService.h"
-#include <Commons/ThreadPool.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-IAccountService::IAccountService() :
-   
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
-    m_id(0),
-    m_type(TYPE_INTERNET)
-{
-}
-
-IAccountService::~IAccountService()
-{
-}
-
-void IAccountService::createAccount(IEventCreateAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateAccount>::PostRequest(event);
-}
-
-void IAccountService::addAccount(IEventAddAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventAddAccount>::PostRequest(event);
-}
-
-
-void IAccountService::updateAccount(IEventUpdateAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateAccount>::PostRequest(event);
-}
-
-void IAccountService::deleteAccount(IEventDeleteAccountPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventDeleteAccount>::PostRequest(event);
-}
-
-void IAccountService::findAccounts(IEventFindAccountsPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindAccounts>::PostRequest(event);
-}
-
-
-}
-}
-}
diff --git a/src/platform/API/Account/IAccountService.h b/src/platform/API/Account/IAccountService.h
deleted file mode 100755 (executable)
index 1c0afc5..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        IAccount.h
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-#ifndef _ABSTRACT_LAYER_IACCOUNT_H_
-#define _ABSTRACT_LAYER_IACCOUNT_H_
-
-#include <string>
-#include <dpl/log/log.h>
-#include <dpl/shared_ptr.h>
-//#include "CalendarEvent.h"
-//#include "EventFilter.h"
-#include "IEventCreateAccount.h"
-#include "IEventAddAccount.h"
-#include "IEventDeleteAccount.h"
-#include "IEventFindAccounts.h"
-#include "IEventUpdateAccount.h"
-#include "IEventGetAccountById.h"
-#include "IEventGetServiceTypeById.h"
-#include "IEventGetProviderById.h"
-#include "IEventFindProviders.h"
-
-#include "OnAddEventsChanged.h"
-#include "OnUpdateEventsChanged.h"
-#include "OnDeleteEventsChanged.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IAccountService :
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateAccount >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindAccounts >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventCreateAccount >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount >
-{
-  public:
-
-    typedef enum
-    {
-        TYPE_NONE,
-     //   TYPE_SIM,
-     //   TYPE_TOKEN,
-     //   TYPE_HW,
-        TYPE_INTERNET
-     //   TYPE_LOCAL,
-     //   TYPE_OTHER
-    } AccountType;
-
-    IAccountService();
-    virtual ~IAccountService();
-    virtual void                createAccount(IEventCreateAccountPtr &event);
-    virtual void                addAccount(IEventAddAccountPtr &event);
-    virtual void                updateAccount(IEventUpdateAccountPtr &event);
-    virtual void                deleteAccount(IEventDeleteAccountPtr &event);
-    virtual void                findAccounts(IEventFindAccountsPtr &event);
-
-
-    virtual std::string         getName() const
-    {
-        return m_name;
-    }
-    virtual void                setName(const std::string &value)
-    {
-        m_name = value;
-    }
-    virtual AccountType        getType() const
-    {
-        return m_type;
-    }
-    virtual void                setType(const AccountType value)
-    {
-        m_type = value;
-    }
-    virtual int                 getId() const
-    {
-        return m_id;
-    }
-    virtual void                setId(const int value)
-    {
-        m_id = value;
-    }
-
-   //TODO: check the meaning of emitters as below.
-    virtual OnAddEventsChangedEmitterPtr getAddEmitter() const
-    {
-        return m_addEmitter;
-    }
-    virtual void                setAddEmitter(OnAddEventsChangedEmitterPtr value)
-    {
-        m_addEmitter = value;
-    }
-    virtual OnUpdateEventsChangedEmitterPtr getUpdateEmitter() const
-    {
-        return m_updateEmitter;
-    }
-    virtual void                setUpdateEmitter(OnUpdateEventsChangedEmitterPtr value)
-    {
-        m_updateEmitter = value;
-    }
-        virtual OnDeleteEventsChangedEmitterPtr getDeleteEmitter() const
-    {
-        return m_deleteEmitter;
-    }
-    virtual void                setDeleteEmitter(OnDeleteEventsChangedEmitterPtr value)
-    {
-        m_deleteEmitter = value;
-    }
-  protected:
-    int m_id;
-    std::string m_name;
-    AccountType m_type;
-    OnAddEventsChangedEmitterPtr m_addEmitter;
-    OnUpdateEventsChangedEmitterPtr m_updateEmitter;
-    OnDeleteEventsChangedEmitterPtr m_deleteEmitter;
-
-    virtual void OnRequestReceived(const IEventDeleteAccountPtr &event) = 0;
-    virtual void OnRequestReceived(const IEventUpdateAccountPtr &event) = 0;
-    virtual void OnRequestReceived(const IEventFindAccountsPtr &event) = 0;
-    virtual void OnRequestReceived(const IEventCreateAccountPtr &event) = 0;
-    virtual void OnRequestReceived(const IEventAddAccountPtr &event) = 0;
-};
-
-typedef DPL::SharedPtr<IAccountService> IAccountServicePtr;
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_IACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventAddAccount.h b/src/platform/API/Account/IEventAddAccount.h
deleted file mode 100755 (executable)
index ced1b11..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_
-#define _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventAddAccount : public WrtDeviceApis::Commons::IEvent<IEventAddAccount>
-{
-    EventAccountPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(EventAccountPtr value)
-    {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const
-    {
-        return m_event;
-    }
-    IEventAddAccount() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventAddAccount()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventAddAccount> IEventAddAccountPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_ADD_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventCreateAccount.h b/src/platform/API/Account/IEventCreateAccount.h
deleted file mode 100755 (executable)
index cd1bae1..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_
-#define _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventCreateAccount : public WrtDeviceApis::Commons::IEvent<IEventCreateAccount>
-{
-    EventAccountPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(EventAccountPtr value)
-    {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const
-    {
-        return m_event;
-    }
-    IEventCreateAccount() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventCreateAccount()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventCreateAccount> IEventCreateAccountPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_CREATE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventDeleteAccount.h b/src/platform/API/Account/IEventDeleteAccount.h
deleted file mode 100755 (executable)
index 73f159f..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_
-#define _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventDeleteAccount : public WrtDeviceApis::Commons::IEvent<IEventDeleteAccount>
-{
-    EventAccountPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(EventAccountPtr value)
-    {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const
-    {
-        return m_event;
-    }
-    IEventDeleteAccount() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventDeleteAccount()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventDeleteAccount> IEventDeleteAccountPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_DELETE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/IEventFindAccounts.h b/src/platform/API/Account/IEventFindAccounts.h
deleted file mode 100755 (executable)
index 6c4241a..0000000
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_
-#define _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-
-#include <dpl/shared_ptr.h>
-
-#include "AccountServiceFilterProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-                       class IEventFindAccounts: public WrtDeviceApis::Commons::IEvent<IEventFindAccounts> {
-
-                               private:
-                               /* user is responsible to free objects inside list */
-                                       std::vector<EventAccountPtr> m_events;
-                                       bool m_result;
-                                       AccountServiceFilterPropertyPtr m_filter;
-
-                                       int m_firstEvent;
-                                       int m_lastEvent;
-
-                                       EventAccountListPtr m_accountList;
-                                       bool m_enable;
-
-                               public:
-
-                                       void setFilterProperty(AccountServiceFilterPropertyPtr value) {
-                                               m_filter = value;
-                                       }
-                                       AccountServiceFilterPropertyPtr getFilterProperty() const {
-                                               return m_filter;
-                                       }
-
-                                       void setAccountLists(EventAccountListPtr value){
-                                               m_accountList = value;
-                                       }
-                                       EventAccountListPtr getAccountLists(){
-                                               return m_accountList;
-                                       }
-
-                                       void setFirstEvent(int value) {
-                                               m_firstEvent = value;
-                                       }
-                                       int getFirstEvent() const {
-                                               return m_firstEvent;
-                                       }
-
-                                       void setLastEvent(int value) {
-                                               m_lastEvent = value;
-                                       }
-                                       int getLastEvent() const {
-                                               return m_lastEvent;
-                                       }
-
-                                       void setResult(bool value) {
-                                               m_result = value;
-                                       }
-                                       bool getResult() const {
-                                               return m_result;
-                                       }
-
-                                       void addEvent(EventAccountPtr value) {
-                                               m_events.push_back(value);
-                                       }
-                                       std::vector<EventAccountPtr> getEvents() {
-                                               return m_events;
-                                       }
-
-                                       void setEnable(bool value){
-                                               m_enable = value;
-                                       }
-                                       bool getEnable(){
-                                               return m_enable;
-                                       }
-
-                                       IEventFindAccounts() :
-                                                       m_result(false), m_firstEvent(0), m_lastEvent(-1) {
-                                       }
-                                       ~IEventFindAccounts() {
-                                       }
-                                       virtual void clearOnCancel() {
-                                       }
-                       };
-
-                       typedef DPL::SharedPtr<IEventFindAccounts> IEventFindAccountsPtr;
-               }
-       }
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_FIND_ACCOUNTS_H_ */
diff --git a/src/platform/API/Account/IEventFindProviders.h b/src/platform/API/Account/IEventFindProviders.h
deleted file mode 100644 (file)
index 40b35ea..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/* IEventFindProviders.h
- *
- *  Created on: 2012. 2. 1.
- *      Author: sangtai
- */
-
-#ifndef IEVENTFINDPROVIDERS_H_
-#define IEVENTFINDPROVIDERS_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class IEventFindProviders: public WrtDeviceApis::Commons::IEvent<IEventFindProviders> {
-                               public:
-                                       IEventFindProviders() : m_serviceTypeId(""), m_result(false){
-                                       }
-                                       virtual ~IEventFindProviders(){
-                                       }
-
-                                       void setServiceTypeId(const std::string& value){
-                                               m_serviceTypeId = value;
-                                       }
-                                       std::string getServiceTypeId(){
-                                               return m_serviceTypeId;
-                                       }
-
-                                       void setResult(bool value){
-                                               m_result = value;
-                                       }
-
-                                       bool getResult(){
-                                               return m_result;
-                                       }
-
-                                       AccountServiceProviderPropertyArrayPtr getAccountServiceProviderProperties(){
-                                               return m_accountServiceProviderProperties;
-                                       }
-                                       void setServiceProviderProperties(const AccountServiceProviderPropertyArrayPtr &value){
-                                               m_accountServiceProviderProperties = value;
-                                       }
-
-                                       virtual void clearOnCancel() {
-                                       }
-
-                               private:
-                                       std::string m_serviceTypeId;
-                                       bool m_result;
-
-                                       AccountServiceProviderPropertyArrayPtr m_accountServiceProviderProperties;
-                       };
-
-                       typedef DPL::SharedPtr<IEventFindProviders> IEventFindProvidersPtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* IEVENTFINDPROVIDERS_H_ */
diff --git a/src/platform/API/Account/IEventFindServiceTypes.h b/src/platform/API/Account/IEventFindServiceTypes.h
deleted file mode 100755 (executable)
index bd3b991..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * IEventFindServiceTypes.h
- *
- *  Created on: 2012. 1. 30.
- *      Author: sangtai
- */
-
-#ifndef IEVENTFINDSERVICETYPES_H_
-#define IEVENTFINDSERVICETYPES_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-
-#include "AccountServiceTypeProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class IEventFindServiceTypes : public WrtDeviceApis::Commons::IEvent<IEventFindServiceTypes>{
-                               public:
-                                       IEventFindServiceTypes(): m_prefix(""), m_result(false){
-                                       }
-                                       virtual ~IEventFindServiceTypes(){
-                                       }
-
-                                       void setPrefix(const std::string& value){
-                                               m_prefix = value;
-                                       }
-                                       std::string getPrefix(){
-                                               return m_prefix;
-                                       }
-
-                                       void setResult(bool value){
-                                               m_result = value;
-                                       }
-
-                                       bool getResult(){
-                                               return m_result;
-                                       }
-
-                                       AccountServiceTypePropertyArrayPtr getAccountServiceTypeProperties(){
-                                               return m_accountServiceTypeProperties;
-                                       }
-                                       void setServiceTypeProperties(const AccountServiceTypePropertyArrayPtr &value){
-                                               m_accountServiceTypeProperties = value;
-                                       }
-
-                                       virtual void clearOnCancel() {
-                                       }
-
-                               private:
-                                       std::string m_prefix;
-                                       bool m_result;
-
-                                       AccountServiceTypePropertyArrayPtr m_accountServiceTypeProperties;
-                       };
-
-                       typedef DPL::SharedPtr<IEventFindServiceTypes> IEventFindServiceTypesPtr;
-               }       // namespace Account
-       }
-}
-
-#endif /* IEVENTFINDSERVICETYPES_H_ */
diff --git a/src/platform/API/Account/IEventFindServices.h b/src/platform/API/Account/IEventFindServices.h
deleted file mode 100644 (file)
index d38faaf..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * @author      Sangtai Kim (sangtai.kim@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef IEVENTFINDSERVICES_H_
-#define IEVENTFINDSERVICES_H_
-
-#include <Commons/IEvent.h>
-
-#include <dpl/shared_ptr.h>
-
-#include "AccountServiceFilterProperty.h"
-
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class IEventFindServices : public WrtDeviceApis::Commons::IEvent<IEventFindServices>{
-                               private:
-                                       bool m_result;
-                                       bool m_enable;
-
-                                       AccountServiceFilterPropertyPtr  m_filter;
-                                       AccountServicesArrayPtr          m_serviceList;
-
-                               public:
-                                       void setFilterProperty(AccountServiceFilterPropertyPtr value) {
-                                               m_filter = value;
-                                       }
-                                       AccountServiceFilterPropertyPtr getFilterProperty() const {
-                                               return m_filter;
-                                       }
-
-                                       void setAccountServiceList(AccountServicesArrayPtr value){
-                                               m_serviceList = value;
-                                       }
-                                       AccountServicesArrayPtr getAccountServiceList(){
-                                               return m_serviceList;
-                                       }
-
-                                       void setResult(bool value) {
-                                               m_result = value;
-                                       }
-                                       bool getResult() const {
-                                               return m_result;
-                                       }
-
-                                       void setEnable(bool value){
-                                               m_enable = value;
-                                       }
-                                       bool getEnable(){
-                                               return m_enable;
-                                       }
-
-                                       IEventFindServices() : m_result(false){
-                                       }
-                                       virtual ~IEventFindServices(){
-                                       }
-                       };
-
-                       typedef DPL::SharedPtr<IEventFindServices> IEventFindServicesPtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* IEVENTFINDSERVICES_H_ */
diff --git a/src/platform/API/Account/IEventGetAccountById.h b/src/platform/API/Account/IEventGetAccountById.h
deleted file mode 100755 (executable)
index fd41c00..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_
-#define _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventGetAccountById : public WrtDeviceApis::Commons::IEvent<IEventGetAccountById>
-{
-    EventAccountPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(EventAccountPtr value)
-    {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const
-    {
-        return m_event;
-    }
-    IEventGetAccountById() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventGetAccountById()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventGetAccountById> IEventGetAccountByIdPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_BY_ID_H_ */
diff --git a/src/platform/API/Account/IEventGetAccountServices.h b/src/platform/API/Account/IEventGetAccountServices.h
deleted file mode 100755 (executable)
index 27ea7dc..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_
-#define _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include "IAccountService.h"
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventGetAccountServices : public WrtDeviceApis::Commons::IEvent<
-        IEventGetAccountServices>
-{
-    std::vector<IAccountServicePtr>     m_accountservices;
-    bool m_result;
-  public:
-    void                        setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool                        getResult() const
-    {
-        return m_result;
-    }
-       //TODO: need to confirm this.
-    void                        addAccountService(IAccountServicePtr value)
-    {
-        m_accountservices.push_back(value);
-    }
-       //TODO: need to confirm this.
-    std::vector<IAccountServicePtr>     getAccountServices() const
-    {
-        return m_accountservices;
-    }
-    IEventGetAccountServices() : m_result(false)
-    {
-    }
-    ~IEventGetAccountServices()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventGetAccountServices> IEventGetAccountServicesPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_GET_ACCOUNT_SERVICE_H_ */
diff --git a/src/platform/API/Account/IEventGetProviderById.h b/src/platform/API/Account/IEventGetProviderById.h
deleted file mode 100755 (executable)
index 1bce836..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_
-#define _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-
-#include "AccountServiceProviderProperty.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventGetProviderById : public WrtDeviceApis::Commons::IEvent<IEventGetProviderById>
-{
-       EventAccountPtr m_event;
-               bool m_result;
-
-       private :
-               AccountServiceProviderPropertyPtr m_accountServiceProviderPropertyPtr;
-
-       public:
-               void setResult(bool value) {
-                       m_result = value;
-               }
-
-               bool getResult() const {
-                       return m_result;
-               }
-
-               void setEvent(EventAccountPtr value) {
-                       m_event = value;
-               }
-
-               EventAccountPtr getEvent() const {
-                       return m_event;
-               }
-
-               void setAccountServiceProviderProperty(AccountServiceProviderPropertyPtr value){
-                       m_accountServiceProviderPropertyPtr = value;
-               }
-
-               AccountServiceProviderPropertyPtr getAccountServiceProviderProperty(){
-                       return m_accountServiceProviderPropertyPtr;
-               }
-
-               IEventGetProviderById() :
-                               m_event(NULL), m_result(false) {
-               }
-
-               ~IEventGetProviderById() {
-               }
-
-               virtual void clearOnCancel() {
-               }
-};
-
-typedef DPL::SharedPtr<IEventGetProviderById> IEventGetProviderByIdPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_GET_PROVIDER_BY_ID_H_ */
-
diff --git a/src/platform/API/Account/IEventGetServiceById.h b/src/platform/API/Account/IEventGetServiceById.h
deleted file mode 100644 (file)
index 6fee772..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * IEventGetServiceById.h
- *
- *  Created on: 2012. 2. 6.
- *      Author: sangtai
- */
-
-#ifndef IEVENTGETSERVICEBYID_H_
-#define IEVENTGETSERVICEBYID_H_
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class IEventGetServiceById : public WrtDeviceApis::Commons::IEvent<IEventGetServiceById>{
-                               public:
-                                       IEventGetServiceById(){
-                                       }
-                                       virtual ~IEventGetServiceById(){
-                                       }
-
-                                       AccountServicesPtr getAccountService(){
-                                               return m_accountService;
-                                       }
-                                       void setAccountService(AccountServicesPtr value){
-                                               m_accountService = value;
-                                       }
-
-                                       std::string getServiceId(){
-                                               return m_serviceId;
-                                       }
-                                       void setServiceId(std::string value){
-                                               m_serviceId = value;
-                                       }
-
-                                       void setResult(bool value){
-                                               m_result = value;
-                                       }
-                                       bool getResult(){
-                                               return m_result;
-                                       }
-
-                               private :
-                                       bool m_result;
-                                       AccountServicesPtr m_accountService;
-                                       std::string m_serviceId;
-                       };
-
-                       typedef DPL::SharedPtr<IEventGetServiceById> IEventGetServiceByIdPtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* IEVENTGETSERVICEBYID_H_ */
diff --git a/src/platform/API/Account/IEventGetServiceByName.h b/src/platform/API/Account/IEventGetServiceByName.h
deleted file mode 100644 (file)
index d2b4ea7..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * IEventGetServiceByName.h
- *
- *  Created on: 2012. 2. 6.
- *      Author: sangtai
- */
-
-#ifndef IEVENTGETSERVICEBYNAME_H_
-#define IEVENTGETSERVICEBYNAME_H_
-
-#include <Commons/IEvent.h>
-
-#include <dpl/shared_ptr.h>
-
-#include "AccountServices.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-
-                       class IEventGetServiceByName : public WrtDeviceApis::Commons::IEvent<IEventGetServiceByName> {
-                               public:
-                                       IEventGetServiceByName(){
-                                       }
-                                       virtual ~IEventGetServiceByName(){
-                                       }
-
-                               public:
-                                       AccountServicesPtr getAccountService(){
-                                               return m_accountService;
-                                       }
-                                       void setAccountService(AccountServicesPtr value){
-                                               m_accountService = value;
-                                       }
-
-                                       std::string getServiceName(){
-                                               return m_serviceName;
-                                       }
-                                       void setServiceName(std::string value){
-                                               m_serviceName = value;
-                                       }
-
-                                       void setResult(bool value){
-                                               m_result = value;
-                                       }
-                                       bool getResult(){
-                                               return m_result;
-                                       }
-
-                               private :
-                                       bool m_result;
-                                       AccountServicesPtr m_accountService;
-                                       std::string m_serviceName;
-                       };
-
-                       typedef DPL::SharedPtr<IEventGetServiceByName> IEventGetServiceByNamePtr;
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace TizenApis */
-#endif /* IEVENTGETSERVICEBYNAME_H_ */
diff --git a/src/platform/API/Account/IEventGetServiceTypeById.h b/src/platform/API/Account/IEventGetServiceTypeById.h
deleted file mode 100755 (executable)
index 517839e..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * @author      jihwa park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_
-#define _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-#include "AccountServiceTypeProperty.h"
-
-namespace TizenApis {
-       namespace Api {
-               namespace Account {
-                       class IEventGetServiceTypeById: public WrtDeviceApis::Commons::IEvent<IEventGetServiceTypeById> {
-                                       EventAccountPtr m_event;
-
-                                       AccountServiceTypePropertyPtr m_accountServiceTypePropertyPtr;
-
-                                       bool m_result;
-                               public:
-                                       void setResult(bool value) {
-                                               m_result = value;
-                                       }
-                                       bool getResult() const {
-                                               return m_result;
-                                       }
-                                       void setEvent(EventAccountPtr value) {
-                                               m_event = value;
-                                       }
-                                       EventAccountPtr getEvent() const {
-                                               return m_event;
-                                       }
-
-                                       AccountServiceTypePropertyPtr getAccountServiceTypeProperty(){
-                                               return m_accountServiceTypePropertyPtr;
-                                       }
-
-                                       void setAccountServiceTypeProperty(AccountServiceTypePropertyPtr value){
-                                               m_accountServiceTypePropertyPtr = value;
-                                       }
-
-                                       IEventGetServiceTypeById() :
-                                                       m_event(NULL), m_result(false) {
-                                       }
-                                       ~IEventGetServiceTypeById() {
-                                       }
-                                       virtual void clearOnCancel() {
-                                       }
-                       };
-
-                       typedef DPL::SharedPtr<IEventGetServiceTypeById> IEventGetServiceTypeByIdPtr;
-               }
-       }
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_GET_SERVICETYPE_BY_ID_H_ */
diff --git a/src/platform/API/Account/IEventUpdateAccount.h b/src/platform/API/Account/IEventUpdateAccount.h
deleted file mode 100755 (executable)
index bea4285..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_
-#define _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_
-
-#include <Commons/IEvent.h>
-#include "EventAccount.h"
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventUpdateAccount : public WrtDeviceApis::Commons::IEvent<IEventUpdateAccount>
-{
-    EventAccountPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(EventAccountPtr value)
-    {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const
-    {
-        return m_event;
-    }
-
-    IEventUpdateAccount() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventUpdateAccount()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventUpdateAccount> IEventUpdateAccountPtr;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_UPDATE_ACCOUNT_H_ */
diff --git a/src/platform/API/Account/OnAddEventsChanged.h b/src/platform/API/Account/OnAddEventsChanged.h
deleted file mode 100755 (executable)
index e012dfa..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file          OnAddEventsChanged.h
- * @author
- * @version     0.1
- * @brief  
- */
-
-#ifndef _ON_ADD_EVENTS_CHANGED_H_
-#define _ON_ADD_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-class OnAddEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnAddEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_ADD_SUCCESS,
-               EVENT_ADD_FAIL
-    } EventAddStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEvent(EventAccountPtr value) {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const {
-        return m_event;
-    }
-
-    void setStatus(EventAddStatus value) {
-        m_status = value;
-    }
-    EventAddStatus getStatus() const {
-        return m_status;
-    }
-
-    OnAddEventsChanged() : m_result(false) {
-    }
-    ~OnAddEventsChanged() {
-    }
-
-    private:
-    EventAccountPtr m_event;
-    EventAddStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnAddEventsChanged> OnAddEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnAddEventsChanged> OnAddEventsChangedEmitter;
-typedef DPL::SharedPtr<OnAddEventsChangedEmitter> OnAddEventsChangedEmitterPtr;
-
-} // Api
-} // WrtPlugins
-}
-
-#endif //_ON_ADD_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/OnDeleteEventsChanged.h b/src/platform/API/Account/OnDeleteEventsChanged.h
deleted file mode 100755 (executable)
index 18bee40..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file          OnDeleteEventsChanged.h
- * @author
- * @version     0.1
- * @brief  
- */
-
-#ifndef _ON_DELETE_EVENTS_CHANGED_H_
-#define _ON_DELETE_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-class OnDeleteEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnDeleteEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_DELETE_SUCCESS,
-               EVENT_DELETE_FAIL
-    } EventDeleteStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEvent(EventAccountPtr value) {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const {
-        return m_event;
-    }
-
-    void setStatus(EventDeleteStatus value) {
-        m_status = value;
-    }
-    EventDeleteStatus getStatus() const {
-        return m_status;
-    }
-
-    OnDeleteEventsChanged() : m_result(false) {
-    }
-    ~OnDeleteEventsChanged() {
-    }
-
-    private:
-    EventAccountPtr m_event;
-    EventDeleteStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnDeleteEventsChanged> OnDeleteEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnDeleteEventsChanged> OnDeleteEventsChangedEmitter;
-typedef DPL::SharedPtr<OnDeleteEventsChangedEmitter> OnDeleteEventsChangedEmitterPtr;
-
-} // Api
-} // WrtPlugins
-}
-
-#endif //_ON_DELETE_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/OnUpdateEventsChanged.h b/src/platform/API/Account/OnUpdateEventsChanged.h
deleted file mode 100755 (executable)
index ab47daf..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file          OnUpdateEventsChanged.h
- * @author
- * @version     0.1
- * @brief  
- */
-
-#ifndef _ON_UPDATE_EVENTS_CHANGED_H_
-#define _ON_UPDATE_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-
-
-namespace TizenApis {
-namespace Api {
-namespace Account{
-
-class OnUpdateEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnUpdateEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_UPDATE_SUCCESS,
-               EVENT_UPDATE_FAIL
-    } EventUpdateStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEvent(EventAccountPtr value) {
-        m_event = value;
-    }
-    EventAccountPtr getEvent() const {
-        return m_event;
-    }
-
-    void setStatus(EventUpdateStatus value) {
-        m_status = value;
-    }
-    EventUpdateStatus getStatus() const {
-        return m_status;
-    }
-
-    OnUpdateEventsChanged() : m_result(false) {
-    }
-    ~OnUpdateEventsChanged() {
-    }
-
-    private:
-    EventAccountPtr m_event;
-    EventUpdateStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnUpdateEventsChanged> OnUpdateEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnUpdateEventsChanged> OnUpdateEventsChangedEmitter;
-typedef DPL::SharedPtr<OnUpdateEventsChangedEmitter> OnUpdateEventsChangedEmitterPtr;
-
-} // Api
-} // WrtPlugins
-}
-
-#endif //_ON_UPDATE_EVENTS_CHANGED_H_
\ No newline at end of file
diff --git a/src/platform/API/Account/config.cmake b/src/platform/API/Account/config.cmake
deleted file mode 100755 (executable)
index 5bbc2e5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-get_current_path()
-set(SRCS_PLATFORM_API_ACCOUNT
-  ${CURRENT_PATH}/IAccountService.cpp
-  ${CURRENT_PATH}/IAccountManager.cpp
-  ${CURRENT_PATH}/AccountFactory.cpp
-  ${CURRENT_PATH}/EventAccount.cpp
-  ${CURRENT_PATH}/AccountFilter.cpp
-  ${CURRENT_PATH}/AccountServices.cpp
-  ${CURRENT_PATH}/AccountServiceTypeProperty.cpp
-  ${CURRENT_PATH}/AccountServiceProviderProperty.cpp
-  ${CURRENT_PATH}/AccountServiceFilterProperty.cpp
-  PARENT_SCOPE
-)
diff --git a/src/platform/API/Account/log.h b/src/platform/API/Account/log.h
deleted file mode 100755 (executable)
index 5804619..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. 
-*/
-/*
- * log.h
- *
- *  Created on: 2011. 11. 25.
- *      Author: sangtai
- */
-
-#ifndef LOG_H_
-#define LOG_H_
-
-#include <dpl/log/log.h>
-
-#define AccountLogError(ARG)   LogError("\u001B[0;31m" << ARG << "\u001B[0;39m")
-#define AccountLogWarning(ARG) LogWarning("\u001B[1;33m" << ARG << "\u001B[0;39m")
-
-#endif /* LOG_H_ */
index eb5d4a2..6404f09 100755 (executable)
@@ -32,23 +32,20 @@ ApplicationService::ApplicationService() :
        m_service(NULL)
 {
     LogDebug("entered");
-       //m_serviceDataArray = ApplicationServiceDataPtr(new ApplicationServiceData);
 }
 
-ApplicationService::ApplicationService(const std::string &op, const std::string &uri, const std::string &mime, const std::string &appId, std::vector<ApplicationServiceDataPtr> &dataArray) :
+ApplicationService::ApplicationService(const std::string &op, const std::string &uri, const std::string &mime, std::vector<ApplicationServiceDataPtr> &dataArray) :
        m_service(NULL)
 {
     LogDebug("entered");
        m_operation = op;
        m_uri = uri;
        m_mime = mime;
-       m_appId = appId;
        m_serviceDataArray = dataArray;
 }
 
 ApplicationService::~ApplicationService()
 {
-    //nothing to do in destructor
     LogDebug("entered");
 }
 
@@ -82,23 +79,12 @@ void ApplicationService::setMime(const std::string &mime)
        m_mime = mime;
 }
 
-std::string ApplicationService::getAppId() const
-{
-       return m_appId;
-}
-
-void ApplicationService::setAppId(const std::string &appId)
-{
-       m_appId = appId;
-}
-
-
 std::vector<ApplicationServiceDataPtr> ApplicationService::getServiceDataArray() const
 {
        return m_serviceDataArray;
 }
 
-void ApplicationService::setServiceDataArray(std::vector<ApplicationServiceDataPtr> &dataArray)
+void ApplicationService::setServiceDataArray(const std::vector<ApplicationServiceDataPtr> &dataArray)
 {
        m_serviceDataArray = dataArray;
 }
index e0035ad..25a158a 100755 (executable)
@@ -36,7 +36,7 @@ class ApplicationService
 {
   public:
     ApplicationService();
-       ApplicationService(const std::string &op, const std::string &uri, const std::string &mime, const std::string &appId, std::vector<ApplicationServiceDataPtr> &dataArray) ;
+       ApplicationService(const std::string &op, const std::string &uri, const std::string &mime, std::vector<ApplicationServiceDataPtr> &dataArray) ;
     ~ApplicationService();
 
        std::string getOperation() const;
@@ -48,11 +48,8 @@ class ApplicationService
        std::string getMime() const;
        void setMime(const std::string &uri);
 
-       std::string getAppId() const;
-       void setAppId(const std::string &appId);
-
        std::vector<ApplicationServiceDataPtr> getServiceDataArray() const;
-       void setServiceDataArray(std::vector<ApplicationServiceDataPtr> &dataArray);
+       void setServiceDataArray(const std::vector<ApplicationServiceDataPtr> &dataArray);
        void addServiceData(const ApplicationServiceDataPtr &data);
 
        service_h getService_h() const;
@@ -65,7 +62,6 @@ class ApplicationService
        std::string m_operation;
        std::string m_uri;
        std::string m_mime;
-       std::string m_appId;
        std::vector<ApplicationServiceDataPtr> m_serviceDataArray;
        service_h m_service;
 };
index 652c351..5a8634d 100755 (executable)
@@ -36,6 +36,8 @@ private:
        ApplicationServicePtr m_service;
        int callbackType;
        int m_eventType;
+       std::string m_encodedBundle;
+       std::string m_appId;
 
 public:
 /* CALLBACK TYPE */
@@ -55,25 +57,6 @@ public:
                serviceData->setValue(value);
 
                m_service->addServiceData(serviceData);
-#if 0
-               
-               LogError("===[WS] create servicedata array");
-               std::vector<ApplicationServiceDataPtr> resultValue;
-               resultValue.push_back(serviceData);
-               LogError("===[WS] set service data array to event.");
-               LogError("===[WS] m_service:"<<m_service);
-               m_service->setServiceDataArray(resultValue);
-
-               if( !m_reply )
-               {
-                       ApplicationServiceReplyPtr reply(new ApplicationServiceReply());
-                       
-                       //ApplicationServiceDataPtr extraDataArray(new ApplicationServiceData());
-                       reply->setServiceDataArray(extraData);
-                       setService(reply);
-               }
-               //m_reply->addExtraData(extraData);
-#endif         
        }
  
        void setService(ApplicationServicePtr &appservice){
@@ -99,6 +82,22 @@ public:
        int getEventType(){
                return m_eventType;
        }       
+
+       void setEncodedBundle(std::string bundle){
+               m_encodedBundle = bundle;
+       }
+
+       std::string getEncodedBundle(){
+               return m_encodedBundle;
+       }
+
+       void setAppId(std::string appId){
+               m_appId = appId;
+       }
+
+       std::string getAppId(){
+               return m_appId;
+       }
        
        EventLaunchService() 
        {
index f8106b5..f265376 100755 (executable)
@@ -43,8 +43,6 @@ public:
        virtual ~IApplication();
        virtual void launch(const EventManageApplicationPtr& event) = 0;
        virtual void kill(const EventManageApplicationPtr& event) = 0;
-       virtual void exit() = 0;
-       virtual void hide() = 0;
        virtual void listApplications(const EventListInstalledApplicationsPtr& event) = 0;
        virtual void getApplication(const EventGetApplicationPtr& event) = 0;
        virtual long addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter) = 0;
diff --git a/src/platform/API/Bluetooth/EventBTCreateDestroyBonding.cpp b/src/platform/API/Bluetooth/EventBTCreateDestroyBonding.cpp
new file mode 100644 (file)
index 0000000..df24f47
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include "EventBTCreateDestroyBonding.h"
+#include "IBluetoothAdapterManager.h"
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <Tizen/Bluetooth/JSBluetoothAdapter.h>
+
+using namespace TizenApis::Api::Bluetooth;
+using namespace TizenApis::Tizen1_0;
+
+namespace TizenApis {
+namespace Api {
+namespace Bluetooth {
+
+EventBTCreateDestroyBonding::EventBTCreateDestroyBonding() 
+{ 
+       LogDebug("entered"); 
+}
+EventBTCreateDestroyBonding::~EventBTCreateDestroyBonding() 
+{ 
+
+}
+
+
+bool EventBTCreateDestroyBonding::cancelRequest()
+{
+       LogDebug("OK");
+       bool result = false;
+
+       BluetoothCreateBondingPrivateDataPtr privData = 
+               DPL::StaticPointerCast<BluetoothCreateBondingPrivateData>(IEvent<EventBTCreateDestroyBonding>::getPrivateData());
+       JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(privData->getObject()));
+       IBluetoothAdapterManagerPtr BluetoothAdapter(priv->getObject());
+
+       if (m_cancelled) {
+               LogDebug("Already canceleed");          
+               return false;
+       }
+       
+       if (m_state) {
+               LogDebug("cancelling");
+               result = BluetoothAdapter->createBondingCancel();
+               return result;
+       }
+
+       return result;
+}
+}
+}
+}
index b980292..0a77fb9 100644 (file)
@@ -22,7 +22,6 @@
 #include <dpl/shared_ptr.h>
 #include "BTDevice.h"
 
-
 namespace TizenApis {
 namespace Api {
 namespace Bluetooth {
@@ -34,8 +33,8 @@ private:
        bool m_operation;
        BluetoothDeviceData m_device;
 public:
-       EventBTCreateDestroyBonding() { LogDebug("entered"); }
-       ~EventBTCreateDestroyBonding() { }
+       EventBTCreateDestroyBonding() ;
+       ~EventBTCreateDestroyBonding() ;
        void setAddress(std::string address) { m_address = address;}
        std::string getAddress() { return m_address;}
        void setCreateBonding(void) { m_operation = true; }
@@ -44,6 +43,7 @@ public:
        bool isDestroyBonding(void) { return m_operation == true;}
        BluetoothDeviceData getDevice() { return m_device;}
        void setDevice(BluetoothDeviceData device) { m_device = device;}
+       virtual bool cancelRequest();
 };
 
 typedef DPL::SharedPtr<EventBTCreateDestroyBonding> EventBTCreateDestroyBondingPtr;
index 9aea743..52ca86b 100644 (file)
@@ -41,8 +41,8 @@ BluetoothSocketData& EventBTSocketNotification::getSocketData()
 
 void EventBTSocketNotification::setReadData(char *data, int length) 
 { 
-       Assert(data != NULL);
-       Assert(length != 0);
+/*     Assert(data != NULL);
+       Assert(length != 0);*/
        
        for (int i = 0; i < length; i++)
        {
index 803d849..72130d1 100644 (file)
@@ -26,15 +26,22 @@ namespace Bluetooth {
 
 using namespace WrtDeviceApis::Commons;
 IBluetoothAdapterManager::IBluetoothAdapterManager() :
-       EventRequestReceiver<EventBTCreateDestroyBonding>(ThreadEnum::BLUETOOTH_THREAD),
+/*     EventRequestReceiver<EventBTCreateDestroyBonding>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTGetKnownDevices>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTGetDevice>(ThreadEnum::BLUETOOTH_THREAD),   
        EventRequestReceiver<EventBTSetPowered>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTSetVisible>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTSetName>(ThreadEnum::BLUETOOTH_THREAD),
        EventRequestReceiver<EventBTStopDiscovery>(ThreadEnum::BLUETOOTH_THREAD),
-       EventRequestReceiver<EventBTRegisterRFCOMM>(ThreadEnum::BLUETOOTH_THREAD)
-       
+       EventRequestReceiver<EventBTRegisterRFCOMM>(ThreadEnum::BLUETOOTH_THREAD)*/
+       EventRequestReceiver<EventBTCreateDestroyBonding>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTGetKnownDevices>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTGetDevice>(ThreadEnum::NULL_THREAD),        
+       EventRequestReceiver<EventBTSetPowered>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTSetVisible>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTSetName>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTStopDiscovery>(ThreadEnum::NULL_THREAD),
+       EventRequestReceiver<EventBTRegisterRFCOMM>(ThreadEnum::NULL_THREAD)
        
 {
 }
index 883668a..d48c9cb 100644 (file)
@@ -56,6 +56,7 @@ public:
        virtual void getKownDevices(const EventBTGetKnownDevicesPtr& event) = 0;
        virtual void getDevice(const EventBTGetDevicePtr& event) = 0;
        virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) = 0;
+       virtual bool createBondingCancel() = 0;
        virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) = 0;
        virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event) = 0;
        virtual void stopDiscovery(const EventBTStopDiscoveryPtr& event) = 0;
index d6ae22c..c694811 100644 (file)
@@ -27,7 +27,9 @@ namespace Bluetooth {
 using namespace WrtDeviceApis::Commons;
 
 IBluetoothDeviceManager::IBluetoothDeviceManager() :
-       EventRequestReceiver<EventBTConnectToServiceByUUID>(ThreadEnum::BLUETOOTH_THREAD)
+//     EventRequestReceiver<EventBTConnectToServiceByUUID>(ThreadEnum::BLUETOOTH_THREAD)
+       EventRequestReceiver<EventBTConnectToServiceByUUID>(ThreadEnum::NULL_THREAD)
+
 {
 }
 
index 3a31444..2a762bb 100644 (file)
@@ -25,7 +25,8 @@ namespace Bluetooth {
 
 
 IBluetoothServiceHandlerManager::IBluetoothServiceHandlerManager() :
-       EventRequestReceiver<EventBTUnregisterRFCOMMService>(ThreadEnum::BLUETOOTH_THREAD)
+//     EventRequestReceiver<EventBTUnregisterRFCOMMService>(ThreadEnum::BLUETOOTH_THREAD)
+       EventRequestReceiver<EventBTUnregisterRFCOMMService>(ThreadEnum::NULL_THREAD)
 {
 }
 
index 57b17a6..8554799 100644 (file)
@@ -6,6 +6,7 @@ set(SRCS_PLATFORM_API_BLUETOOTH
   ${CURRENT_PATH}/EventBTGetDevice.cpp
   ${CURRENT_PATH}/EventBTOnDiscoveryDevices.cpp
   ${CURRENT_PATH}/EventBTSocketNotification.cpp
+  ${CURRENT_PATH}/EventBTCreateDestroyBonding.cpp
   ${CURRENT_PATH}/IBluetoothAdapterManager.cpp
   ${CURRENT_PATH}/IBluetoothDeviceManager.cpp
   ${CURRENT_PATH}/IBluetoothSocketManager.cpp
index 7bdfa8a..2f26f14 100755 (executable)
@@ -23,17 +23,30 @@ namespace TizenApis {
 namespace Api {
 namespace Calendar {
 
-CalendarEvent::CalendarEvent() :
+CalendarEvent::CalendarEvent():
+    m_id(UNDEFINED_ITEM_ID),
+    m_parentId(UNDEFINED_ITEM_ID),
     m_calendarId(UNDEFINED_CALENDAR_ID),
+    m_startTime(UNDEFINED_TIME),
+    m_endTime(UNDEFINED_TIME),
     m_recurrence(new EventRecurrenceRule()),
     m_status(UNDEFINED_STATUS),
     m_categories(new CategoryList()),
     m_isAllDay(false),
-    m_recurrenceId(0),
+    m_lastModifiedDate(UNDEFINED_TIME),
+    m_visibility(PUBLIC_VISIBILITY),
+    m_availability(BUSY_FB),
+    m_uid(UNDEFINED_ID),
+    m_recurrenceId(UNDEFINED_TIME),
     m_attendees(new EventAttendeeList()),
     m_isDetached(false),
     m_attributesOfInterest(new AttributeList()),
-    m_geolocation(new CalendarItemGeo()),
+    m_latitude(UNDEFINED_GEO),
+    m_longitude(UNDEFINED_GEO),
+    m_priority(LOW_PRIORITY),
+    m_createdDate(UNDEFINED_TIME),
+    m_completedDate(UNDEFINED_TIME),
+    m_progress(0),
     m_calendarType(EVENT_TYPE)
 {
 }
@@ -43,6 +56,7 @@ CalendarEvent::CalendarEvent(const CalendarEvent &original)
     LogDebug("Copy constructor called.");
 
     m_id = original.getId();
+    m_parentId = original.getParentId();
     m_calendarId = original.getCalendarId();
     m_description = original.getDescription();
     m_subject = original.getSubject();
@@ -106,10 +120,8 @@ CalendarEvent::CalendarEvent(const CalendarEvent &original)
     m_attributesOfInterest = attributesPtr;
     *m_attributesOfInterest = *(original.getAttributesOfInterest());
 
-    CalendarItemGeoPtr geoPtr( new CalendarItemGeo() );
-    m_geolocation = geoPtr;
-    m_geolocation->setLatitude(original.getGeolocation()->getLatitude());
-    m_geolocation->setLongitude(original.getGeolocation()->getLongitude());
+    m_latitude = original.getLatitude();
+    m_longitude = original.getLongitude();
 
     m_timeZone = original.getTimeZone();
     m_priority = original.getPriority();
@@ -125,34 +137,51 @@ CalendarEvent::~CalendarEvent()
 {
 }
 
-bool CalendarEvent::getIdIsSet() const
+int CalendarEvent::getId() const
 {
-    return !m_id.IsNull();
+    return m_id;
 }
 
-int CalendarEvent::getCalendarId() const
+void CalendarEvent::setId(int value)
 {
-    return m_calendarId;
+    m_id = value;
+
+    // Set the uid also.
+    std::stringstream ss;
+    ss<<value;
+    m_uid = ss.str();
+    LogDebug("m_id: "<<m_id<<", m_uid: "<<m_uid);
 }
 
-void CalendarEvent::setCalendarId(int value)
+void CalendarEvent::resetId()
 {
-    m_calendarId = value;
+    m_id = UNDEFINED_ITEM_ID;
+    m_uid = "";
 }
 
-int CalendarEvent::getId() const
+bool CalendarEvent::getIdIsSet() const
 {
-    return *m_id;
+    return !(m_id==UNDEFINED_ITEM_ID);
 }
 
-void CalendarEvent::setId(int value)
+int CalendarEvent::getParentId() const
 {
-    m_id = value;
+    return m_parentId;
 }
 
-void CalendarEvent::resetId()
+void CalendarEvent::setParentId(int value)
+{
+    m_parentId = value;
+}
+
+int CalendarEvent::getCalendarId() const
 {
-    m_id = DPL::Optional<int>();
+    return m_calendarId;
+}
+
+void CalendarEvent::setCalendarId(int value)
+{
+    m_calendarId = value;
 }
 
 std::string CalendarEvent::getDescription() const
@@ -267,11 +296,16 @@ void CalendarEvent::setCategories(const CategoryListPtr &value)
 void CalendarEvent::display() const
 {
     LogDebug("m_id " << m_id);
+    LogDebug("m_parentId " << m_parentId);
     LogDebug("m_calendarId " << m_calendarId);
     LogDebug("m_calendarType " << m_calendarType);
     LogDebug("m_description " << m_description);
     LogDebug("m_subject " << m_subject);
+
     LogDebug("m_startTime " << m_startTime);
+    tm* startDate = localtime(&m_startTime);
+    LogDebug("year: "<<startDate->tm_year<<", month: "<<startDate->tm_mon<<", day: "<<startDate->tm_mday<<", hour: "<<startDate->tm_hour);
+
     LogDebug("m_endTime " << m_endTime);
     LogDebug("m_location " << m_location);
     LogDebug("m_recurrence " << m_recurrence);
@@ -281,14 +315,21 @@ void CalendarEvent::display() const
     LogDebug("m_lastModifiedDate " << m_lastModifiedDate);
     LogDebug("m_visibility " << m_visibility);
     LogDebug("m_availability " << m_availability);
+
+    if(m_recurrence->getFrequency()!=EventRecurrenceRule::NO_RECURRENCE) {
+        LogDebug("recurrence frequency " << m_recurrence->getFrequency());
+        LogDebug("recurrence interval " << m_recurrence->getInterval());
+        LogDebug("recurrence recurrenceCount " << m_recurrence->getOccurrenceCount());
+        LogDebug("recurrence endDate " << m_recurrence->getEndDate());
+        std::time_t endDateOrigin = m_recurrence->getEndDate();
+        tm* endDate = localtime(&endDateOrigin);
+        LogDebug("year: "<<endDate->tm_year<<", month: "<<endDate->tm_mon<<", day: "<<endDate->tm_mday<<", hour: "<<endDate->tm_hour);
+    }
 }
 
 bool CalendarEvent::validate() const
 {
-    if (m_status == INVALID_STATUS) {
-        LogError("Incorrect status value detected");
-        return false;
-    }
+    LogInfo("Nothing to validate.");
     return true;
 }
 
@@ -392,14 +433,24 @@ void CalendarEvent::setAttributesOfInterest(AttributeListPtr value)
     m_attributesOfInterest = value;
 }
 
-CalendarItemGeoPtr CalendarEvent::getGeolocation() const
+double CalendarEvent::getLatitude() const
+{
+    return m_latitude;
+}
+
+void CalendarEvent::setLatitude(double value)
+{
+    m_latitude = value;
+}
+
+double CalendarEvent::getLongitude() const
 {
-    return m_geolocation;
+    return m_longitude;
 }
 
-void CalendarEvent::setGeolocation(CalendarItemGeoPtr value)
+void CalendarEvent::setLongitude(double value)
 {
-    m_geolocation = value;
+    m_longitude = value;
 }
 
 std::string CalendarEvent::getTimeZone() const
index c5f2ccf..ea1cd2f 100755 (executable)
 #include <ctime>
 #include <string>
 #include <vector>
-#include <dpl/optional.h>
 #include <dpl/shared_ptr.h>
 
-#include "CalendarItemGeo.h"
 #include "EventAttendee.h"
 #include "EventRecurrenceRule.h"
 
@@ -32,6 +30,11 @@ namespace TizenApis {
 namespace Api {
 namespace Calendar {
 
+#define UNDEFINED_CALENDAR_ID 0
+#define UNDEFINED_ITEM_ID 0
+#define UNDEFINED_GEO 0
+#define UNDEFINED_ID "0"
+
 typedef std::vector<std::string> CategoryList;
 typedef DPL::SharedPtr<CategoryList> CategoryListPtr;
 
@@ -42,9 +45,6 @@ typedef DPL::SharedPtr<AttributeList> AttributeListPtr;
 class CalendarEvent
 {
   public:
-
-    static const int UNDEFINED_CALENDAR_ID = -1;
-
     typedef enum
     {
         TENTATIVE_STATUS,
@@ -53,7 +53,6 @@ class CalendarEvent
         NEEDS_ACTION_STATUS,
         IN_PROCESS_STATUS,
         COMPLETED_STATUS,
-        INVALID_STATUS = 10000,
         UNDEFINED_STATUS
     } EventStatus;
 
@@ -62,7 +61,6 @@ class CalendarEvent
         NO_ALARM,
         SILENT_ALARM,
         SOUND_ALARM,
-        INVALID_ALARM_TYPE = 10000,
         UNDEFINED_ALARM_TYPE
     } EventAlarmType;
 
@@ -71,7 +69,6 @@ class CalendarEvent
         PUBLIC_VISIBILITY,
         PRIVATE_VISIBILITY,
         CONFIDENTIAL_VISIBILITY,
-        INVALID_VISIBILITY = 10000,
         UNDEFINED_VISIBILITY
     } EventVisibility;
 
@@ -81,7 +78,6 @@ class CalendarEvent
         BUSY_UNAVAILABLE_FB,
         FREE_FB,
         BUSY_TENTATIVE_FB,
-        INVALID_AVAILABILITY = 10000,
         UNDEFINED_AVAILABILITY
     } EventAvailability;
 
@@ -90,7 +86,6 @@ class CalendarEvent
         LOW_PRIORITY,
         MEDIUM_PRIORITY,
         HIGH_PRIORITY,
-        INVALID_PRIORITY = 10000,
         UNDEFINED_PRIORITY
     } TaskPriority;
 
@@ -98,7 +93,6 @@ class CalendarEvent
     {
         ICALENDAR_20,
         VCALENDAR_10,
-        INVALID_FORMAT = 10000,
         UNDEFINED_FORMAT
     } VObjectFormat;
 
@@ -106,6 +100,7 @@ class CalendarEvent
     {
         EVENT_TYPE = 0,
         TASK_TYPE,
+        UNDEFINED_TYPE
     } CalendarType;
 
 
@@ -118,6 +113,9 @@ class CalendarEvent
     void resetId();
     bool getIdIsSet() const;
 
+    int getParentId() const;
+    void setParentId(int value);
+
     int getCalendarId() const;
     void setCalendarId(int value);
 
@@ -187,8 +185,11 @@ class CalendarEvent
     void setAttributesOfInterest(AttributeListPtr value);
     AttributeListPtr getAttributesOfInterest() const;
 
-    void setGeolocation(CalendarItemGeoPtr value);
-    CalendarItemGeoPtr getGeolocation() const;
+    double getLatitude() const;
+    void setLatitude(double value);
+
+    double getLongitude() const;
+    void setLongitude(double value);
 
     void setTimeZone(std::string value);
     std::string getTimeZone() const;
@@ -209,7 +210,8 @@ class CalendarEvent
     void setCalendarType(CalendarType type);
 
   protected:
-    DPL::Optional<int> m_id;
+    int m_id;
+    int m_parentId; // the parent id if it's detached.
     int m_calendarId;
     std::string m_description;
     std::string m_subject;
@@ -227,12 +229,13 @@ class CalendarEvent
     std::time_t m_lastModifiedDate;
     EventVisibility m_visibility;
     EventAvailability m_availability;
-    std::string m_uid;
+    std::string m_uid; // uid is same with id.
     std::time_t m_recurrenceId;
     EventAttendeeListPtr m_attendees;
     bool m_isDetached;
     AttributeListPtr m_attributesOfInterest;
-    CalendarItemGeoPtr m_geolocation;
+    double m_latitude;
+    double m_longitude;
     std::string m_timeZone;
     TaskPriority m_priority;
     std::time_t m_createdDate;
diff --git a/src/platform/API/Calendar/CalendarItemGeo.h b/src/platform/API/Calendar/CalendarItemGeo.h
deleted file mode 100755 (executable)
index d5afc27..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _CALENDAR_ITEM_GEO_H_
-#define _CALENDAR_ITEM_GEO_H_
-
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class CalendarItemGeo
-{
-  public:
-
-       enum GeoValue{
-               GEO_LATITUDE_MIN = -90,
-               GEO_LATITUDE_MAX = 90,
-               GEO_LONGITUDE_MIN = -180,
-               GEO_LONGITUDE_MAX = 180,
-               GEO_UNDEFINED = -999
-       };
-
-    CalendarItemGeo();
-    virtual ~CalendarItemGeo();
-
-    double getLatitude() const;
-    void setLatitude(const double &value);
-
-    double getLongitude() const;
-    void setLongitude(const double &value);
-
-  protected:
-    double m_latitude;
-    double m_longitude;
-};
-
-typedef DPL::SharedPtr<CalendarItemGeo> CalendarItemGeoPtr;
-
-}
-}
-}
-
-#endif /* _CALENDAR_ITEM_GEO_H_ */
index 828adbb..50a9c15 100755 (executable)
@@ -24,7 +24,7 @@ namespace Calendar {
 
 EventAlarm::EventAlarm()
 {
-    m_absoluteDate = 0;
+    m_absoluteDate = UNDEFINED_TIME;
 }
 EventAlarm::~EventAlarm()
 {
index f4dc01a..fb674ad 100755 (executable)
@@ -36,8 +36,7 @@ class EventAttendee
         OPT_PARTICIPANT_ROLE,
         NON_PARTICIPANT_ROLE,
         CHAIR_ROLE,
-        INVALID_ATTENDEE_ROLE = 10000,
-        UNDEFINED_ATTENDEE_ROLE            /* should be used only to mark a fact filter is not set */
+        UNDEFINED_ATTENDEE_ROLE
     } EventAttendeeRole;
 
     typedef enum
@@ -49,8 +48,7 @@ class EventAttendee
         DELEGATED_AT_STATUS,
         COMPLETED_AT_STATUS,
         IN_PROCESS_AT_STATUS,
-        INVALID_ATTENDEE_STATUS = 10000,
-        UNDEFINED_ATTENDEE_STATUS            /* should be used only to mark a fact filter is not set */
+        UNDEFINED_ATTENDEE_STATUS
     } EventAttendeeStatus;
 
     typedef enum
@@ -60,8 +58,7 @@ class EventAttendee
         RESOURCE_TYPE,
         ROOM_TYPE,
         UNKNOWN_TYPE,
-        INVALID_ATTENDEE_TYPE = 10000,
-        UNDEFINED_ATTENDEE_TYPE            /* should be used only to mark a fact filter is not set */
+        UNDEFINED_ATTENDEE_TYPE
     } EventAttendeeType;
 
     EventAttendee();
diff --git a/src/platform/API/Calendar/EventFilter.cpp b/src/platform/API/Calendar/EventFilter.cpp
deleted file mode 100755 (executable)
index 495fb0c..0000000
+++ /dev/null
@@ -1,286 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "EventFilter.h"
-#include <dpl/log/log.h>
-
-/**
- * @file        EventFilter.cpp
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-EventFilter::EventFilter()
-{
-}
-
-EventFilter::~EventFilter()
-{
-}
-
-std::string EventFilter::getIdFilter() const
-{
-    return *m_id;
-}
-
-void EventFilter::setIdFilter(const std::string &value)
-{
-    m_id = value;
-}
-
-int EventFilter::getCalendarIdFilter() const
-{
-    return *m_calendarId;
-}
-
-void EventFilter::setCalendarIdFilter(int value)
-{
-    m_calendarId = value;
-}
-
-std::string EventFilter::getDescriptionFilter() const
-{
-    return *m_description;
-}
-
-void EventFilter::setDescriptionFilter(const std::string &value)
-{
-    m_description = value;
-}
-
-std::string EventFilter::getSubjectFilter() const
-{
-    return *m_subject;
-}
-
-void EventFilter::setSubjectFilter(const std::string &value)
-{
-    m_subject = value;
-}
-
-time_t EventFilter::getStartTimeMinFilter() const
-{
-    return *m_startTimeMin;
-}
-
-time_t EventFilter::getStartTimeMaxFilter() const
-{
-    return *m_startTimeMax;
-}
-
-void EventFilter::setStartTimeMinFilter(time_t value)
-{
-    m_startTimeMin = value;
-}
-
-void EventFilter::setStartTimeMaxFilter(time_t value)
-{
-    m_startTimeMax = value;
-}
-
-void EventFilter::setStartTimeFilter(time_t value)
-{
-    setStartTimeMinFilter(value);
-    setStartTimeMaxFilter(value);
-}
-
-time_t EventFilter::getEndTimeMinFilter() const
-{
-    return *m_endTimeMin;
-}
-
-time_t EventFilter::getEndTimeMaxFilter() const
-{
-    return *m_endTimeMax;
-}
-
-void EventFilter::setEndTimeMinFilter(time_t value)
-{
-    m_endTimeMin = value;
-}
-
-void EventFilter::setEndTimeMaxFilter(time_t value)
-{
-    m_endTimeMax = value;
-}
-
-void EventFilter::setEndTimeFilter(time_t value)
-{
-    setEndTimeMinFilter(value);
-    setEndTimeMaxFilter(value);
-}
-
-std::string EventFilter::getLocationFilter() const
-{
-    return *m_location;
-}
-
-void EventFilter::setLocationFilter(const std::string &value)
-{
-    m_location = value;
-}
-
-std::vector<EventRecurrenceRule::EventRecurrence> EventFilter::getRecurrenceFilter()
-const
-{
-    return m_recurrence;
-}
-
-void EventFilter::addRecurrenceFilter(EventRecurrenceRule::EventRecurrence value)
-{
-    m_recurrence.push_back(value);
-}
-
-std::vector<CalendarEvent::EventStatus> EventFilter::getStatusFilter() const
-{
-    return m_status;
-}
-
-void EventFilter::addStatusFilter(CalendarEvent::EventStatus value)
-{
-    m_status.push_back(value);
-}
-
-time_t EventFilter::getAlarmTimeMinFilter() const
-{
-    return *m_alarmTimeMin;
-}
-
-time_t EventFilter::getAlarmTimeMaxFilter() const
-{
-    return *m_alarmTimeMax;
-}
-
-void EventFilter::setAlarmTimeMinFilter(time_t value)
-{
-    m_alarmTimeMin = value;
-}
-
-void EventFilter::setAlarmTimeMaxFilter(time_t value)
-{
-    m_alarmTimeMax = value;
-}
-
-void EventFilter::setAlarmTimeFilter(time_t value)
-{
-    setAlarmTimeMinFilter(value);
-    setAlarmTimeMaxFilter(value);
-}
-
-std::vector<CalendarEvent::EventAlarmType> EventFilter::getAlarmTypeFilter()
-const
-{
-    return m_alarmType;
-}
-
-void EventFilter::addAlarmTypeFilter(CalendarEvent::EventAlarmType value)
-{
-    m_alarmType.push_back(value);
-}
-
-std::string EventFilter::getCategoryFilter() const
-{
-    return *m_category;
-}
-
-void EventFilter::setCategoryFilter(const std::string &category)
-{
-    m_category = category;
-}
-
-bool EventFilter::getIdIsSet() const
-{
-    return !m_id.IsNull();
-}
-
-bool EventFilter::getCalendarIdIsSet() const
-{
-    return !m_calendarId.IsNull();
-}
-
-bool EventFilter::getDescriptionIsSet() const
-{
-    return !m_description.IsNull();
-}
-
-bool EventFilter::getSubjectIsSet() const
-{
-    return !m_subject.IsNull();
-}
-
-bool EventFilter::getStartTimeMinIsSet() const
-{
-    return !m_startTimeMin.IsNull();
-}
-
-bool EventFilter::getStartTimeMaxIsSet() const
-{
-    return !m_startTimeMax.IsNull();
-}
-
-bool EventFilter::getEndTimeMinIsSet() const
-{
-    return !m_endTimeMin.IsNull();
-}
-
-bool EventFilter::getEndTimeMaxIsSet() const
-{
-    return !m_endTimeMax.IsNull();
-}
-
-bool EventFilter::getLocationIsSet() const
-{
-    return !m_location.IsNull();
-}
-
-bool EventFilter::getRecurrenceIsSet() const
-{
-    return !m_recurrence.empty();
-}
-
-bool EventFilter::getStatusIsSet() const
-{
-    return !m_status.empty();
-}
-
-bool EventFilter::getAlarmTimeMinIsSet() const
-{
-    return !m_alarmTimeMin.IsNull();
-}
-
-bool EventFilter::getAlarmTimeMaxIsSet() const
-{
-    return !m_alarmTimeMax.IsNull();
-}
-
-bool EventFilter::getAlarmTypeIsSet() const
-{
-    return !m_alarmType.empty();
-}
-
-bool EventFilter::getCategoryIsSet() const
-{
-    return !m_category.IsNull();
-}
-
-}
-}
-}
diff --git a/src/platform/API/Calendar/EventFilter.h b/src/platform/API/Calendar/EventFilter.h
deleted file mode 100755 (executable)
index 69259e7..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ABSTRACT_LAYER_IEVENT_FILTER_H_
-#define _ABSTRACT_LAYER_IEVENT_FILTER_H_
-
-#include <ctime>
-#include <string>
-#include <vector>
-#include <dpl/shared_ptr.h>
-#include <dpl/optional.h>
-#include "CalendarEvent.h"
-#include "EventRecurrenceRule.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class EventFilter
-{
-  public:
-
-    EventFilter();
-    virtual ~EventFilter();
-
-    std::string getIdFilter() const;
-    void setIdFilter(const std::string &value);
-
-    int getCalendarIdFilter() const;
-    void setCalendarIdFilter(int value);
-
-    std::string getDescriptionFilter() const;
-    void setDescriptionFilter(const std::string &value);
-
-    std::string getSubjectFilter() const;
-    void setSubjectFilter(const std::string &value);
-
-    std::time_t getStartTimeMinFilter() const;
-    std::time_t getStartTimeMaxFilter() const;
-    void setStartTimeMinFilter(std::time_t value);
-    void setStartTimeMaxFilter(std::time_t value);
-    void setStartTimeFilter(std::time_t value);
-
-    std::time_t getEndTimeMinFilter() const;
-    std::time_t getEndTimeMaxFilter() const;
-    void setEndTimeMinFilter(std::time_t value);
-    void setEndTimeMaxFilter(std::time_t value);
-    void setEndTimeFilter(std::time_t value);
-
-    std::string getLocationFilter() const;
-    void setLocationFilter(const std::string &value);
-
-    std::vector<EventRecurrenceRule::EventRecurrence> getRecurrenceFilter() const;
-    void addRecurrenceFilter(EventRecurrenceRule::EventRecurrence value);
-
-    std::vector<CalendarEvent::EventStatus> getStatusFilter() const;
-    void addStatusFilter(CalendarEvent::EventStatus value);
-
-    std::time_t getAlarmTimeMinFilter() const;
-    std::time_t getAlarmTimeMaxFilter() const;
-    void setAlarmTimeMinFilter(std::time_t value);
-    void setAlarmTimeMaxFilter(std::time_t value);
-    void setAlarmTimeFilter(std::time_t value);
-
-    std::vector<CalendarEvent::EventAlarmType> getAlarmTypeFilter() const;
-    void addAlarmTypeFilter(CalendarEvent::EventAlarmType value);
-
-    std::string getCategoryFilter() const;
-    void setCategoryFilter(const std::string &category);
-
-    bool getIdIsSet() const;
-    bool getCalendarIdIsSet() const;
-    bool getDescriptionIsSet() const;
-    bool getSubjectIsSet() const;
-    bool getStartTimeMinIsSet() const;
-    bool getStartTimeMaxIsSet() const;
-    bool getEndTimeMinIsSet() const;
-    bool getEndTimeMaxIsSet() const;
-    bool getLocationIsSet() const;
-    bool getRecurrenceIsSet() const;
-    bool getStatusIsSet() const;
-    bool getAlarmTimeMinIsSet() const;
-    bool getAlarmTimeMaxIsSet() const;
-    bool getAlarmTypeIsSet() const;
-    bool getCategoryIsSet() const;
-
-  protected:
-    DPL::Optional<std::string> m_id;
-    DPL::Optional<int>         m_calendarId;
-    DPL::Optional<std::string> m_description;
-    DPL::Optional<std::string> m_subject;
-    DPL::Optional<std::time_t> m_startTimeMin;
-    DPL::Optional<std::time_t> m_startTimeMax;
-    DPL::Optional<std::time_t> m_endTimeMin;
-    DPL::Optional<std::time_t> m_endTimeMax;
-    DPL::Optional<std::string> m_location;
-    std::vector<EventRecurrenceRule::EventRecurrence> m_recurrence;
-    std::vector<CalendarEvent::EventStatus>     m_status;
-    std::vector<CalendarEvent::EventAlarmType>  m_alarmType;
-    DPL::Optional<std::time_t> m_alarmTimeMin;
-    DPL::Optional<std::time_t> m_alarmTimeMax;
-    DPL::Optional<std::string> m_category;
-};
-
-typedef DPL::SharedPtr<EventFilter> EventFilterPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_IEVENT_FILTER_H_ */
index 8c6ffd7..fec63c0 100755 (executable)
@@ -23,7 +23,6 @@ namespace Calendar {
 
 EventId::EventId()
 {
-    m_recurrenceId = 0;
 }
 
 EventId::~EventId()
@@ -40,26 +39,16 @@ void EventId::setUId(const std::string &value)
     m_uid = value;
 }
 
-std::time_t EventId::getRecurrenceId() const
+std::string EventId::getRecurrenceId() const
 {
     return m_recurrenceId;
 }
 
-void EventId::setRecurrenceId(const std::time_t &value)
+void EventId::setRecurrenceId(const std::string &value)
 {
     m_recurrenceId = value;
 }
 
-std::string EventId::getTimeZone() const
-{
-    return m_timeZone;
-}
-
-void EventId::setTimeZone(const std::string &value)
-{
-    m_timeZone = value;
-}
-
 CalendarEvent::CalendarType EventId::getCalendarType() const
 {
     return m_calendarType;
index 1a3d8c3..05f2fd4 100755 (executable)
@@ -32,26 +32,21 @@ namespace Calendar {
 class EventId
 {
   public:
-
     EventId();
     virtual ~EventId();
 
     std::string getUId() const;
     void setUId(const std::string &value);
 
-    std::time_t getRecurrenceId() const;
-    void setRecurrenceId(const std::time_t &value);
-
-    std::string getTimeZone() const;
-    void setTimeZone(const std::string &value);
+    std::string getRecurrenceId() const;
+    void setRecurrenceId(const std::string &value);
     
     CalendarEvent::CalendarType getCalendarType() const;
     void setCalendarType(CalendarEvent::CalendarType type);
 
   protected:
     std::string m_uid;
-    std::time_t m_recurrenceId;
-    std::string m_timeZone;
+    std::string m_recurrenceId;
     CalendarEvent::CalendarType m_calendarType;
 };
 
index 3966379..7ed37be 100755 (executable)
 #include <Commons/Exception.h>
 #include <dpl/log/log.h>
 
-/**
- * @file        EventRecurrenceRule.cpp
- *
- * @version     0.1
- */
-
 namespace TizenApis {
 namespace Api {
 namespace Calendar {
 
-EventRecurrenceRule::EventRecurrenceRule() :
-    m_frequency(NO_RECURRENCE),
-    m_occurrenceCount(-1),
-    m_setPosition(false)
+EventRecurrenceRule::EventRecurrenceRule()
 {
+    m_frequency = NO_RECURRENCE;
+    m_interval = 1;
+    m_endDate = UNDEFINED_TIME;
+    m_occurrenceCount = -1;
+    m_setPosition = false;
+    m_timeZone = "UTC";
 }
 
 EventRecurrenceRule::~EventRecurrenceRule()
@@ -60,12 +57,12 @@ void EventRecurrenceRule::setInterval(const int &value)
     m_interval = value;
 }
 
-time_t EventRecurrenceRule::getEndDate() const
+std::time_t EventRecurrenceRule::getEndDate() const
 {
     return m_endDate;
 }
 
-void EventRecurrenceRule::setEndDate(time_t value)
+void EventRecurrenceRule::setEndDate(std::time_t value)
 {
     m_endDate = value;
 }
@@ -129,12 +126,12 @@ void EventRecurrenceRule::setSetPosition(bool value)
     m_setPosition = value;
 }
 
-std::vector<time_t> EventRecurrenceRule::getExceptions() const
+std::vector<std::time_t> EventRecurrenceRule::getExceptions() const
 {
     return m_exceptions;
 }
 
-void EventRecurrenceRule::setExceptions(std::vector<time_t> value)
+void EventRecurrenceRule::setExceptions(std::vector<std::time_t> value)
 {
     m_exceptions = value;
 }
index 6f9e513..3c22de9 100755 (executable)
 
 #include <string>
 #include <vector>
+#include <ctime>
 #include <dpl/shared_ptr.h>
 
 namespace TizenApis {
 namespace Api {
 namespace Calendar {
 
+#define UNDEFINED_TIME 0
+
 class EventRecurrenceRule
 {
   public:
@@ -39,8 +42,7 @@ class EventRecurrenceRule
         YEARLY_RECURRENCE,              //The calendar entry occurs every year  e.g. every June 1st
         WEEKDAY_RECURRENCE,             //The calendar entry occurs Mon-Fri every week
         MONTHLY_ON_DAY_RECURRENCE,      //The calendar entry occurs on the same weekday or weekend every month, e.g., every second Tuesday each month.
-        INVALID_RECURRENCE = 10000,
-        UNDEFINED_RECURRENCE            /* should be used only to mark a fact filter is not set */
+        UNDEFINED_RECURRENCE
     } EventRecurrence;
 
     EventRecurrenceRule();
@@ -52,8 +54,8 @@ class EventRecurrenceRule
     int getInterval() const;
     void setInterval(const int &value);
 
-    time_t getEndDate() const;
-    void setEndDate(time_t value);
+    std::time_t getEndDate() const;
+    void setEndDate(std::time_t value);
 
     long getOccurrenceCount() const;
     void setOccurrenceCount(long value);
@@ -73,8 +75,8 @@ class EventRecurrenceRule
     bool getSetPosition() const;
     void setSetPosition(bool value);
 
-    std::vector<time_t> getExceptions() const;
-    void setExceptions(std::vector<time_t> value);
+    std::vector<std::time_t> getExceptions() const;
+    void setExceptions(std::vector<std::time_t> value);
 
     std::string getTimeZone() const;
     void setTimeZone(std::string value);
@@ -82,14 +84,14 @@ class EventRecurrenceRule
   protected:
     EventRecurrence m_frequency;
     int m_interval;
-    time_t m_endDate;
+    std::time_t m_endDate;
     long m_occurrenceCount;
     std::vector<int> m_daysOfTheMonth;
     std::vector<std::string> m_daysOfTheWeek;
     std::vector<int> m_daysOfTheYear;
     std::vector<int> m_weeksOfTheYear;
     bool m_setPosition;
-    std::vector<time_t> m_exceptions;
+    std::vector<std::time_t> m_exceptions;
     std::string m_timeZone;
 };
 
index c5d44e2..c51e256 100755 (executable)
@@ -30,7 +30,6 @@ ICalendar::ICalendar() :
     WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventFindEvents>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEvent>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEventFromString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventExportEventToString>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
@@ -46,11 +45,6 @@ ICalendar::~ICalendar()
 {
 }
 
-void ICalendar::createEvent(IEventCreateEventPtr &event)
-{
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventCreateEvent>::PostRequest(event);
-}
-
 void ICalendar::addEvent(IEventAddEventPtr &event)
 {
     WrtDeviceApis::Commons::EventRequestReceiver<IEventAddEvent>::PostRequest(event);
index d9e1b24..0b0ea58 100755 (executable)
 #include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "CalendarEvent.h"
-#include "EventFilter.h"
 #include "IEventAddEvent.h"
 #include "IEventAddEvents.h"
-#include "IEventCreateEvent.h"
 #include "IEventDeleteEvent.h"
 #include "IEventDeleteEvents.h"
 #include "IEventFindEvents.h"
@@ -38,9 +36,6 @@
 #include "IEventClearWatch.h"
 #include "IEventExpandEventRecurrence.h"
 #include "IEventGet.h"
-#include "OnAddEventsChanged.h"
-#include "OnUpdateEventsChanged.h"
-#include "OnDeleteEventsChanged.h"
 #include "OnEventsChanged.h"
 
 namespace TizenApis {
@@ -54,7 +49,6 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateEvent >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventUpdateEvents >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindEvents >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventCreateEvent >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventCreateEventFromString >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventExportEventToString >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventWatchChanges >,
@@ -65,7 +59,6 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
   public:
     ICalendar();
     virtual ~ICalendar();
-    virtual void                createEvent(IEventCreateEventPtr &event);
     virtual void                addEvent(IEventAddEventPtr &event);
     virtual void                addEvents(IEventAddEventsPtr &events);
     virtual void                updateEvent(IEventUpdateEventPtr &event);
@@ -118,33 +111,6 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
         m_accountId = value;
     }
 
-    virtual OnAddEventsChangedEmitterPtr getAddEmitter() const
-    {
-        return m_addEmitter;
-    }
-    virtual void                setAddEmitter(OnAddEventsChangedEmitterPtr value)
-    {
-        m_addEmitter = value;
-    }
-
-    virtual OnUpdateEventsChangedEmitterPtr getUpdateEmitter() const
-    {
-        return m_updateEmitter;
-    }
-    virtual void                setUpdateEmitter(OnUpdateEventsChangedEmitterPtr value)
-    {
-        m_updateEmitter = value;
-    }
-
-    virtual OnDeleteEventsChangedEmitterPtr getDeleteEmitter() const
-    {
-        return m_deleteEmitter;
-    }
-    virtual void                setDeleteEmitter(OnDeleteEventsChangedEmitterPtr value)
-    {
-        m_deleteEmitter = value;
-    }
-
     virtual std::time_t getLastChangeFetchTime()
     {
         return m_lastChangeFetchTime;
@@ -161,9 +127,6 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     int m_accountId;
     std::string m_name;
     CalendarEvent::CalendarType m_type;
-    OnAddEventsChangedEmitterPtr m_addEmitter;
-    OnUpdateEventsChangedEmitterPtr m_updateEmitter;
-    OnDeleteEventsChangedEmitterPtr m_deleteEmitter;
     std::time_t m_lastChangeFetchTime;
 
     virtual void OnRequestReceived(const IEventAddEventPtr &event) = 0;
@@ -173,7 +136,6 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     virtual void OnRequestReceived(const IEventUpdateEventPtr &event) = 0;
     virtual void OnRequestReceived(const IEventUpdateEventsPtr &events) = 0;
     virtual void OnRequestReceived(const IEventFindEventsPtr &event) = 0;
-    virtual void OnRequestReceived(const IEventCreateEventPtr &event) = 0;
     virtual void OnRequestReceived(const IEventCreateEventFromStringPtr &event) = 0;
     virtual void OnRequestReceived(const IEventExportEventToStringPtr &event) = 0;
     virtual void OnRequestReceived(const IEventWatchChangesPtr &event) = 0;
diff --git a/src/platform/API/Calendar/IEventCreateEvent.h b/src/platform/API/Calendar/IEventCreateEvent.h
deleted file mode 100755 (executable)
index 3d82ac3..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ABSTRACT_LAYER_IEVENT_CREATE_EVENT_H_
-#define _ABSTRACT_LAYER_IEVENT_CREATE_EVENT_H_
-
-#include <dpl/shared_ptr.h>
-#include <Commons/IEvent.h>
-#include "CalendarEvent.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class IEventCreateEvent : public WrtDeviceApis::Commons::IEvent<IEventCreateEvent>
-{
-    CalendarEventPtr m_event;
-    bool m_result;
-  public:
-    void             setResult(bool value)
-    {
-        m_result = value;
-    }
-    bool             getResult() const
-    {
-        return m_result;
-    }
-    void             setEvent(CalendarEventPtr value)
-    {
-        m_event = value;
-    }
-    CalendarEventPtr getEvent() const
-    {
-        return m_event;
-    }
-    IEventCreateEvent() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventCreateEvent()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventCreateEvent> IEventCreateEventPtr;
-
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_CREATE_EVENT_H_ */
index 876c5ef..f3e8472 100755 (executable)
@@ -21,7 +21,6 @@
 #include <vector>
 #include <Commons/IEvent.h>
 #include "CalendarEvent.h"
-#include "EventFilter.h"
 #include <API/Filter/IFilter.h>
 #include <API/Filter/SortMode.h>
 #include <dpl/shared_ptr.h>
@@ -35,10 +34,7 @@ class IEventFindEvents : public WrtDeviceApis::Commons::IEvent<IEventFindEvents>
     /* user is responsible to free objects inside list */
     CalendarEventListPtr m_events;
     bool m_result;
-    EventFilterPtr m_filter;
     CalendarEvent::CalendarType m_calendarType;
-
-       /* generic filter parameters */
        Tizen::FilterPtr                        m_genericFilter;
        Tizen::SortModeArrayPtr m_sortModes;
        std::vector<std::string>                m_attributesOfInterest;
@@ -47,15 +43,6 @@ class IEventFindEvents : public WrtDeviceApis::Commons::IEvent<IEventFindEvents>
        bool    m_attributesOfInterestIsSet;
 
   public:
-    void                        setFilter(EventFilterPtr value)
-    {
-        m_filter = value;
-    }
-    EventFilterPtr              getFilter() const
-    {
-        return m_filter;
-    }
-
     void                        setResult(bool value)
     {
         m_result = value;
diff --git a/src/platform/API/Calendar/OnAddEventsChanged.h b/src/platform/API/Calendar/OnAddEventsChanged.h
deleted file mode 100755 (executable)
index f634499..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ON_ADD_EVENTS_CHANGED_H_
-#define _ON_ADD_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-#include "CalendarEvent.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class OnAddEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnAddEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_ADD_SUCCESS,
-               EVENT_ADD_FAIL
-    } EventAddStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEvent(CalendarEventPtr value) {
-        m_event = value;
-    }
-    CalendarEventPtr getEvent() const {
-        return m_event;
-    }
-
-    void setStatus(EventAddStatus value) {
-        m_status = value;
-    }
-    EventAddStatus getStatus() const {
-        return m_status;
-    }
-
-    OnAddEventsChanged() : m_result(false) {
-    }
-    ~OnAddEventsChanged() {
-    }
-
-    private:
-    CalendarEventPtr m_event;
-    EventAddStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnAddEventsChanged> OnAddEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnAddEventsChanged> OnAddEventsChangedEmitter;
-typedef DPL::SharedPtr<OnAddEventsChangedEmitter> OnAddEventsChangedEmitterPtr;
-
-}
-}
-}
-
-#endif //_ON_ADD_EVENTS_CHANGED_H_
diff --git a/src/platform/API/Calendar/OnDeleteEventsChanged.h b/src/platform/API/Calendar/OnDeleteEventsChanged.h
deleted file mode 100755 (executable)
index f639642..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ON_DELETE_EVENTS_CHANGED_H_
-#define _ON_DELETE_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-#include "EventId.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class OnDeleteEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnDeleteEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_DELETE_SUCCESS,
-               EVENT_DELETE_FAIL
-    } EventDeleteStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEventId(EventIdPtr value) {
-        m_eventId = value;
-    }
-    EventIdPtr getEventId() const {
-        return m_eventId;
-    }
-
-    void setStatus(EventDeleteStatus value) {
-        m_status = value;
-    }
-    EventDeleteStatus getStatus() const {
-        return m_status;
-    }
-
-    OnDeleteEventsChanged() : m_result(false) {
-    }
-    ~OnDeleteEventsChanged() {
-    }
-
-    private:
-    EventIdPtr m_eventId;
-    EventDeleteStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnDeleteEventsChanged> OnDeleteEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnDeleteEventsChanged> OnDeleteEventsChangedEmitter;
-typedef DPL::SharedPtr<OnDeleteEventsChangedEmitter> OnDeleteEventsChangedEmitterPtr;
-
-}
-}
-}
-
-#endif //_ON_DELETE_EVENTS_CHANGED_H_
diff --git a/src/platform/API/Calendar/OnUpdateEventsChanged.h b/src/platform/API/Calendar/OnUpdateEventsChanged.h
deleted file mode 100755 (executable)
index 855f94f..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _ON_UPDATE_EVENTS_CHANGED_H_
-#define _ON_UPDATE_EVENTS_CHANGED_H_
-
-#include <vector>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <Commons/ListenerEvent.h>
-#include <Commons/ListenerEventEmitter.h>
-#include "CalendarEvent.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Calendar {
-
-class OnUpdateEventsChanged : public WrtDeviceApis::Commons::ListenerEvent<OnUpdateEventsChanged>
-{
-    public:
-    typedef enum
-    {
-               SUCCESS_ALL,
-               FAIL_ALL,
-               EVENT_UPDATE_SUCCESS,
-               EVENT_UPDATE_FAIL
-    } EventUpdateStatus;
-
-    void setResult (bool value) {
-        m_result = value;
-    }  
-    bool getResult() const {
-        return m_result;
-    }
-
-    void setEvent(CalendarEventPtr value) {
-        m_event = value;
-    }
-    CalendarEventPtr getEvent() const {
-        return m_event;
-    }
-
-    void setStatus(EventUpdateStatus value) {
-        m_status = value;
-    }
-    EventUpdateStatus getStatus() const {
-        return m_status;
-    }
-
-    OnUpdateEventsChanged() : m_result(false) {
-    }
-    ~OnUpdateEventsChanged() {
-    }
-
-    private:
-    CalendarEventPtr m_event;
-    EventUpdateStatus m_status;
-    bool m_result;
-};
-
-typedef DPL::SharedPtr<OnUpdateEventsChanged> OnUpdateEventsChangedPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<OnUpdateEventsChanged> OnUpdateEventsChangedEmitter;
-typedef DPL::SharedPtr<OnUpdateEventsChangedEmitter> OnUpdateEventsChangedEmitterPtr;
-
-}
-}
-}
-
-#endif //_ON_UPDATE_EVENTS_CHANGED_H_
index 9227227..ec71ec2 100755 (executable)
@@ -2,13 +2,11 @@ get_current_path()
 set(SRCS_PLATFORM_API_CALENDAR
   ${CURRENT_PATH}/CalendarEvent.cpp
   ${CURRENT_PATH}/CalendarFactory.cpp
-  ${CURRENT_PATH}/EventFilter.cpp
   ${CURRENT_PATH}/ICalendar.cpp
   ${CURRENT_PATH}/ICalendarManager.cpp
   ${CURRENT_PATH}/EventAttendee.cpp
   ${CURRENT_PATH}/EventRecurrenceRule.cpp
   ${CURRENT_PATH}/EventId.cpp
   ${CURRENT_PATH}/EventAlarm.cpp
-  ${CURRENT_PATH}/CalendarItemGeo.cpp
   PARENT_SCOPE
 )
index c67fde7..793104a 100755 (executable)
@@ -38,7 +38,7 @@ namespace {
 
 #define STR_BASE_QUERY                 "SELECT id, log_type, related_id, number, log_time, data1 FROM phonelogs"
 
-#define STR_ENTRY_ID                   "entryId"
+#define STR_ENTRY_ID                   "uid"
 #define STR_SERVICE_ID                 "serviceId"
 #define STR_CALL_TYPE                  "callType"
 #define STR_TAGS                       "tags"
@@ -54,10 +54,10 @@ namespace {
 
 #define STR_REMOTE_PARTY               "remoteParty"
 #define STR_DISPLAY_NAME               "displayName"
-#define STR_CONTACT_ID                 "contactId"
+#define STR_CONTACT_REF                "contactRef"
 
 #define STR_RP_REMOTEPARTY             "remoteParties.remoteParty"
-#define STR_RP_CONTACTID               "remoteParties.contactId"
+#define STR_RP_CONTACTREF              "remoteParties.contactRef.contactId"
 
 #define STR_NUMBER                     "number"
 #define STR_LOG_TIME                   "log_time"
index 370f2d6..b422cd1 100755 (executable)
@@ -16,7 +16,6 @@
  
 #include "CallFactory.h"
 #include <Call/CallManager.h>
-#include <Call/CallService.h>
 
 namespace TizenApis {
 namespace Api {
@@ -34,12 +33,6 @@ ICallManagerPtr CallFactory::getCallObject()
        return result;
 }
 
-ICallServicePtr CallFactory::getCallServiceObject()
-{
-       ICallServicePtr result(new Platform::Call::CallService()); 
-       return result;
-}
-
 CallFactory::CallFactory()
 {
 }
index 1aa6fc7..8743a79 100755 (executable)
@@ -20,7 +20,6 @@
 
 #include <dpl/noncopyable.h>
 #include "ICallManager.h"
-#include "ICallService.h"
 
 namespace TizenApis {
 namespace Api {
@@ -33,7 +32,6 @@ protected:
 public:
        static CallFactory& getInstance();
        ICallManagerPtr getCallObject();
-       ICallServicePtr getCallServiceObject();
 };
 
 }
diff --git a/src/platform/API/Call/CallServiceFilter.cpp b/src/platform/API/Call/CallServiceFilter.cpp
deleted file mode 100755 (executable)
index d342b2a..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-#include "CallServiceFilter.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Call {
-CallServiceFilter::CallServiceFilter() :
-               m_callType(""),
-               m_serviceName(""),
-               m_providerId("")
-{
-       m_tags = StringArrayPtr(new StringArray());
-}
-
-void CallServiceFilter::setCallType(const std::string callType)
-{
-       m_callType = callType;
-}
-
-void CallServiceFilter::setTags(const StringArrayPtr tags)
-{
-       m_tags = tags;
-}
-
-void CallServiceFilter::setServiceName(const std::string serviceName)
-{
-       m_serviceName = serviceName;
-}
-
-void CallServiceFilter::setProviderId(const std::string providerId)
-{
-       m_providerId = providerId;
-}
-
-std::string CallServiceFilter::getCallType() const
-{
-       return m_callType;
-}
-
-StringArrayPtr CallServiceFilter::getTags() const
-{
-       return m_tags;
-}
-
-std::string CallServiceFilter::getServiceName() const
-{
-       return m_serviceName;
-}
-
-std::string CallServiceFilter::getProviderId() const
-{
-       return m_providerId;
-}
-
-}
-}
-}
diff --git a/src/platform/API/Call/CallServiceFilter.h b/src/platform/API/Call/CallServiceFilter.h
deleted file mode 100755 (executable)
index b3ab55a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_API_CALLSERVICE_FILTER_H_
-#define TIZENAPIS_API_CALLSERVICE_FILTER_H_
-
-#include <dpl/shared_ptr.h>
-#include <string>
-#include <vector>
-
-namespace TizenApis {
-namespace Api {
-namespace Call {
-class CallServiceFilter;
-typedef DPL::SharedPtr<CallServiceFilter> CallServiceFilterPtr;
-typedef std::vector<std::string> StringArray;
-typedef DPL::SharedPtr<StringArray> StringArrayPtr;
-
-class CallServiceFilter
-{
-private:
-       std::string m_callType;
-       StringArrayPtr m_tags;
-       std::string m_serviceName;
-       std::string m_providerId;
-
-public:
-       void setCallType(const std::string callType);
-       void setTags(const StringArrayPtr tags);
-       void setServiceName(const std::string serviceName);
-       void setProviderId(const std::string providerId);
-
-       std::string getCallType() const;
-       StringArrayPtr getTags() const;
-       std::string getServiceName() const;
-       std::string getProviderId() const;
-       
-       CallServiceFilter();
-};
-}
-}
-}
-
-#endif
\ No newline at end of file
diff --git a/src/platform/API/Call/EventGetCallService.h b/src/platform/API/Call/EventGetCallService.h
deleted file mode 100755 (executable)
index 3e5ce1f..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_API_CALL_EVENT_GET_CALL_SERVICE_H_
-#define TIZENAPIS_API_CALL_EVENT_GET_CALL_SERVICE_H_
-
-#include <string>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-#include <API/Account/AccountServices.h>
-#include "CallServiceFilter.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Call {
-class EventGetCallService : public WrtDeviceApis::Commons::IEvent<EventGetCallService>
-{
-private:
-       CallServiceFilterPtr m_filter;
-       Api::Account::AccountServicesArrayPtr m_result;
-
-public:
-       void setFilter(const CallServiceFilterPtr &filter);
-       void setResult(const Api::Account::AccountServicesArrayPtr &result);
-       CallServiceFilterPtr getFilter() const;
-       Api::Account::AccountServicesArrayPtr getResult() const;
-
-       EventGetCallService();
-};
-
-typedef DPL::SharedPtr<EventGetCallService> EventGetCallServicePtr;
-}
-}
-}
-
-#endif
\ No newline at end of file
index 29c1bde..0b2c3be 100755 (executable)
@@ -23,7 +23,6 @@ namespace Call {
 using namespace WrtDeviceApis::Commons;
 
 ICallManager::ICallManager()
-       :EventRequestReceiver<EventGetCallService>(ThreadEnum::TELEPHONY_THREAD)
 {
 }
 
index df6d516..bb5e661 100755 (executable)
@@ -21,7 +21,6 @@
 #include <vector>
 #include <dpl/shared_ptr.h>
 #include <Commons/ThreadPool.h>
-#include "EventGetCallService.h"
 
 namespace TizenApis {
 namespace Api {
@@ -31,7 +30,6 @@ typedef std::vector<std::string> StringList;
 typedef DPL::SharedPtr<StringList> StringListPtr;
 
 class ICallManager
-       :public WrtDeviceApis::Commons::EventRequestReceiver<EventGetCallService>
 {
 public:
        ICallManager();
@@ -43,14 +41,6 @@ public:
         * active, held, dialing, alerting, incoming, or waiting; otherwise false.
         */
        virtual bool isCallInProgress() = 0;
-
-       /**
-        * Synchronously get call services instances.
-        */
-       virtual void getCallService(const EventGetCallServicePtr& event) = 0;
-
-protected:
-       virtual void OnRequestReceived(const EventGetCallServicePtr& event) = 0;
 };
 
 typedef DPL::SharedPtr<ICallManager> ICallManagerPtr;
diff --git a/src/platform/API/Call/ICallService.h b/src/platform/API/Call/ICallService.h
deleted file mode 100755 (executable)
index b9cc86c..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#ifndef TIZENAPIS_API_ICALLSERVICE_H_
-#define TIZENAPIS_API_ICALLSERVICE_H_
-
-#include <string>
-#include <vector>
-#include <dpl/shared_ptr.h>
-#include <Commons/ThreadPool.h>
-#include "EventLaunchDialer.h"
-#include "EventSendUSSD.h"
-
-namespace TizenApis {
-namespace Api {
-namespace Call{
-
-typedef std::vector<std::string> StringList;
-typedef DPL::SharedPtr<StringList> StringListPtr;
-
-class ICallService :
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventLaunchDialer>,
-       public WrtDeviceApis::Commons::EventRequestReceiver<EventSendUSSD>
-{
-public:
-       ICallService();
-       virtual ~ICallService();
-
-       /**
-        * Asynchronously launches the native phone application for this call service with a pre-filled remote ID.
-        * The user still needs to press the call button to make the call.
-        */
-       virtual void launchDialer(const EventLaunchDialerPtr& event) = 0;
-
-       /**
-        * Send a USSD string to the network.
-        */
-       virtual void sendUSSD(const EventSendUSSDPtr& event) = 0;
-
-       /**
-        * Get voicemail numbers.
-        * @return A list of voicemail numbers.
-        */
-       virtual StringListPtr getVoicemailNumbers() = 0;
-
-       /**
-        * Get subscriber numbers.
-        * @return A list of subscriber numbers.
-        */
-       virtual StringListPtr getSubscriberNumbers() = 0;
-
-       /**
-        * Get emergency numbers.
-        * @return A list of emergency numbers.
-        */
-       virtual StringListPtr getEmergencyNumbers() = 0;
-
-protected:
-       virtual void OnRequestReceived(const EventLaunchDialerPtr& event) = 0;
-
-       virtual void OnRequestReceived(const EventSendUSSDPtr& event) = 0;
-};
-
-typedef DPL::SharedPtr<ICallService> ICallServicePtr;
-
-}
-}
-}
-
-#endif
index ff57efc..1772a9f 100755 (executable)
@@ -21,9 +21,9 @@ namespace Api {
 namespace Call {
 RemoteParty::RemoteParty() :
                m_remoteParty(""),
-               m_displayName(""),
-               m_contactId("")
+               m_displayName("")
 {
+       m_contactRef = Api::Contact::ContactRefPtr(new Api::Contact::ContactRef());
 }
 
 void RemoteParty::setRemoteParty(const std::string remoteParty)
@@ -36,9 +36,9 @@ void RemoteParty::setDisplayName(const std::string displayName)
        m_displayName = displayName;
 }
 
-void RemoteParty::setContactId(const std::string contactId)
+void RemoteParty::setContactRef(const Api::Contact::ContactRefPtr &contactRef)
 {
-       m_contactId = contactId;
+       m_contactRef = contactRef;
 }
 
 std::string RemoteParty::getRemoteParty() const
@@ -51,9 +51,9 @@ std::string RemoteParty::getDisplayName() const
        return m_displayName;
 }
 
-std::string RemoteParty::getContactId() const
+Api::Contact::ContactRefPtr RemoteParty::getContactRef() const
 {
-       return m_contactId;
+       return m_contactRef;
 }
 
 }
index 6257c3d..e8d3dca 100755 (executable)
@@ -21,6 +21,7 @@
 #include <dpl/shared_ptr.h>
 #include <string>
 #include <vector>
+#include <API/Contact/ContactRef.h>
 
 namespace TizenApis {
 namespace Api {
@@ -35,16 +36,16 @@ class RemoteParty
 private:
        std::string m_remoteParty;
        std::string m_displayName;
-       std::string m_contactId;
+       Api::Contact::ContactRefPtr m_contactRef;
 
 public:
        void setRemoteParty(const std::string remoteParty);
        void setDisplayName(const std::string displayName);
-       void setContactId(const std::string contactId);
+       void setContactRef(const Api::Contact::ContactRefPtr &contactRef);
 
        std::string getRemoteParty() const;
        std::string getDisplayName() const;
-       std::string getContactId() const;
+       Api::Contact::ContactRefPtr getContactRef() const;
        
        RemoteParty();
 };
index fe16aab..e082169 100755 (executable)
@@ -3,19 +3,13 @@ set(SRCS_PLATFORM_API_CALL
   ${CURRENT_PATH}/CallFactory.cpp
   ${CURRENT_PATH}/CallHistoryEntryProperties.cpp
   ${CURRENT_PATH}/CallHistoryFactory.cpp
-  ${CURRENT_PATH}/CallServiceFilter.cpp
-  ${CURRENT_PATH}/CallServiceObject.cpp
   ${CURRENT_PATH}/EventCallHistoryListener.cpp
   ${CURRENT_PATH}/EventFindCallHistory.cpp
-  ${CURRENT_PATH}/EventGetCallService.cpp
-  ${CURRENT_PATH}/EventLaunchDialer.cpp
   ${CURRENT_PATH}/EventRemoveAll.cpp
   ${CURRENT_PATH}/EventRemoveBatch.cpp
-  ${CURRENT_PATH}/EventSendUSSD.cpp
   ${CURRENT_PATH}/ICallHistory.cpp
   ${CURRENT_PATH}/ICallHistoryEntry.cpp
   ${CURRENT_PATH}/ICallManager.cpp
-  ${CURRENT_PATH}/ICallService.cpp
   ${CURRENT_PATH}/RemoteParty.cpp
   PARENT_SCOPE
 )
index 6cb171b..9266a66 100755 (executable)
@@ -49,12 +49,6 @@ ContactPtr ContactFactory::createContact()
        return result;
 }
 
-ContactPtr ContactFactory::createContact(const std::string &vObjectStr, const std::string &format)
-{
-       ContactPtr result(new TizenApis::Platform::Contact::Contact(vObjectStr, format));
-       return result;
-}
-
 } // Contact
 } // Api
 } // TizenApis
index d1ecd00..b36153f 100755 (executable)
@@ -43,7 +43,6 @@ public:
        static ContactFactory&  getInstance();
        IContactManagerPtr      createContactManager();
        ContactPtr              createContact();
-       ContactPtr              createContact(const std::string &vObjectStr, const std::string &format);
 };
 
 } // Contact
diff --git a/src/platform/API/Contact/EventAddressBookAdd.h b/src/platform/API/Contact/EventAddressBookAdd.h
new file mode 100755 (executable)
index 0000000..551a984
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookAdd.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IContact.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookAdd : public WrtDeviceApis::Commons::IEvent<EventAddressBookAdd>
+{
+private:
+       bool m_result;
+
+       /* parameters */
+       ContactPtr      m_contact;
+
+       bool m_contactIsSet;
+
+public:
+       EventAddressBookAdd() :
+               m_result(false),
+               m_contactIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookAdd()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       ContactPtr getContact() const
+       {
+               return m_contact;
+       }
+
+       void setContact(const ContactPtr &value)
+       {
+               m_contact = value;
+               m_contactIsSet = true;
+       }
+
+       bool getContactIsSet() const
+       {
+               return m_contactIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookAdd> EventAddressBookAddPtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_H_
+
diff --git a/src/platform/API/Contact/EventAddressBookAddChangeListener.h b/src/platform/API/Contact/EventAddressBookAddChangeListener.h
new file mode 100755 (executable)
index 0000000..df550e1
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookAddChangeListener.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_CHANGE_LISTENER_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_CHANGE_LISTENER_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "EventAddressBookChangeListener.h"
+#include "IContact.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookAddChangeListener : public WrtDeviceApis::Commons::IEvent<EventAddressBookAddChangeListener>
+{
+private:
+       bool m_result;
+
+       /* result */
+       long m_id;
+
+       bool m_idIsSet;
+
+       /* parameters */
+       EventAddressBookChangeListenerEmitterPtr m_emitter;
+
+       bool m_emitterIsSet;
+
+public:
+       EventAddressBookAddChangeListener() :
+               m_result(false),
+               m_id(0),
+               m_idIsSet(false),
+               m_emitterIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookAddChangeListener()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       void setEmitter(EventAddressBookChangeListenerEmitterPtr &value)
+       {
+               m_emitter = value;
+               m_emitterIsSet = true;
+       }
+
+       EventAddressBookChangeListenerEmitterPtr getEmitter() const
+       {
+               return m_emitter;
+       }
+
+       bool getEmitterIsSet() const
+       {
+               return m_emitterIsSet;
+       }
+
+       long getId() const
+       {
+               return m_id;
+       }
+
+       void setId(const long value)
+       {
+               m_id = value;
+               m_idIsSet = true;
+       }
+
+       bool getIdIsSet() const
+       {
+               return m_idIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookAddChangeListener> EventAddressBookAddChangeListenerPtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_ADD_CHANGE_LISTENER_H_
diff --git a/src/platform/API/Contact/EventAddressBookGet.h b/src/platform/API/Contact/EventAddressBookGet.h
new file mode 100755 (executable)
index 0000000..a741f5d
--- /dev/null
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookGet.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_GET_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_GET_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IContact.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookGet : public WrtDeviceApis::Commons::IEvent<EventAddressBookGet>
+{
+private:
+       bool m_result;
+
+       /* result */
+       ContactPtr m_contact;
+
+       bool m_contactIsSet;
+
+       /* parameters */
+       std::string     m_id;
+
+       bool m_idIsSet;
+
+public:
+       EventAddressBookGet() :
+               m_result(false),
+               m_contact(NULL),
+               m_contactIsSet(false),
+               m_idIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookGet()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       std::string getId() const
+       {
+               return m_id;
+       }
+
+       void setId(const std::string value)
+       {
+               m_id = value;
+               m_idIsSet = true;
+       }
+
+       bool getIdIsSet() const
+       {
+               return m_idIsSet;
+       }
+
+       void setContact(ContactPtr &value)
+       {
+               m_contact = value;
+               m_contactIsSet = true;
+       }
+
+       ContactPtr getContact() const
+       {
+               return m_contact;
+       }
+
+       bool getContactIsSet() const
+       {
+               return m_contactIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookGet> EventAddressBookGetPtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_GET_H_
diff --git a/src/platform/API/Contact/EventAddressBookRemove.h b/src/platform/API/Contact/EventAddressBookRemove.h
new file mode 100755 (executable)
index 0000000..2314a0f
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookRemove.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookRemove : public WrtDeviceApis::Commons::IEvent<EventAddressBookRemove>
+{
+private:
+       bool    m_result;
+
+       /* parameters */
+       std::string     m_contactId;
+
+       bool    m_contactIdIsSet;
+
+public:
+       EventAddressBookRemove() :
+               m_result(false),
+               m_contactIdIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookRemove()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       std::string getContactId() const
+       {
+               return m_contactId;
+       }
+
+       void setContactId(const std::string value)
+       {
+               m_contactIdIsSet = true;
+               m_contactId = value;
+       }
+
+       bool getContactIdIsSet() const
+       {
+               return m_contactIdIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookRemove> EventAddressBookRemovePtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_H_
+
diff --git a/src/platform/API/Contact/EventAddressBookRemoveChangeListener.h b/src/platform/API/Contact/EventAddressBookRemoveChangeListener.h
new file mode 100755 (executable)
index 0000000..9a1bcdf
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookRemoveChangeListener.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IContact.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookRemoveChangeListener : public WrtDeviceApis::Commons::IEvent<EventAddressBookRemoveChangeListener>
+{
+private:
+       bool m_result;
+
+       /* parameters */
+
+       /* result */
+       long m_id;
+
+       bool m_idIsSet;
+
+public:
+       EventAddressBookRemoveChangeListener() :
+               m_result(false),
+               m_id(0),
+               m_idIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookRemoveChangeListener()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       long getId() const
+       {
+               return m_id;
+       }
+
+       void setId(const long value)
+       {
+               m_id = value;
+               m_idIsSet = true;
+       }
+
+       bool getIdIsSet() const
+       {
+               return m_idIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookRemoveChangeListener> EventAddressBookRemoveChangeListenerPtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_REMOVE_CHANGE_LISTENER_H_
diff --git a/src/platform/API/Contact/EventAddressBookUpdate.h b/src/platform/API/Contact/EventAddressBookUpdate.h
new file mode 100755 (executable)
index 0000000..bd2cccc
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file        EventAddressBookUpdate.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _API_CONTACT_EVENT_ADDRESS_BOOK_UPDATE_H_
+#define _API_CONTACT_EVENT_ADDRESS_BOOK_UPDATE_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include "IContact.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Contact {
+
+class EventAddressBookUpdate : public WrtDeviceApis::Commons::IEvent<EventAddressBookUpdate>
+{
+private:
+       bool m_result;
+
+       /* parameters */
+       ContactPtr      m_contact;
+
+       bool m_contactIsSet;
+
+public:
+       EventAddressBookUpdate() :
+               m_result(false),
+               m_contactIsSet(false)
+       {
+       }
+
+       virtual ~EventAddressBookUpdate()
+       {
+       }
+
+       virtual void clearOnCancel()
+       {
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getResult() const
+       {
+               return m_result;
+       }
+
+       ContactPtr getContact() const
+       {
+               return m_contact;
+       }
+
+       void setContact(const ContactPtr &value)
+       {
+               m_contact = value;
+               m_contactIsSet = true;
+       }
+
+       bool getContactIsSet() const
+       {
+               return m_contactIsSet;
+       }
+};
+
+typedef DPL::SharedPtr<EventAddressBookUpdate> EventAddressBookUpdatePtr;
+
+} // Contact
+} // Api
+} // TizenApis
+
+#endif // _API_CONTACT_EVENT_ADDRESS_BOOK_UPDATE_H_
+
index ed623d6..2677e57 100755 (executable)
@@ -32,10 +32,16 @@ using namespace WrtDeviceApis::Commons;
 
 IAddressBook::IAddressBook(AddressBookType type) :
        //initialize all receivers to work on CONTACT_THREAD thread
+       EventRequestReceiver< EventAddressBookGet >(ThreadEnum::CONTACT_THREAD),
+       EventRequestReceiver< EventAddressBookAdd >(ThreadEnum::CONTACT_THREAD),
        EventRequestReceiver< EventAddressBookAddBatch >(ThreadEnum::CONTACT_THREAD),
+       EventRequestReceiver< EventAddressBookUpdate >(ThreadEnum::CONTACT_THREAD),
        EventRequestReceiver< EventAddressBookUpdateBatch >(ThreadEnum::CONTACT_THREAD),
+       EventRequestReceiver< EventAddressBookRemove >(ThreadEnum::CONTACT_THREAD),
        EventRequestReceiver< EventAddressBookRemoveBatch >(ThreadEnum::CONTACT_THREAD),
        EventRequestReceiver< EventAddressBookFind >(ThreadEnum::CONTACT_THREAD),
+       EventRequestReceiver< EventAddressBookAddChangeListener >(ThreadEnum::CONTACT_THREAD),
+       EventRequestReceiver< EventAddressBookRemoveChangeListener >(ThreadEnum::CONTACT_THREAD),
        m_bookType(type)
 {
        //Nothing to do
@@ -54,18 +60,42 @@ IAddressBook::AddressBookType IAddressBook::getType() const
        return m_bookType;
 }
 
+void IAddressBook::get(const EventAddressBookGetPtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookGet >::PostRequest(event);
+}
+
+void IAddressBook::add(const EventAddressBookAddPtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookAdd >::PostRequest(event);
+}
+
 void IAddressBook::addBatch(const EventAddressBookAddBatchPtr &event)
 {
        //post event to PLATFORM implementation
        EventRequestReceiver< EventAddressBookAddBatch >::PostRequest(event);
 }
 
+void IAddressBook::update(const EventAddressBookUpdatePtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookUpdate >::PostRequest(event);
+}
+
 void IAddressBook::updateBatch(const EventAddressBookUpdateBatchPtr &event)
 {
        //post event to PLATFORM implementation
        EventRequestReceiver< EventAddressBookUpdateBatch >::PostRequest(event);
 }
 
+void IAddressBook::remove(const EventAddressBookRemovePtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookRemove >::PostRequest(event);
+}
+
 void IAddressBook::removeBatch(const EventAddressBookRemoveBatchPtr &event)
 {
        //post event to PLATFORM implementation
@@ -78,6 +108,18 @@ void IAddressBook::find(const EventAddressBookFindPtr &event)
        EventRequestReceiver< EventAddressBookFind >::PostRequest(event);
 }
 
+void IAddressBook::addChangeListener(const EventAddressBookAddChangeListenerPtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookAddChangeListener >::PostRequest(event);
+}
+
+void IAddressBook::removeChangeListener(const EventAddressBookRemoveChangeListenerPtr &event)
+{
+       //post event to PLATFORM implementation
+       EventRequestReceiver< EventAddressBookRemoveChangeListener >::PostRequest(event);
+}
+
 } // Contact
 } // Api
 } // TizenApis
index 4340ddc..b8ea1af 100755 (executable)
 #include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include <Commons/EventReceiver.h>
+#include "EventAddressBookGet.h"
+#include "EventAddressBookAdd.h"
 #include "EventAddressBookAddBatch.h"
+#include "EventAddressBookUpdate.h"
 #include "EventAddressBookUpdateBatch.h"
+#include "EventAddressBookRemove.h"
 #include "EventAddressBookRemoveBatch.h"
 #include "EventAddressBookFind.h"
-#include "EventAddressBookChangeListener.h"
+#include "EventAddressBookAddChangeListener.h"
+#include "EventAddressBookRemoveChangeListener.h"
 #include "IContactEventPrivateData.h"
 
 namespace TizenApis {
@@ -47,10 +52,16 @@ typedef std::vector<AddressBookPtr> AddressBookArray;
 typedef DPL::SharedPtr<AddressBookArray> AddressBookArrayPtr;
 
 class IAddressBook :
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookGet >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookAdd >,
        public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookAddBatch >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookUpdate >,
        public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookUpdateBatch >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookRemove >,
        public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookRemoveBatch >,
        public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookFind >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookAddChangeListener >,
+       public WrtDeviceApis::Commons::EventRequestReceiver< EventAddressBookRemoveChangeListener >,
        public IContactEventPrivateData
 {
 public:
@@ -63,17 +74,16 @@ public:
        explicit IAddressBook(AddressBookType type);
        virtual ~IAddressBook();
 
-       virtual ContactPtr get(const std::string &contactId) = 0;
-       virtual void add(const ContactPtr &contact) = 0;
+       virtual void get(const EventAddressBookGetPtr &event);
+       virtual void add(const EventAddressBookAddPtr &event);
        virtual void addBatch(const EventAddressBookAddBatchPtr &event);
-       virtual void update(const ContactPtr &contact) = 0;
+       virtual void update(const EventAddressBookUpdatePtr &event);
        virtual void updateBatch(const EventAddressBookUpdateBatchPtr &event);
-       virtual void remove(const std::string &id) = 0;
+       virtual void remove(const EventAddressBookRemovePtr &event);
        virtual void removeBatch(const EventAddressBookRemoveBatchPtr &event);
        virtual void find(const EventAddressBookFindPtr &event);
-
-       virtual long addChangeListener(const EventAddressBookChangeListenerEmitterPtr &emitter) = 0;
-       virtual void removeChangeListener(const long watchId) = 0;
+       virtual void addChangeListener(const EventAddressBookAddChangeListenerPtr &event);
+       virtual void removeChangeListener(const EventAddressBookRemoveChangeListenerPtr &event);
 
        virtual AddressBookType    getType() const;
        virtual std::string getId() const = 0;
@@ -86,10 +96,16 @@ public:
 protected:
        AddressBookType m_bookType;
 
+       virtual void    OnRequestReceived(const EventAddressBookGetPtr &event) = 0;
+       virtual void    OnRequestReceived(const EventAddressBookAddPtr &event) = 0;
        virtual void    OnRequestReceived(const EventAddressBookAddBatchPtr &event) = 0;
+       virtual void    OnRequestReceived(const EventAddressBookUpdatePtr &event) = 0;
        virtual void    OnRequestReceived(const EventAddressBookUpdateBatchPtr &event) = 0;
+       virtual void    OnRequestReceived(const EventAddressBookRemovePtr &event) = 0;
        virtual void    OnRequestReceived(const EventAddressBookRemoveBatchPtr &event) = 0;
        virtual void    OnRequestReceived(const EventAddressBookFindPtr &event) = 0;
+       virtual void    OnRequestReceived(const EventAddressBookAddChangeListenerPtr &event) = 0;
+       virtual void    OnRequestReceived(const EventAddressBookRemoveChangeListenerPtr &event) = 0;
 };
 
 } // Contact
index bbc9bb4..f1b049d 100755 (executable)
@@ -53,30 +53,6 @@ IContact::IContact() :
        m_categories = StringArrayPtr(new StringArray());
 }
 
-IContact::IContact(const std::string &vObjectStr, const std::string &format) :
-               m_isFavorite(false),
-               m_idIsSet(false),
-               m_lastUpdatedIsSet(false),
-               m_nameIsSet(false),
-               m_accountIsSet(false),
-               m_photoURIIsSet(false),
-               m_birthdayIsSet(false),
-               m_organizationIsSet(false),
-               m_ringtoneURIIsSet(false)
-{
-       m_name = ContactNamePtr(new ContactName());
-       m_account = ContactAccountPtr(new ContactAccount());
-       m_addresses = ContactAddressArrayPtr(new ContactAddressArray());
-       m_phoneNumbers = ContactPhoneNumberArrayPtr(new ContactPhoneNumberArray());
-       m_emails = ContactEmailAddressArrayPtr(new ContactEmailAddressArray());
-       m_birthday = {0, };
-       m_anniversaries = ContactAnniversaryArrayPtr(new ContactAnniversaryArray());
-       m_organization = ContactOrganizationPtr(new ContactOrganization());
-       m_notes = StringArrayPtr(new StringArray());
-       m_urls = ContactWebSiteArrayPtr(new ContactWebSiteArray());
-       m_categories = StringArrayPtr(new StringArray());
-}
-
 IContact::~IContact()
 {
 }
index d137ce8..de6805d 100755 (executable)
@@ -30,6 +30,7 @@
 #include <vector>
 #include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
+#include <dpl/enable_shared_from_this.h>
 #include "ContactTypes.h"
 #include "ContactName.h"
 #include "ContactAccount.h"
@@ -50,14 +51,14 @@ typedef DPL::SharedPtr<IContact> ContactPtr;
 typedef std::vector<ContactPtr> ContactArray;
 typedef DPL::SharedPtr<ContactArray> ContactArrayPtr;
 
-class IContact
+class IContact : public DPL::EnableSharedFromThis<IContact>
 {
 public:
        IContact();
-       IContact(const std::string &vObjectStr, const std::string &format);
        virtual ~IContact();
 
        virtual std::string convertToString(const std::string &format) = 0;
+       virtual void setContactFromString(const std::string &vObjectStr, const std::string &format) = 0;
 
        std::string getId() const;
        void setId(const std::string value);
index db09924..f461008 100755 (executable)
@@ -18,6 +18,7 @@
 #include "EventListNodes.h"
 #include <dpl/assert.h>
 #include "INode.h"
+#include "Enums.h"
 
 namespace TizenApis {
 namespace Api {
@@ -51,6 +52,8 @@ void EventListNodes::setResult(const NodeList& list)
 {
     m_list = list;
 }
+
+
 } // Filesystem
 } // Api
 } // TizenApis
\ No newline at end of file
index f018dfe..171b609 100644 (file)
@@ -26,6 +26,8 @@
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include "AnyType.h"
+#include <Tizen/TimeUtil/TimeUtilConverter.h>
+#include <Tizen/TimeUtil/JSTZDate.h>
 
 namespace TizenApis {
 namespace Api {
@@ -300,6 +302,14 @@ AnyPtr AnyTypeConverter::toAny(const JSValueRef &value)
        {
                if(isDate(value))
                        return AnyPtr(new Any(Converter::toDateTm(value), toString(json.get())));
+               else if(JSValueIsObjectOfClass(m_context, value, TizenApis::Tizen1_0::JSTZDate::getClassRef()))
+               {
+                       TizenApis::Tizen1_0::TimeUtilConverter timeConverter(m_context);
+                       std::tm tmValue = timeConverter.toTZDateTime(value);
+                       std::stringstream ss;
+                       ss<<mktime(&tmValue);
+                       return AnyPtr(new Any(tmValue, ss.str()));
+               }
                else
                {
                        void *priv = NULL;
index ee823d6..dce0b00 100644 (file)
@@ -70,7 +70,7 @@ enum PrimitiveType {
                                                                _PT_LONG | _PT_ULONG),
        PrimitiveType_Any               = (_PT_BOOLEAN | _PT_CHAR | _PT_UCHAR | _PT_INT |
                                                                _PT_UINT | _PT_LONG | _PT_ULONG | _PT_DOUBLE |
-                                                               _PT_STRING | _PT_TIME | _PT_OBJECT )
+                                                               _PT_STRING | _PT_TIME | _PT_OBJECT)
 };
 
 class Any
index 51ff86e..527941b 100644 (file)
@@ -53,6 +53,9 @@ bool FilterValidator::validateAttribute(std::string& attrName,
 
        PropertyPtr prop = m_properties[attrName];
 
+       if(matchFlag == MATCH_EXISTS)
+               return true;
+
        if(!matchValue->isType(prop->type))
                return false;
 
diff --git a/src/platform/API/Geocoder/EventGeocoder.h b/src/platform/API/Geocoder/EventGeocoder.h
deleted file mode 100644 (file)
index 3b62146..0000000
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-/*
- * @author
- */
-
-#ifndef WRTPLUGINS_API_GEOLOCATION_EVENT_GEOCODER_H_
-#define WRTPLUGINS_API_GEOLOCATION_EVENT_GEOCODER_H_
-
-#include "GeocoderProperties.h"
-
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Tizen1_0{
-namespace Api {
-namespace Geocoder {
-
-class EventGeocoder: public WrtDeviceApis::Commons::IEvent<EventGeocoder> {
-public:
-       static const int GEOCODER_EVENT_UNKNOWN         = -1;
-       static const int GEOCODER_EVENT_GET_POSITION    = 1;
-       static const int GEOCODER_EVENT_GET_ADDRESS     = 2;
-
-private:
-       GeocoderProperties m_props;
-       int m_eventType;
-
-       std::string m_addressString;
-
-public:
-       void setLatitude(double latitude) {
-               m_props.latitude = latitude;
-       }
-       void setLongitude(double longitude) {
-               m_props.longitude = longitude;
-       }
-       void setAltitude(double altitude) {
-               m_props.altitude = altitude;
-       }
-
-       void setCountry(const std::string& strCountry) {
-               m_props.strCountry = strCountry;
-       }
-
-       void setRegion(const std::string& strRegion) {
-               m_props.strRegion= strRegion;
-       }
-
-       void setCounty(const std::string& strCounty) {
-               m_props.strCounty = strCounty;
-       }
-
-       void setCity(const std::string& strCity) {
-               m_props.strCity = strCity;
-       }
-
-       void setStreet(const std::string& strStreet) {
-               m_props.strStreet = strStreet;
-       }
-
-       void setStreetNumber(const std::string& strStreetNumber) {
-               m_props.strStreetNumber = strStreetNumber;
-       }
-
-       void setPremises(const std::string& strPremises) {
-               m_props.strPremises = strPremises;
-       }
-
-       void setAdditionalInformation(const std::string& strAdditionalInformation) {
-               m_props.strAdditionalInformation= strAdditionalInformation;
-       }
-
-       void setPostalCode(const std::string& strPostalCode) {
-               m_props.strPostalCode = strPostalCode;
-       }
-
-       double getLatitude() const {
-               return m_props.latitude;
-       }
-       double getLongitude() const {
-               return m_props.longitude;
-       }
-       double getAltitude() const {
-               return m_props.altitude;
-       }
-
-       std::string getCountry() const {
-               return m_props.strCountry;
-       }
-
-       std::string getRegion() const {
-               return m_props.strRegion;
-       }
-
-       std::string getCounty() const {
-               return m_props.strCounty;
-       }
-
-       std::string getCity() const {
-               return m_props.strCity;
-       }
-
-       std::string getStreet() const {
-               return m_props.strStreet;
-       }
-
-       std::string getStreetNumber() const {
-               return m_props.strStreetNumber;
-       }
-
-       std::string getPremises() const {
-               return m_props.strPremises;
-       }
-
-       std::string getAdditionalInformation() const {
-               return m_props.strAdditionalInformation;
-       }
-
-       std::string getPostalCode() const {
-               return m_props.strPostalCode;
-       }
-
-       void setAddressString(std::string& addressString){
-               m_addressString = addressString;
-       }
-
-       std::string getAddressString() const {
-               if(m_addressString.empty() != true){
-                       return m_addressString;
-               }else{
-                       std::string strAddress;
-                       strAddress.append(getCountry());
-                       strAddress.append(" ");
-                       strAddress.append(getRegion());
-                       strAddress.append(" ");
-                       strAddress.append(getCounty());
-                       strAddress.append(" ");
-                       strAddress.append(getCity());
-                       strAddress.append(" ");
-                       strAddress.append(getStreet());
-                       strAddress.append(" ");
-                       strAddress.append(getStreetNumber());
-                       strAddress.append(" ");
-                       strAddress.append(getPostalCode());
-                       strAddress.append(" ");
-                       strAddress.append(getPremises());
-
-                       return strAddress;
-               }
-       }
-
-       void setEventType(int type){
-               m_eventType = type;
-       }
-
-       int getEventType(){
-               return m_eventType;
-       }
-
-       GeocoderProperties getGeocoderProperties() const {
-               return m_props;
-       }
-
-       EventGeocoder() {
-               m_props.altitude    = 0;
-               m_props.latitude    = 0;
-               m_props.longitude   = 0;
-
-               m_props.strCountry               =  "";
-               m_props.strRegion                =  "";
-               m_props.strCounty                =  "";
-               m_props.strCity                  =  "";
-               m_props.strStreet                =  "";
-               m_props.strStreetNumber          =  "";
-               m_props.strPremises              =  "";
-               m_props.strAdditionalInformation =  "";
-
-               m_eventType = GEOCODER_EVENT_UNKNOWN;
-       }
-};
-
-typedef DPL::SharedPtr<EventGeocoder> EventGeocoderPtr;
-
-} // Geocoder
-} // Api
-}
-} // TizenApis
-
-#endif //WRTPLUGINS_API_GEOLOCATION_EVENT_GEOCODER_H_
diff --git a/src/platform/API/Geocoder/GeocoderProperties.h b/src/platform/API/Geocoder/GeocoderProperties.h
deleted file mode 100644 (file)
index 7400204..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @author
- */
-
-#ifndef WRTPLUGINS_API_GEOCODER_PROPERTIES_H_
-#define WRTPLUGINS_API_GEOCODER_PROPERTIES_H_
-
-#include <dpl/shared_ptr.h>
-#include <string>
-
-using namespace std;
-
-namespace TizenApis {
-namespace Tizen1_0{
-namespace Api {
-namespace Geocoder {
-
-struct GeocoderProperties {
-    double latitude;
-    double longitude;
-    double altitude;
-       double accuracy;
-       double altitudeAccuracy;
-       double heading;
-       double speed;
-
-       std::string strCountry;
-       std::string strRegion;
-       std::string strCounty;
-       std::string strCity;
-       std::string strStreet;
-       std::string strStreetNumber;
-       std::string strPremises;
-       std::string strAdditionalInformation;
-       std::string strPostalCode;
-
-//     std::string strCountryCode;
-//     std::string strState;
-//     std::string strDistrict;
-//     std::string strBuildingNumber;
-       GeocoderProperties() : latitude(0), longitude(0), altitude(0), accuracy(0), altitudeAccuracy(0),
-                       heading(0), speed(0){
-       }
-};
-
-typedef DPL::SharedPtr<GeocoderProperties> GeocoderPropertiesPtr;
-
-} // Geocoder
-} // Api
-}
-} // WrtPlugins
-
-#endif //WRTPLUGINS_API_GEOCODER_PROPERTIES_H_
diff --git a/src/platform/API/Geocoder/IGeocoder.h b/src/platform/API/Geocoder/IGeocoder.h
deleted file mode 100644 (file)
index b34165c..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @author
- */
-
-#ifndef WRTPLUGINS_API_IGEOCODER_H_
-#define WRTPLUGINS_API_IGEOCODER_H_
-
-#include "EventGeocoder.h"
-
-#include <dpl/shared_ptr.h>
-#include <Commons/ThreadPool.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Api {
-namespace Geocoder {
-
-class EventGeocoder;
-typedef DPL::SharedPtr<EventGeocoder> EventGeocoderPtr;
-
-class IGeocoder: public WrtDeviceApis::Commons::EventRequestReceiver<EventGeocoder> {
-public:
-
-       virtual ~IGeocoder();
-
-//     /**
-//      * Gets address from position
-//      * @param event @see WrtPlugins::Api::Geocoder::EventGeocoder.
-//      * @exception Commons::PlatformException when platform error occurs
-//      */
-       virtual void getAddressFromPosition(const EventGeocoderPtr& event) = 0;
-
-       //      /**
-       //       * Gets address from position
-       //       * @param event @see WrtPlugins::Api::Geocoder::EventGeocoder.
-       //       * @exception Commons::PlatformException when platform error occurs
-       //       */
-       virtual void getPositionFromAddress(const EventGeocoderPtr& event) = 0;
-
-protected:
-       IGeocoder();
-
-       virtual void OnRequestReceived(const EventGeocoderPtr& event) = 0;
-};
-
-typedef DPL::SharedPtr<IGeocoder> IGeocoderPtr;
-
-}
-}
-}
-}
-
-#endif /* WRTPLUGINS_API_IGEOCODER_H_ */
diff --git a/src/platform/API/Geocoder/config.cmake b/src/platform/API/Geocoder/config.cmake
deleted file mode 100644 (file)
index 8936e30..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-get_current_path()
-set(SRCS_PLATFORM_API_GEOCODER
-  ${CURRENT_PATH}/GeocoderFactory.cpp
-  ${CURRENT_PATH}/IGeocoder.cpp
-  PARENT_SCOPE
-)
index 60e1e62..e6b9f4a 100644 (file)
@@ -44,6 +44,7 @@ class IEventBrowseFolder : public WrtDeviceApis::Commons::IEvent<IEventBrowseFol
                m_sortModesIsSet = false;
                m_limitIsSet = false;
                m_offsetIsSet = false;
+               m_folderIdIsSet = false;
 
        }
        
@@ -88,6 +89,7 @@ class IEventBrowseFolder : public WrtDeviceApis::Commons::IEvent<IEventBrowseFol
        void setFolderID(const string &value)
        {
                m_folderId = value;
+               m_folderIdIsSet = true;
        }
 
        string getFolderID()
@@ -120,6 +122,11 @@ class IEventBrowseFolder : public WrtDeviceApis::Commons::IEvent<IEventBrowseFol
        {
                return m_filterIsSet; 
        }
+
+       bool getFolderIdIsSet()const
+       {
+               return m_folderIdIsSet; 
+       }
        
        bool getSortModesIsSet()const
        {
@@ -155,6 +162,7 @@ class IEventBrowseFolder : public WrtDeviceApis::Commons::IEvent<IEventBrowseFol
        bool m_result;                                                                  //OUTPUT: operation result
        bool m_limitIsSet;
        bool m_offsetIsSet;
+       bool m_folderIdIsSet;
 
        unsigned long m_limit;
        unsigned long m_offset;
index 6de68a4..c73a414 100755 (executable)
@@ -27,7 +27,7 @@
 #include "AttachmentFactory.h"
 #include "Attachments.h"
 #include <Messaging/Attachment.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <WidgetDB/WidgetDBMgr.h>
 
 using namespace std;
@@ -53,7 +53,7 @@ const char* VPATH_WGT_PRIVATE_TEMP = "wgt-package-tmp";
 
 const char* COMMAND_NAME = "/bin/cp";
 const char* COMMAND_SWITCH_RECURSIVE = "-r";
-const char* COMMAND_SWITCH_FORCE = "-f";
+//const char* COMMAND_SWITCH_FORCE = "-f";
 
 }
 
@@ -98,8 +98,6 @@ std::string AttachmentFactory::getVirtualPathFromRealPath(JSContextRef context,
        const std::string& realpath)
 {
        LogDebug("path = " << realpath);        
-       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
 
        //find virtual root
        std::string root;
@@ -171,8 +169,9 @@ std::string AttachmentFactory::getVirtualPathFromRealPath(JSContextRef context,
                return virtualpath;
        }
 
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
        WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
 
        //wgt-package
        virtualrootpathposition = realpath.find(widgetDB->getWidgetInstallationPath());
@@ -213,8 +212,31 @@ std::string AttachmentFactory::getVirtualPathFromRealPath(JSContextRef context,
                return virtualpath;
        }
 
+       return "";
+       
+}
+
+std::string AttachmentFactory::getVirtualPathFromEmailServiceFolder(JSContextRef context, 
+               const std::string& realpath)
+{
+
        //another folder
        //copy
+       LogDebug("path = " << realpath);        
+
+       int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+
+      WidgetDB::Api::IWidgetDBPtr widgetDB =
+               WidgetDB::Api::getWidgetDB(widgetId);
+                       
+#if 0
+       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
+       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
+
+       WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+#endif
+
        size_t pos = realpath.find_last_of("/");
        if ((pos + 1) >= realpath.size()) {
            LogError("Problem with short name creation");
@@ -227,32 +249,43 @@ std::string AttachmentFactory::getVirtualPathFromRealPath(JSContextRef context,
                LogError("Problem with short name creation");
                Throw(InvalidArgumentException);
        }
-       
-     std::stringstream to_oss;
-               to_oss << "/email/" << attachShortName;
+
+       char buf[] = "/email/XXXXXX";
+       mkstemp(buf);
                
-       LogDebug("temp file=" << to_oss.str());
+       LogDebug("temp file=" << buf << AttachmentFactory::m_pathSeparator << attachShortName);
        
-       std::stringstream cp_oss;
-       cp_oss << COMMAND_NAME;
-       cp_oss << " " << COMMAND_SWITCH_RECURSIVE;
-       cp_oss << " \"" << realpath << "\"";
-       cp_oss << " \"" << privat_dir << to_oss.str() << "\"";
-
-       LogDebug("cp path=" << cp_oss.str());
+       std::stringstream cp_cmd;
+       cp_cmd << COMMAND_NAME;
+       cp_cmd << " " << COMMAND_SWITCH_RECURSIVE;
+       cp_cmd << " \"" << realpath << "\"";
+       cp_cmd << " \"" << privat_dir << buf  << AttachmentFactory::m_pathSeparator << attachShortName << "\"";
+       
+       LogDebug("cp path=" << cp_cmd.str());
+
+       int result = system(cp_cmd.str().c_str());
+       if (-1 != result) {
+               if (0 != WIFEXITED(result)) {
+                       if (0 != WEXITSTATUS(result)) {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Command failed.");
+                       }
+               } else {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Command terminated abnormally.");
+               }
+       } else {
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't launch command.");
+       }
        
        std::string vrootpath(VPATH_WGT_PRIVATE);
+       return vrootpath+ buf + AttachmentFactory::m_pathSeparator + attachShortName ;
        
-       return vrootpath+to_oss.str();
 }
 
-
 std::string AttachmentFactory::getRealPathFromVirtualPath(JSContextRef context, 
        const std::string& path)
 {
        LogDebug("path = " << path);    
-       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
 
        std::string root;
        std::string tail;
@@ -265,9 +298,10 @@ std::string AttachmentFactory::getRealPathFromVirtualPath(JSContextRef context,
        }
        LogDebug("root = " << root);
        LogDebug("tail = " << tail);
-       
+
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
        WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
 
        std::string realroot;
 
index a7693f8..e613628 100755 (executable)
@@ -56,6 +56,9 @@ class AttachmentFactory
     static std::string getVirtualPathFromRealPath(JSContextRef context, 
                const std::string& realpath);
 
+    static std::string getVirtualPathFromEmailServiceFolder(JSContextRef context, 
+               const std::string& realpath);
+
 private:       
     static const char m_pathSeparator;
 
index 1b8bc08..2f10c16 100755 (executable)
@@ -82,6 +82,8 @@ IAttachmentPtr Attachments::appendAttachment(const IMessagePtr& message, const s
        {
                iAttachment->setMessage(message);
        }
+
+       return iAttachment;
 }
 
 void Attachments::appendAttachment(const IMessagePtr& message, const IAttachmentPtr& attachment)
index 7689191..e6eacdd 100644 (file)
@@ -35,10 +35,32 @@ typedef DPL::SharedPtr<EventAddDraftMessage> EventAddDraftMessagePtr;
 class EventAddDraftMessage :
     public WrtDeviceApis::Commons::IEvent<EventAddDraftMessage>
 {
+  private:
+    long m_index;
+    int m_type;
+
   public:
+  EventAddDraftMessage() : m_index(-1), m_type(-1){
+  }
 
     IMessagePtr msg;
 
+    void setIndex(long index){
+        m_index = index;
+    }
+
+    long getIndex(){
+        return m_index;
+    }
+
+    void setType(int type){
+        m_type = type;
+    }
+
+    int getType(){
+        return m_type;
+    }  
+
     virtual void clearOnCancel()
     {
     }
index 320aec9..2f7af4f 100755 (executable)
@@ -42,6 +42,8 @@ private:
        Api::Tizen::FilterPtr m_filter;
        unsigned long m_limit;
        unsigned long m_offset;
+       long m_index;
+       int m_type;
        
   public:
        void setSortMode(Api::Tizen::SortModePtr sortMode) { m_sortMode = sortMode;}
@@ -57,6 +59,11 @@ private:
        std::vector<Api::Messaging::IConversationPtr> getConversations() { return m_conversations; }
        void setFilterUsing(bool filter) { m_FilterUse = filter;}
        bool isFilterUsing() { return m_FilterUse;}
+       void setIndex(long index){m_index = index;}
+       long getIndex(){return m_index;}
+       void setType(int type){m_type = type;}
+       int getType(){return m_type;}   
+
 
     virtual void clearOnCancel()
     {
index f3c76d5..82e85c6 100755 (executable)
@@ -44,6 +44,8 @@ class EventDeleteMessages :
 {
        private:
                Api::Tizen::FilterPtr m_filter;
+               long m_index;
+               int m_type;
   public:
 
     IMessagePtr msg;
@@ -57,6 +59,21 @@ class EventDeleteMessages :
                Api::Tizen::FilterPtr getFilter() {
                        return m_filter;
                }
+               void setIndex(long index){
+                       m_index = index;
+               }
+
+               long getIndex(){
+                       return m_index;
+               }
+
+               void setType(int type){
+                       m_type = type;
+               }
+
+               int getType(){
+                       return m_type;
+               }       
 
     virtual void clearOnCancel()
     {
index 4b6b9fd..fd8df00 100755 (executable)
@@ -41,7 +41,7 @@ private:
        int m_messagingServiceType;
      int m_eventType;
                
-     std::vector< IMessagingServicePtr > m_messagingService;
+     std::vector< IMessagingServicePtr > m_messagingServices;
        
 public:
        void setAccountID(long value) {
@@ -72,26 +72,26 @@ public:
                
        void setMessagingServicesRef(const std::vector< IMessagingServicePtr > &msgServices)
        {
-               m_messagingService = msgServices;
+               m_messagingServices = msgServices;
        }
 
        std::size_t getNumberOfMessagingService()
        {
-               return m_messagingService.size();
+               return m_messagingServices.size();
        }
                
        IMessagingServicePtr getMessagingService(std::size_t index)
        {
-               if (index >= m_messagingService.size() || m_messagingService.size() == 0) {
+               if (index >= m_messagingServices.size() || m_messagingServices.size() == 0) {
                        Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                }
                
-               return m_messagingService[index];
+               return m_messagingServices[index];
        }
        
        std::vector<IMessagingServicePtr> getMessagingServices()
        {
-               return m_messagingService;
+               return m_messagingServices;
        }
        
        EventGetMessagingService() 
index b3e2521..015c840 100755 (executable)
@@ -31,15 +31,28 @@ namespace Messaging {
 
 class EventMessagingService;
 
+enum MessagingServiceEventType
+{
+       MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE = 1,
+       MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY,
+       MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT,
+       MESSAGING_SERVICE_EVENT_TYPE_SYNC,
+       MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER,
+       MESSAGING_SERVICE_EVENT_COUNT,
+};
+
+
+
 class EventMessagingService: public WrtDeviceApis::Commons::IEvent<EventMessagingService> {
        
 public:
+#if 0  
        static const int MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE                      = 1;
        static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY         = 2;
        static const int MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT = 3;
        static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC                                      = 4;   //now, I have no idea about sync.                                
        static const int MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER                       = 5;
-       
+#endif
 private:
        
        MessagingPropertiesPtr m_messagingPropsPtr;
@@ -67,13 +80,25 @@ public:
                return m_messagingPropsPtr;
        }
 
-       IMessagePtr m_message;
+       int getHandle() const {
+               return m_handle;
+       }
 
-       IAttachmentPtr m_attachment;
+       void setHandle(int handle)
+       {
+               m_handle = handle;
+       }
 
+       std::vector<std::string> m_successRecipients;   //sucess
+       std::vector<std::string> m_failRecipients;              //fail
+       bool store;
+
+       IMessagePtr m_message;
+       IAttachmentPtr m_attachment;
        IMessagingServicePtr m_messagingService;
 
        int opId;
+       int m_handle;
 
        std::string m_folder_name;
 
index de0c435..de793bc 100755 (executable)
@@ -39,6 +39,8 @@ class EventQueryConversations :
     public WrtDeviceApis::Commons::IEvent<EventQueryConversations>
 {
   public:
+         EventQueryConversations() : m_limit(0), m_offset(0), m_index(-1), m_type(-1){
+         }     
        void setSortMode(Api::Tizen::SortModePtr sortMode) { m_sortMode = sortMode;}
        void setFilter(Api::Tizen::FilterPtr filter) { m_filter = filter;}
        void setLimit(unsigned long limit) { m_limit = limit;}
@@ -50,6 +52,21 @@ class EventQueryConversations :
        unsigned long getLimit() { return m_limit;}
        unsigned long getOffset() { return m_offset;}
        std::vector<IConversationPtr> getConversatioins() { return m_conversations;}
+       void setIndex(long index){
+               m_index = index;
+       }
+       
+       long getIndex(){
+               return m_index;
+       }
+       
+       void setType(int type){
+               m_type = type;
+       }
+       
+       int getType(){
+               return m_type;
+       }       
 
     virtual void clearOnCancel()
     {
@@ -61,6 +78,8 @@ private:
        Api::Tizen::FilterPtr m_filter;
        unsigned long m_limit;
        unsigned long m_offset;
+       long m_index;
+       int m_type;             
     //output parameter
        std::vector<IConversationPtr> m_conversations;
 
index d086e60..eb06920 100755 (executable)
@@ -41,11 +41,13 @@ class EventQueryFolders :
                // input parameters
                Api::Tizen::FilterPtr m_filter;
                int m_accountId;        
+               long m_index;
+               int m_type;             
                //output parameter
                std::vector<IMessageFolderPtr> m_folders;
 
   public:
-    EventQueryFolders() : m_accountId(-1){
+    EventQueryFolders() : m_accountId(-1), m_index(-1), m_type(-1){
        }
        
        void setFilter(Api::Tizen::FilterPtr filter) { m_filter = filter;}
@@ -61,6 +63,23 @@ class EventQueryFolders :
                return m_accountId;
        }
 
+       void setIndex(long index){
+               m_index = index;
+       }
+       
+       long getIndex(){
+               return m_index;
+       }
+       
+       void setType(int type){
+               m_type = type;
+       }
+       
+       int getType(){
+               return m_type;
+       }       
+       
+
     virtual void clearOnCancel()
     {
     }
index bb6179e..415adb4 100755 (executable)
@@ -49,9 +49,11 @@ class EventQueryMessages :
        Api::Tizen::SortModePtr m_sortMode;
        long m_limit;
        long m_offset;
+       long m_index;
+       int m_type;
 
   public:
-       EventQueryMessages() : m_limit(0), m_offset(0){
+       EventQueryMessages() : m_limit(0), m_offset(0), m_index(-1), m_type(-1){
        }
     // input parameters
     std::vector<MessageType> messageTypes;
@@ -93,6 +95,22 @@ class EventQueryMessages :
                        return m_offset;
                }
 
+               void setIndex(long index){
+                       m_index = index;
+               }
+
+               long getIndex(){
+                       return m_index;
+               }
+
+               void setType(int type){
+                       m_type = type;
+               }
+
+               int getType(){
+                       return m_type;
+               }       
+
     virtual void clearOnCancel()
     {
     }
index 9abe9ad..14bf6d7 100755 (executable)
@@ -42,11 +42,31 @@ typedef DPL::SharedPtr<EventUpdateMessages> EventUpdateMessagesPtr;
 class EventUpdateMessages :
     public WrtDeviceApis::Commons::IEvent<EventUpdateMessages>
 {
+  private:
+    long m_index;
+    int m_type;
+
   public:
 
     IMessagePtr msg;
     std::vector<Api::Messaging::IMessagePtr> msgArray; 
 
+    void setIndex(long index){
+        m_index = index;
+    }
+       
+    long getIndex(){
+        return m_index;
+    }
+       
+    void setType(int type){
+        m_type = type;
+    }
+       
+    int getType(){
+        return m_type;
+    }  
+
     virtual void clearOnCancel()
     {
     }
index a5d4cb0..929ca18 100755 (executable)
@@ -130,6 +130,17 @@ void IAttachment::setMimeType(const std::string &mimeType)
     m_mimeType = mimeType;
 }
 
+//for security
+void IAttachment::setVirtualPath(const std::string& virtualPath)
+{
+       m_virtualPath = m_virtualPath;
+}
+
+std::string IAttachment::getVirtualPath()
+{
+       return m_virtualPath;
+}
+
 Api::Messaging::IMessagePtr IAttachment::getMessage() const
 {
        return m_message;
index 999f7c0..dc0547c 100755 (executable)
@@ -63,6 +63,9 @@ class IAttachment
      */
     std::string m_mimeType;
 
+
+    std::string m_virtualPath;
+
     /**
      * information if abstract message attachment has been changed and need
      * update in low level
@@ -128,7 +131,10 @@ class IAttachment
      */
     void rename(const std::string& newName);
 
-
+    void setVirtualPath(const std::string& virtualPath);
+               
+    std::string getVirtualPath();
+       
     void setAttachmentID(int id);
        
     int getAttachmentID() const;
index f58a076..21d26d7 100755 (executable)
@@ -64,12 +64,12 @@ class IEmail : virtual public IMessage,
        
     void setEmailAccount(const EmailAccountInfo& account)
     {
-               m_EmailAccount = account;
+               m_emailAccount = account;
     }
 
     EmailAccountInfo getEmailAccount()
     {
-               return m_EmailAccount;
+               return m_emailAccount;
     }
        
     virtual int getAccountID() = 0;
@@ -80,7 +80,8 @@ class IEmail : virtual public IMessage,
     virtual void downloadBodyCancel(int handle ) = 0;
 
     virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment) = 0;
-
+    virtual void downloadAttachmentCancel(int handle ) = 0;
+       
     virtual bool hasAttachment() = 0;
 
 #if 0  
@@ -89,7 +90,7 @@ class IEmail : virtual public IMessage,
 #endif    
   private:
     std::string m_htmlBody;            //html body for Email.
-    EmailAccountInfo m_EmailAccount;   
+    EmailAccountInfo m_emailAccount;   
 };
 
 typedef DPL::SharedPtr<IEmail> IEmailPtr;
index 2628332..89c2f74 100755 (executable)
@@ -195,6 +195,13 @@ class IMessage :
 
 
     /**
+     * method used to updateMessage
+     * @throw PlatformException Thrown when updateMessage fail
+     */
+    virtual void updateMessage() = 0;
+
+
+    /**
      * method used to addMessageToDraft
      * @throw PlatformException Thrown when addMessageToDraft fail
      */
index 0df17ed..486fde5 100755 (executable)
@@ -75,6 +75,9 @@ class IMessaging : private DPL::Noncopyable,
 
        virtual std::vector<IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter,
                const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset) = 0;
+       virtual std::vector<IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter,
+               const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type) = 0;      
+       
        virtual std::vector<IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter) = 0;
 
     virtual std::vector<std::string> getMessageIds(MessageType msgType,
@@ -104,6 +107,7 @@ class IMessaging : private DPL::Noncopyable,
        virtual int getConversationId(const int& msgId, const MessageType &msgtype) = 0;
 
        virtual std::vector<IConversationPtr> queryConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter, long limit=0, long offset=0) = 0;
+       virtual std::vector<IConversationPtr> queryConversations(const Api::Tizen::FilterPtr& filter, const Api::Tizen::SortModePtr& sortMode, int type, long limit=0, long offset=0)= 0;
        virtual bool deleteConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter) = 0;
        virtual bool deleteConversations(const std::vector<IConversationPtr>& conversations) = 0;
        virtual std::vector<IMessageFolderPtr> queryFolders(const Api::Tizen::FilterPtr& filter) = 0;
index 4a604e3..d16e27b 100755 (executable)
@@ -51,6 +51,15 @@ EventMessagingServicePtr IMessagingService::getMessagingServiceEvent() const
        return m_messagingServiceEvent;
 }
 
+void IMessagingService::OnCancelEvent(const EventMessagingServicePtr &event)\r
+{\r
+       LogDebug("<<<<<<<<<<<<<<<<< OnCancelEvent >>>>>>>>>>>>>>>>>>>>>> " );\r
+       LogDebug(" OpID " << event->opId);\r
+       LogDebug(" Handle " << event->getHandle());\r
+       LogDebug(" event Type " << event->getEventType());\r
+       cancelOperation(event->opId, event->getHandle(), event->getEventType(), event->m_message);\r
+       return;\r
+}\r
 \r
 }\r
 }\r
index 83a2a9d..9680dc3 100755 (executable)
@@ -25,6 +25,8 @@
 #include <API/Messaging/IEmailAccount.h>
 #include <API/Messaging/IMessageFolder.h>
 #include <API/Messaging/IMessage.h>
+#include <Commons/EventReceiver.h>
+#include <Commons/IExternEventCanceler.h>
 
 namespace TizenApis {
 namespace Api {
@@ -46,6 +48,7 @@ class IMessagingService;
 typedef DPL::SharedPtr<IMessagingService> IMessagingServicePtr;
 
 class IMessagingService:
+       public WrtDeviceApis::Commons::IExternEventCanceler< EventMessagingService >,
        public IEmailAccount
 {
 public:
@@ -90,8 +93,10 @@ public:
        virtual int getHandleFromOpId(int opId) = 0;
        virtual int getOpTypeFromOpId(int opId) = 0;
        virtual Api::Messaging::IMessagePtr getMessageFromOpId(int opId) = 0;
+       virtual Api::Messaging::EventMessagingServicePtr getEventFromOpId(int opId) = 0;
        virtual void setHandleToOpId(int opId, int handle) = 0;
        virtual void setMessageToOpId(int opId, Api::Messaging::IMessagePtr& message) = 0;
+       virtual void setEventToOpId(int opId, EventMessagingServicePtr &event) = 0;
        virtual int deleteOpId(int opId)=0;
                                        
        virtual int sync(const Api::Messaging::IMessagingServicePtr& messagingService, const int limit) = 0;
@@ -99,6 +104,9 @@ public:
        virtual int syncFolder(const Api::Messaging::IMessagingServicePtr& messagingService, const std::string& folder_name, const int limit) = 0;
        virtual void syncFolderCancel(int handle) = 0;
 
+       virtual void cancelOperation(int opId, int handle, int eventType, Api::Messaging::IMessagePtr& message) = 0;
+       
+    void OnCancelEvent(const EventMessagingServicePtr &event);
     void setMessagingServiceEvent(const EventMessagingServicePtr &event);
     EventMessagingServicePtr getMessagingServiceEvent() const;
 
index 0ec8e58..29ebcb4 100755 (executable)
@@ -123,7 +123,7 @@ IMessagePtr MessageFactory::createEmailMessage(const int accountId, const int ma
 
        std::vector<IAttachmentPtr> attachments = email->getAttachments();
 
-       int idx = 0;
+       unsigned int idx = 0;
        for (; idx < attachments.size() ; idx++ )
        {
                LogDebug("set Messsage ID = " << attachments[idx]->getAttachmentID());
index 65f4a99..830ef60 100755 (executable)
@@ -50,6 +50,8 @@ namespace TizenApis {
 
                        m_idMatchFlagVec.push_back(MessageFilterValidatorFactory::MATCH_EXACTLY);
 
+                       m_serviceIdMatchFlagVec.push_back(MessageFilterValidatorFactory::MATCH_EXACTLY);
+
                        m_folderIdMatchFlagVec.push_back(MessageFilterValidatorFactory::MATCH_EXACTLY);
 
                        m_timestampMatchFlagVec.push_back(MessageFilterValidatorFactory::MATCH_EXACTLY);
@@ -89,6 +91,7 @@ namespace TizenApis {
                void MessageFilterValidator::initAttributeAndMatchFlagsMap(){
                        m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_TYPE]      = m_typeMatchFlagVec;
                        m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_ID]        = m_idMatchFlagVec;
+                       m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID]= m_serviceIdMatchFlagVec;                      
                        m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_FOLDER]    = m_folderIdMatchFlagVec;
                        m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP] = m_timestampMatchFlagVec;
                        m_attributeAndMatchFlagsMap[MessageFilterValidatorFactory::ATTRIBUTE_FROM]      = m_fromMatchFlagVec;
index 3327c0d..da65a06 100755 (executable)
@@ -38,6 +38,7 @@ namespace TizenApis {
 
                                std::vector<std::string>  m_typeMatchFlagVec;
                                std::vector<std::string>  m_idMatchFlagVec;
+                               std::vector<std::string>  m_serviceIdMatchFlagVec;                              
                                std::vector<std::string>  m_folderIdMatchFlagVec;
                                std::vector<std::string>  m_timestampMatchFlagVec;
                                std::vector<std::string>  m_fromMatchFlagVec;
index cfd63b9..a2d62a5 100755 (executable)
@@ -29,6 +29,7 @@ namespace TizenApis {
                namespace Messaging {
 
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_ID               = "id";
+               const std::string MessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID       = "serviceId";              
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_TYPE             = "type";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_FOLDER           = "folderId";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP        = "timestamp";
@@ -38,7 +39,7 @@ namespace TizenApis {
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_BCC              = "bcc";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_BODY             = "body";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_IS_READ          = "isRead";
-               const std::string MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY         = "priority";
+               const std::string MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY         = "isHighPriority";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_SUBJECT          = "subject";
                const std::string MessageFilterValidatorFactory::ATTRIBUTE_ATTACHMENT   = "hasAttachment";
 
@@ -50,6 +51,7 @@ namespace TizenApis {
                static PropertyStructArray properties =
                {
                                {MessageFilterValidatorFactory::ATTRIBUTE_ID.c_str(),        Api::Tizen::PrimitiveType_String},
+                               {MessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID.c_str(),Api::Tizen::PrimitiveType_String},
                                {MessageFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),      Api::Tizen::PrimitiveType_String},
                                {MessageFilterValidatorFactory::ATTRIBUTE_FOLDER.c_str(),    Api::Tizen::PrimitiveType_String},
                                {MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP.c_str(), Api::Tizen::PrimitiveType_Time},
index 69ec806..694aafd 100755 (executable)
@@ -41,6 +41,7 @@ namespace TizenApis {
 
                        public:
                                static const std::string ATTRIBUTE_ID;
+                               static const std::string ATTRIBUTE_SERVICE_ID;                          
                                static const std::string ATTRIBUTE_TYPE;
                                static const std::string ATTRIBUTE_FOLDER;
                                static const std::string ATTRIBUTE_TIMESTAMP;
index da6cd04..3b12806 100755 (executable)
@@ -31,8 +31,8 @@
 #include "FolderFilterValidatorFactory.h"
 
 //for email service
-#include <emf-types.h>
-#include <Emf_Mapi.h>
+#include <email-types.h>
+#include <email-api.h>
 
 
 using namespace std;
@@ -78,6 +78,12 @@ void ReqReceiverMessage::sendMessage(const EventSendMessagePtr& event)
     EventSendMessageReqReceiver::PostRequest(event);
 }
 
+void ReqReceiverMessage::sendMessage(const EventMessagingServicePtr& event)
+{
+    LogDebug("enter");
+    EventMessagingServiceReqReceiver::PostRequest(event);
+}
+
 void ReqReceiverMessage::updateMessage(const EventUpdateMessagePtr& event)
 {
     LogDebug("enter");
@@ -197,9 +203,10 @@ void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event)
                                if (email_get_account_list(&accounts, &count)) {
                                        if (0 < count)
                                        {
-                                               Api::Messaging::EmailAccountInfo account(accounts[0].account_id,
-                                                                                 accounts[0].user_name,
-                                                                                 accounts[0].email_addr );                                             
+                                               int index = (int)event->getIndex();
+                                               Api::Messaging::EmailAccountInfo account(accounts[index-1].account_id,
+                                                                                                           accounts[index-1].user_name,
+                                                                                                           accounts[index-1].email_addr );                                             
                                                email->setEmailAccount(account);
                                                
                                                if (accounts != NULL) {
@@ -212,6 +219,8 @@ void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event)
                                if (accounts != NULL) {
                                        email_free_account(&accounts, count);
                                }
+                               MsgLogError("platform exception");
+                               Throw(WrtDeviceApis::Commons::PlatformException);
                }
                                                
                                
@@ -377,7 +386,8 @@ void ReqReceiverMessage::OnRequestReceived(const EventUpdateMessagesPtr& event)
         {
 //            int type = msg[i]->getMessageType();
             std::string id = msg[i]->getId();
-            msg[i]->updateIsRead();
+            msg[i]->updateMessage();                   
+//            msg[i]->updateIsRead();                  
         }
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
@@ -393,6 +403,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventQueryMessagesPtr& event)
        Try {
 
                vector<IMessagePtr> msgs;
+               vector<IMessagePtr> tmp;
 
                //check filter validation
                Tizen::FilterPtr filter = event->getFilter();
@@ -403,7 +414,17 @@ void ReqReceiverMessage::OnRequestReceived(const EventQueryMessagesPtr& event)
                }
 
                // using filter
-               vector<IMessagePtr> tmp = IMessaging::getInstance().findMessages(event->getFilter(), event->getSortMode(), event->getLimit(), event->getOffset());
+               LogDebug("event->getType() = " << event->getType());            
+               if(event->getType() > Api::Messaging::UNKNOWN)
+               {
+                       LogDebug("enter");
+                       tmp = IMessaging::getInstance().findMessages(event->getFilter(), event->getSortMode(), event->getLimit(), event->getOffset(), event->getType());
+               }
+               else
+               {
+                       LogDebug("enter");              
+                       tmp = IMessaging::getInstance().findMessages(event->getFilter(), event->getSortMode(), event->getLimit(), event->getOffset());
+               }
                msgs.insert(msgs.end(), tmp.begin(), tmp.end());
                event->msgs = msgs;
 
@@ -454,6 +475,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventQueryConversationsPtr& eve
        {
                //check filter validation
                Tizen::FilterPtr filter = event->getFilter();
+               vector<IConversationPtr> tmp;
                if(filter != NULL){
                        ConversationFilterValidatorPtr validator =
                                        ConversationFilterValidatorFactory::getConversationFilterValidator();
@@ -465,8 +487,17 @@ void ReqReceiverMessage::OnRequestReceived(const EventQueryConversationsPtr& eve
                                Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                        }
                }
-
-               vector<IConversationPtr> tmp = IMessaging::getInstance().queryConversations(event->getSortMode(), event->getFilter(), event->getLimit(), event->getOffset());
+               LogDebug("event->getType() = "<<event->getType());
+               if(event->getType() > Api::Messaging::UNKNOWN)
+               {
+                       LogDebug("enter");
+                       tmp = IMessaging::getInstance().queryConversations(event->getFilter(), event->getSortMode(), event->getType(), event->getLimit(), event->getOffset());
+               }
+               else
+               {
+                       LogDebug("enter");              
+                       tmp = IMessaging::getInstance().queryConversations(event->getSortMode(), event->getFilter(), event->getLimit(), event->getOffset());
+               }               
                event->addConversations(tmp);
 
        }
@@ -490,7 +521,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                LogDebug("event type :" << event->getEventType() );
                int MessagingServiceEventType = event->getEventType();
 
-               if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY)
+               if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY)
                {
                        if (!event->checkCancelled()) {
                                IMessagePtr msg = event->m_message;
@@ -512,6 +543,10 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                                {
                                                        event->m_messagingService->setHandleToOpId(event->opId, handle);
                                                }
+                                               if (handle > 0)
+                                               {
+                                                       event->setHandle(handle);       //set handle
+                                               }                                               
                                        }
                                }
                                else {
@@ -527,7 +562,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                        }
                }
 
-               else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
+               else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
                {
                        if (!event->checkCancelled()) {
                                IMessagePtr msg = event->m_message;
@@ -548,6 +583,10 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                                {
                                                        event->m_messagingService->setHandleToOpId(event->opId, handle);
                                                }
+                                               if (handle > 0)
+                                               {
+                                                       event->setHandle(handle);       //set handle
+                                               }                                               
                                        }
                                        else
                                        {
@@ -564,7 +603,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
 
                }
 
-               else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC)
+               else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC)
                {
                        if (event->m_messagingService)
                        {
@@ -588,6 +627,11 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                                        {
                                                                event->m_messagingService->setHandleToOpId(event->opId, handle);
                                                        }
+                                                       if (handle > 0)
+                                                       {
+                                                               event->setHandle(handle);       //set handle
+                                                       }
+
                                                }
                                                else
                                                        event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException);
@@ -605,7 +649,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                        }
 
                }
-               else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER)
+               else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER)
                {
                        if (event->m_messagingService)
                        {
@@ -628,6 +672,10 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                                        {
                                                                event->m_messagingService->setHandleToOpId(event->opId, handle);
                                                        }
+                                                       if (handle > 0)
+                                                       {
+                                                               event->setHandle(handle);       //set handle
+                                                       }
                                                }
                                                else
                                                        event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException);
@@ -644,6 +692,44 @@ void ReqReceiverMessage::OnRequestReceived(const EventMessagingServicePtr& event
                                }
                        }
                }
+               else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE)
+               {
+                       IMessagePtr msg = event->m_message;
+                       msg->setRequestReceiver(this);
+                       msg->setMessagingServiceEvent(event);
+                       if (!event->checkCancelled()) 
+                       {
+                               event->switchToManualAnswer();
+                               if (msg->getMessageStatus() == Api::Messaging::MESSAGE_STATUS_CREATED ) //create message.
+                               {
+                                       //if draft Message.
+                                       if (msg->getMessageType() == Api::Messaging::EMAIL )
+                                       {
+                                               Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                                               email->setEmailAccount(event->m_messagingService->getCurrentEmailAccount());
+                                       }
+                                       
+                                       msg->addMessageToDraft();       //save 
+                                       
+                                       LogDebug("Message Status = " << msg->getMessageStatus());
+                                       LogDebug("Message ID = " << msg->getId());
+                               }
+
+                               int handle = msg->send();
+                               LogDebug("handle : " << handle);
+                               if (event->opId && event->m_messagingService)
+                               {
+                                       event->m_messagingService->setHandleToOpId(event->opId, handle);
+                               }
+
+                               if (handle > 0)
+                               {
+                                       event->setHandle(handle);       //set handle
+                               }
+                               
+                       }       
+
+               }
                else
                {
                        LogDebug(" Cancel ");
@@ -663,7 +749,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventDeleteConversationsPtr& ev
        LogDebug("enter");
 
        Try
-       {
+       {/*
                        if (event->isFilterUsing())
                        {
                                LogDebug("filter use");
@@ -691,7 +777,7 @@ void ReqReceiverMessage::OnRequestReceived(const EventDeleteConversationsPtr& ev
                                }
                                        //.queryConversations(event->getSortMode(), event->getFilter());
                        }
-                       else
+                       else*/
                        {
                                LogDebug("no filter");
 
index ce23660..f186036 100755 (executable)
@@ -96,6 +96,8 @@ class ReqReceiverMessage : public EventAddDraftMessageReqReceiver,
 
     void sendMessage(const EventSendMessagePtr& event);
 
+    void sendMessage(const EventMessagingServicePtr& event);
+
     void updateMessage(const EventUpdateMessagePtr& event);
 
     void deleteMessage(const EventDeleteMessagePtr& event);
index ad835eb..6d60dc6 100755 (executable)
@@ -28,33 +28,35 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
+               const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_ID             = "id";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TYPE             = "type";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP        = "timestamp";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT    = "messageCount";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES  = "unreadMessages";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW          = "preview";
+               const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_SUBJECT          = "subject";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ          = "isRead";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_FROM             = "from";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TO               = "to";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_CC               = "cc";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_BCC              = "bcc";
-               const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_SUBJECT          = "subject";
                const std::string StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_LAST_MESSAGE_ID  = "lastMessageId";
 
                static PropertyStructArray properties =
                {
-                               {"type",             Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_ID.c_str(),                           Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),             Api::Tizen::PrimitiveType_String},
                                {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP.c_str(), Api::Tizen::PrimitiveType_Time},
-                               {"messageCount",         Api::Tizen::PrimitiveType_Number},
-                               {"unreadMessages",       Api::Tizen::PrimitiveType_Number},
-                               {"preview",                      Api::Tizen::PrimitiveType_String},
-                               {"isRead",                       Api::Tizen::PrimitiveType_Number},
-                               {"from",             Api::Tizen::PrimitiveType_String},
-                               {"to",               Api::Tizen::PrimitiveType_String},
-                               {"cc",               Api::Tizen::PrimitiveType_String},
-                               {"bcc",              Api::Tizen::PrimitiveType_String},
-                               {"subject",          Api::Tizen::PrimitiveType_String},
-                               {"lastMessageId",        Api::Tizen::PrimitiveType_String},                             
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT.c_str(),    Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES.c_str(),  Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW.c_str(),          Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_SUBJECT.c_str(),          Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),          Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_FROM.c_str(),             Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TO.c_str(),               Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_CC.c_str(),               Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_BCC.c_str(),              Api::Tizen::PrimitiveType_String},
+                               {StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_LAST_MESSAGE_ID.c_str(),  Api::Tizen::PrimitiveType_String},                               
                                {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
index 81167cd..fa29e4f 100755 (executable)
@@ -40,17 +40,18 @@ namespace TizenApis {
                                static StorageChangesConversationFilterValidatorPtr getStorageChangesConversationFilterValidator();
 
                        public:
+                               static const std::string ATTRIBUTE_ID;
                                static const std::string ATTRIBUTE_TYPE;
                                static const std::string ATTRIBUTE_TIMESTAMP;
                                static const std::string ATTRIBUTE_MESSAGE_COUNT;
                                static const std::string ATTRIBUTE_UNREAD_MESSAGES;
                                static const std::string ATTRIBUTE_PREVIEW;                             
+                               static const std::string ATTRIBUTE_SUBJECT;
                                static const std::string ATTRIBUTE_IS_READ;
                                static const std::string ATTRIBUTE_FROM;
                                static const std::string ATTRIBUTE_TO;
                                static const std::string ATTRIBUTE_CC;
                                static const std::string ATTRIBUTE_BCC;
-                               static const std::string ATTRIBUTE_SUBJECT;
                                static const std::string ATTRIBUTE_LAST_MESSAGE_ID;
                };
 
index cf4c110..b540dd8 100755 (executable)
 
 #include "IMessagingTypes.h"
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <dpl/log/log.h>
+#include <algorithm>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -42,14 +43,15 @@ namespace TizenApis {
 
                StorageChangesConversationGenerator::StorageChangesConversationGenerator(Api::Messaging::IConversationPtr conv):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
 
+                       m_id = conv->getId();
                        m_type = conv->getType();
                        m_time = conv->getTime();
                        m_messageCount = conv->getMessageCount();
                        m_unreadMessages = conv->getUnreadMessages();
                        m_preview = conv->getPreview();
+                       m_subject = conv->getSubject();
                        m_read = conv->getRead();
                        m_from = conv->getFrom();
-                       m_subject = conv->getSubject();
                        m_to = conv->getTo();
                        m_cc = conv->getCC();
                        m_bcc = conv->getBCC();
@@ -168,6 +170,7 @@ namespace TizenApis {
                        return tm_Time;
                        }
 
+
                bool StorageChangesConversationGenerator::getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
                        std::string valueString = value->toString();
@@ -186,14 +189,53 @@ namespace TizenApis {
                        }
                }
 
+               bool StorageChangesConversationGenerator::getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value)
+               {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
+                       std::string valueString = value->toString();
+                       LogDebug("<<< attrName : " << attrName);
+                       LogDebug("<<< valueString : " << valueString);
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
+                       
+                       if(tempString1.compare(tempString2) == 0)
+                       {
+                               LogDebug("<<< getMatchFullstringClause SAME >>>");
+                               return TRUE;                            
+                       }
+                       else{
+                               LogDebug("<<< getMatchFullstringClause DIFF >>>");
+                               return FALSE;                                                           
+                       }
+               }
+
                bool StorageChangesConversationGenerator::getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.find(valueString) : " << attrName.find(valueString));
 
-                       if(attrName.find(valueString) != std::string::npos)
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+                       
+                       LogDebug("<<< attrName.find(valueString) : " << tempString1.find(tempString2));
+
+                       if(tempString1.find(tempString2) != std::string::npos)
                        {
                                LogDebug("<<< getMatchContainsClause CONTAINS >>>");
                                return TRUE;                            
@@ -205,16 +247,23 @@ namespace TizenApis {
 
                bool StorageChangesConversationGenerator::getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.compare(0,valueString.size(), valueString) : " << attrName.compare(0,valueString.size(), valueString));
 
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
                        
-                       if(attrName.size()-valueString.size() < 0)
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
 
-                       if(attrName.compare(0,valueString.size(), valueString) == 0)
+                       if(tempString1.compare(0,tempString2.size(), tempString2) == 0)
                        {
                                LogDebug("<<< getMatchStartwithClause START WITH >>>");
                        return TRUE;
@@ -227,17 +276,27 @@ namespace TizenApis {
 
                bool StorageChangesConversationGenerator::getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
 
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
+
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+                       
                        LogDebug("<<< attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) : " << attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString));
 
 
-                       if(attrName.size()-valueString.size() < 0)
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
 
-                       if(attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) == 0 )
+                       if(tempString1.compare(tempString1.size()-tempString2.size(),tempString2.size(), tempString2) == 0 )
                        {
                                LogDebug("<<< getMatchEndwithClause END WITH >>>");
                                return TRUE;                            
@@ -246,13 +305,26 @@ namespace TizenApis {
                                LogDebug("<<< getMatchEndwithClause NOT END WITH >>>");
                                return FALSE;                                                           
                        }
-                       }
+               }
+
+               bool StorageChangesConversationGenerator::getMatchExistClause(std::string& attrName)
+               {
+                       LogDebug("<<< attrName : " << attrName);
+                       if(attrName.size()> 0)
+                               return TRUE;
+                       else
+                               return FALSE;
+               }
+
 
                void StorageChangesConversationGenerator::visitAttribute(std::string& attrName,
                                                 MatchFlag& matchFlag, AnyPtr& matchValue, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
-                       if(matchValue == NULL)
+                       if(matchFlag != Api::Tizen::MATCH_EXISTS){
+                               if(matchValue == NULL)  {
                                return;
+                               }
+                       }
 
                        LogDebug("matchValue:" << matchValue->toString());
 
@@ -265,7 +337,24 @@ namespace TizenApis {
                        std::string valueString;
 
 //  Check msg_type and filter_type
-                       if(attrName.compare("type")==0){
+
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_ID)==0){
+                               LogDebug("<<< value:[" << value << "]");
+                               int nType = atoi(value->toString().c_str());
+                               if((int)m_id == nType)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< id is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< id is different");
+                               }
+                               return;
+                       }
+
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TYPE)==0){
                                LogDebug("<<< value:[" << value << "]");
                                std::string convertType = value->toString();
                                int nType = convertMessageType(convertType);
@@ -281,7 +370,8 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("messageCount")==0){
+                       
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_MESSAGE_COUNT)==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = atoi(value->toString().c_str());
                                if((int)m_messageCount == nType)
@@ -296,7 +386,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("unreadMessages")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_UNREAD_MESSAGES)==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = atoi(value->toString().c_str());
                                if((int)m_unreadMessages == nType)
@@ -311,10 +401,14 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("isRead")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_IS_READ)==0){
                                LogDebug("<<< value:[" << value << "]");
-                               int nType = value->toString().compare("true");
-                               if((int)m_read == nType)
+                               std::string lowerString;
+                               lowerString.assign(value->toString());
+                               StrLowChange(lowerString);                              
+                               int nType = lowerString.compare("true");
+
+                               if((int)m_read != nType)
                                {
                                        m_result.push_back(TRUE);
                                        LogDebug("<<< read is same");
@@ -326,7 +420,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("lastMessageId")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_LAST_MESSAGE_ID)==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = atoi(value->toString().c_str());
                                if((int)m_lastMessageId == nType)
@@ -342,7 +436,7 @@ namespace TizenApis {
                                return;
                        }
   
-                       if(attrName.compare("preview")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_body:[" << m_preview << "]");
@@ -352,7 +446,7 @@ namespace TizenApis {
                                {
                                        m_result.push_back(TRUE);
                                        LogDebug("<<< preview is same");
-                       }
+                               }
                                else
                                {
                                        m_result.push_back(FALSE);
@@ -360,7 +454,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("from")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_FROM)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_from:[" << m_from << "]");
@@ -378,7 +472,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("subject")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_SUBJECT)==0){
                        LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_subject:[" << m_subject << "]");
@@ -397,7 +491,7 @@ namespace TizenApis {
                                return;
                        }
   
-                       if(attrName.compare("to")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TO)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_to.size :[" << m_to.size() << "]");
@@ -413,7 +507,7 @@ namespace TizenApis {
                                return;
                        }
   
-                       if(attrName.compare("cc")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_CC)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_cc.size :[" << m_cc.size() << "]");
@@ -429,7 +523,7 @@ namespace TizenApis {
                                return;
                        }
   
-                       if(attrName.compare("bcc")==0){
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_BCC)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_cc.size :[" << m_bcc.size() << "]");
@@ -484,19 +578,48 @@ namespace TizenApis {
 
                void StorageChangesConversationGenerator::visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth) {
                        time_t init_time, mid_time, end_time;
-                       struct tm retValue;
+                       struct tm startTime;
+                       struct tm endTime;                      
+//                     struct tm retValue;
+                       string initialValueStr;
+                       string endValueStr;
 
                        if(initialValue == NULL || endValue == NULL)
                                return;
 
-                       if(attrName.compare("timestamp")==0){
-                               retValue = convertToTimeFormat(initialValue->toString());
-                               init_time = mktime(&retValue);
+                       if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
+
+                               if (!initialValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==initialValue->getType() ) {
+                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
+                                               startTime = initialValue->getDateTm();
+                                               LogDebug("<<<valueStr[" << initialValueStr <<"]");
+                                       }
+                                       else {
+                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
+                                       }
+                               }
+                               
+                               if (!endValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==endValue->getType() ) {
+                                               LogDebug("<<<endValue->getType()[" << endValue->getType() <<"]");                                       
+                                               endTime= endValue->getDateTm();
+                                               LogDebug("<<<valueStr[" << endValueStr <<"]");                                  
+                                       } else {
+                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
+                                       }
+                               }
+
+                               
+//                             retValue = convertToTimeFormat(initialValueStr);
+                               init_time = mktime(&startTime);
 
                                mid_time = m_time;
 
-                               retValue = convertToTimeFormat(endValue->toString());                           
-                               end_time = mktime(&retValue);
+//                             retValue = convertToTimeFormat(endValueStr);            
+                               end_time = mktime(&endTime);
 
                                LogDebug("<<< mktime(initialValue):[" << init_time << "]");
                                LogDebug("<<< mktime(m_dateTime):[" << mid_time << "]");
@@ -524,6 +647,9 @@ namespace TizenApis {
                        if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
+                       }else if(matchFlag == Api::Tizen::MATCH_FULLSTRING){
+                               LogDebug("STRING_MATCH_FULLSTRING");
+                               result = result || getMatchFullstringClause(valueString, value);                                                
                        }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
@@ -533,6 +659,9 @@ namespace TizenApis {
                        }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
+                       }else if(matchFlag == Api::Tizen::MATCH_EXISTS){
+                               LogDebug("STRING_MATCH_EXIST");
+                               result = result || getMatchExistClause(valueString);
                        }else{
                                LogDebug("[ERROR]invalid match flag : iter:" << *iter);
                        }
@@ -548,6 +677,14 @@ namespace TizenApis {
                        LogDebug("result = " << result);        
                        return result;
                }
+
+               void StorageChangesConversationGenerator::StrLowChange(std::string& tempString)
+               {       
+                       std::transform(tempString.begin(), tempString.end(), tempString.begin(), ::tolower);
+                       return;
+               }
+
+
 }
        }               //namespace Platform
 }              //namespace WrtPlugins
index cfc0d7c..2f0a73a 100755 (executable)
@@ -63,9 +63,11 @@ namespace TizenApis {
 
                        private:
                                bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
+                               bool getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
+                               bool getMatchExistClause(std::string& attrName);                                
                                bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
 
                                void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
@@ -78,6 +80,8 @@ namespace TizenApis {
                                std::string createPriorityType(std::string& value);
                                std::string createDateTimeType(Api::Tizen::AnyPtr& value);
 
+                               void StrLowChange(std::string& tempString);
+
                        private:
                                int m_messageType;
 
@@ -87,15 +91,15 @@ namespace TizenApis {
                                std::vector<bool> m_result;
                                std::vector<int> m_operand;                             
 
-//                             unsigned int m_Id;
+                               unsigned int m_id;
                                unsigned short int m_type;
                                time_t m_time;
                                unsigned long m_messageCount;
                                unsigned long m_unreadMessages;
                                std::string m_preview;
+                               std::string m_subject;
                                bool m_read;
                                std::string m_from;
-                               std::string m_subject;
                                std::vector<std::string> m_to;
                                std::vector<std::string> m_cc;
                                std::vector<std::string> m_bcc;
index 6eaf229..0da3f33 100755 (executable)
@@ -39,14 +39,14 @@ namespace TizenApis {
 
                static PropertyStructArray properties =
                {
-                               {"id",             Api::Tizen::PrimitiveType_String},
-                               {"parentId",       Api::Tizen::PrimitiveType_String},
-                               {"serviceId",      Api::Tizen::PrimitiveType_String},
-                               {"contentType",    Api::Tizen::PrimitiveType_String},
-                               {"name",                   Api::Tizen::PrimitiveType_String},
-                               {"path",           Api::Tizen::PrimitiveType_String},
-                               {"type",           Api::Tizen::PrimitiveType_String},
-                               {"synchronizable", Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ID.c_str(),                                      Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PARENT_ID.c_str(),                       Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ACCOUNT_ID.c_str(),                      Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_CONTENT_TYPE.c_str(),            Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_NAME.c_str(),                            Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PATH.c_str(),                                    Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),                                    Api::Tizen::PrimitiveType_String},
+                               {StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_SYNCHRONIZABLE.c_str(),          Api::Tizen::PrimitiveType_Number},
                                {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
index 799c68a..e6c8078 100755 (executable)
@@ -25,7 +25,7 @@
 
 #include "IMessagingTypes.h"
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <dpl/log/log.h>
 
@@ -37,12 +37,6 @@ namespace TizenApis {
                namespace Messaging {
 
 
-               const std::string StorageChangesFolderGenerator::STRING_MATCH_EXACTLY         = "EXACTLY";
-               const std::string StorageChangesFolderGenerator::STRING_MATCH_CONTAINS        = "CONTAINS";
-               const std::string StorageChangesFolderGenerator::STRING_MATCH_STARTSWITH      = "STARTSWITH";
-               const std::string StorageChangesFolderGenerator::STRING_MATCH_ENDSWITH        = "ENDSWITH";
-//             const std::string StorageChangesFolderGenerator::STRING_MATCH_CASESENSITIVE   = "CASESENSITIVE";
-
                const int StorageChangesFolderGenerator::MESSAGE_TYPE_NOT_INITIALIZED = -1;
 
                StorageChangesFolderGenerator::StorageChangesFolderGenerator(Api::Messaging::IMessageFolderPtr folder):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
@@ -145,16 +139,56 @@ namespace TizenApis {
                                LogDebug("<<< getMatchExactlyClause DIFF >>>");
                                return FALSE;                                                           
                        }
+               }
+
+               bool StorageChangesFolderGenerator::getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value)
+               {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
+                       std::string valueString = value->toString();
+                       LogDebug("<<< attrName : " << attrName);
+                       LogDebug("<<< valueString : " << valueString);
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
+                       
+                       if(tempString1.compare(tempString2) == 0)
+                       {
+                               LogDebug("<<< getMatchFullstringClause SAME >>>");
+                               return TRUE;                            
+                       }
+                       else{
+                               LogDebug("<<< getMatchFullstringClause DIFF >>>");
+                               return FALSE;                                                           
                        }
+               }               
 
                bool StorageChangesFolderGenerator::getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.find(valueString) : " << attrName.find(valueString));
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
 
-                       if(attrName.find(valueString) != std::string::npos)
+                       if(tempString1.find(tempString2) != std::string::npos)
                        {
                                LogDebug("<<< getMatchContainsClause CONTAINS >>>");
                                return TRUE;                            
@@ -166,16 +200,26 @@ namespace TizenApis {
 
                bool StorageChangesFolderGenerator::getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.compare(0,valueString.size(), valueString) : " << attrName.compare(0,valueString.size(), valueString));
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
 
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
 
-                       if(attrName.size()-valueString.size() < 0)
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
 
-                       if(attrName.compare(0,valueString.size(), valueString) == 0)
+                       if(tempString1.compare(0,tempString2.size(), tempString2) == 0)
                {
                                LogDebug("<<< getMatchStartwithClause START WITH >>>");
                                return TRUE;
@@ -188,17 +232,26 @@ namespace TizenApis {
 
                bool StorageChangesFolderGenerator::getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
                        std::string valueString = value->toString();
-
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) : " << attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString));
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
 
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
 
-                       if(attrName.size()-valueString.size() < 0)
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
+
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
 
-                       if(attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) == 0 )
+                       if(tempString1.compare(tempString1.size()-tempString2.size(),tempString2.size(), tempString2) == 0 )
                        {
                                LogDebug("<<< getMatchEndwithClause END WITH >>>");
                                return TRUE;                            
@@ -209,12 +262,25 @@ namespace TizenApis {
                        }
                        }
 
+
+               bool StorageChangesFolderGenerator::getMatchExistClause(std::string& attrName)
+               {
+                       LogDebug("<<< attrName : " << attrName);
+                       if(attrName.size()> 0)
+                               return TRUE;
+                       else
+                               return FALSE;
+               }
+
                void StorageChangesFolderGenerator::visitAttribute(std::string& attrName,
                                Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& matchValue, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
 
-                       if(matchValue == NULL)
+                       if(matchFlag != Api::Tizen::MATCH_EXISTS){
+                               if(matchValue == NULL)  {
                                return;
+                               }
+                       }
 
                        LogDebug("matchValue:" << matchValue->toString());
 
@@ -226,7 +292,7 @@ namespace TizenApis {
                        std::string valueString;
 
 //  Check Folder_type and filter_type
-                       if(attrName.compare("serviceId")==0){
+                       if(attrName.compare( StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_ACCOUNT_ID)==0){
                                LogDebug("<<< value:[" << value << "]");
                                int nType = atoi(value->toString().c_str());
                                if((int)m_accountid == nType)
@@ -241,7 +307,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("contestType")==0){
+                       if(attrName.compare(StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_CONTENT_TYPE)==0){
                        LogDebug("<<< value:[" << value << "]");
                                std::string convertType = value->toString();
                                int nType = convertMessageType(convertType);
@@ -257,7 +323,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("type")==0){
+                       if(attrName.compare(StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_TYPE )==0){
                                LogDebug("<<< value:[" << value << "]");
                                std::string convertType = value->toString();
                                int nType = convertFolderType(convertType);
@@ -273,10 +339,13 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("synchronizable")==0){
+                       if(attrName.compare(StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_SYNCHRONIZABLE)==0){
                                LogDebug("<<< value:[" << value << "]");
-                               int nType = value->toString().compare("true");
-                               if((int)m_synchronizable == nType)
+                               std::string lowerString;
+                               lowerString.assign(value->toString());
+                               StrLowChange(lowerString);                              
+                               int nType = lowerString.compare("true");
+                               if((int)m_synchronizable != nType)
                                {
                                        m_result.push_back(TRUE);
                                        LogDebug("<<< synchronizable is same");
@@ -289,7 +358,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("name")==0){
+                       if(attrName.compare(StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_NAME)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_name:[" << m_name << "]");
@@ -308,7 +377,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("path")==0){
+                       if(attrName.compare(StorageChangesFolderFilterValidatorFactory::ATTRIBUTE_PATH)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_path:[" << m_path << "]");
@@ -386,6 +455,9 @@ namespace TizenApis {
                        if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
+                       }else if(matchFlag == Api::Tizen::MATCH_FULLSTRING){
+                               LogDebug("STRING_MATCH_FULLSTRING");
+                               result = result || getMatchFullstringClause(valueString, value);                                                
                        }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
@@ -395,6 +467,9 @@ namespace TizenApis {
                        }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
+                       }else if(matchFlag == Api::Tizen::MATCH_EXISTS){
+                               LogDebug("STRING_MATCH_EXIST");
+                               result = result || getMatchExistClause(valueString);
                        }else{
                                LogDebug("[ERROR]invalid match flag : iter:" << *iter);
                        }
@@ -410,6 +485,14 @@ namespace TizenApis {
                        LogDebug("result = " << result);        
                        return result;
                }
+
+
+               void StorageChangesFolderGenerator::StrLowChange(std::string& tempString)
+               {       
+                       std::transform(tempString.begin(), tempString.end(), tempString.begin(), ::tolower);
+                       return;
+               }
+               
 }
        }               //namespace Platform
 }              //namespace WrtPlugins
index c396cda..6e4c810 100755 (executable)
@@ -62,14 +62,17 @@ namespace TizenApis {
 
                        private:
                                bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
+                               bool getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
+                               bool getMatchExistClause(std::string& attrName);                                
 
                                void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
                                int convertMessageType(std::string& stringType);
                                int convertFolderType(std::string& stringType);                         
 
+                               void StrLowChange(std::string& tempString);
 
                        private:
                                int m_messageType;
@@ -91,12 +94,6 @@ namespace TizenApis {
                                unsigned short m_type;                          
                                bool m_synchronizable;
 
-                               static const std::string STRING_MATCH_EXACTLY;
-                               static const std::string STRING_MATCH_CONTAINS;
-                               static const std::string STRING_MATCH_STARTSWITH;
-                               static const std::string STRING_MATCH_ENDSWITH;
-                               static const std::string STRING_MATCH_CASESENSITIVE;
-
                                static const int MESSAGE_TYPE_NOT_INITIALIZED;
 
                };
index 9478bd1..d5cbd2e 100755 (executable)
@@ -28,8 +28,10 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID       = "serviceId";
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CONVERSATION_ID  = "conversationId";           
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FOLDER_ID        = "folderId";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TYPE             = "type";
-               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FOLDER           = "folder";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP        = "timestamp";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FROM             = "from";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TO               = "to";
@@ -37,23 +39,31 @@ namespace TizenApis {
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BCC              = "bcc";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY             = "body";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ          = "isRead";
-               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY         = "priority";
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT   = "hasAttachment";            
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY         = "isHighPriority";
                const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SUBJECT          = "subject";
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_RESPONSE_TO   = "isResponseTo";
+               const std::string StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_MESSAGE_STATUS   = "messageStatus";
 
 
                static PropertyStructArray properties =
                {
-                               {"type",             Api::Tizen::PrimitiveType_String},
-                               {"folder",           Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID.c_str(),            Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CONVERSATION_ID.c_str(),       Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FOLDER_ID.c_str(),             Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TYPE.c_str(),                  Api::Tizen::PrimitiveType_String},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP.c_str(), Api::Tizen::PrimitiveType_Time},
-                               {"from",             Api::Tizen::PrimitiveType_String},
-                               {"to",               Api::Tizen::PrimitiveType_String},
-                               {"cc",               Api::Tizen::PrimitiveType_String},
-                               {"bcc",              Api::Tizen::PrimitiveType_String},
-                               {"body",             Api::Tizen::PrimitiveType_String},
-                               {"isRead",           Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FROM.c_str(),                  Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TO.c_str(),                    Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CC.c_str(),                    Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BCC.c_str(),                   Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY.c_str(),                  Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),               Api::Tizen::PrimitiveType_Number},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT.c_str(),        Api::Tizen::PrimitiveType_Number},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY.c_str(),  Api::Tizen::PrimitiveType_Number},
-                               {"subject",          Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SUBJECT.c_str(),               Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_RESPONSE_TO.c_str(),        Api::Tizen::PrimitiveType_String},
+                               {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_MESSAGE_STATUS.c_str(),        Api::Tizen::PrimitiveType_String},
                                {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
index 17199ac..66fddc9 100755 (executable)
@@ -40,9 +40,10 @@ namespace TizenApis {
                                static StorageChangesMessageFilterValidatorPtr getStorageChangesMessageFilterValidator();
 
                        public:
-//                             static const std::string ATTRIBUTE_ID;
+                               static const std::string ATTRIBUTE_SERVICE_ID;
+                               static const std::string ATTRIBUTE_CONVERSATION_ID;
+                               static const std::string ATTRIBUTE_FOLDER_ID;                           
                                static const std::string ATTRIBUTE_TYPE;
-                               static const std::string ATTRIBUTE_FOLDER;
                                static const std::string ATTRIBUTE_TIMESTAMP;
                                static const std::string ATTRIBUTE_FROM;
                                static const std::string ATTRIBUTE_TO;
@@ -50,8 +51,11 @@ namespace TizenApis {
                                static const std::string ATTRIBUTE_BCC;
                                static const std::string ATTRIBUTE_BODY;
                                static const std::string ATTRIBUTE_IS_READ;
+                               static const std::string ATTRIBUTE_HAS_ATTACHMENT;
                                static const std::string ATTRIBUTE_PRIORITY;
                                static const std::string ATTRIBUTE_SUBJECT;
+                               static const std::string ATTRIBUTE_IS_RESPONSE_TO;
+                               static const std::string ATTRIBUTE_MESSAGE_STATUS;
                };
 
                }
index de8123d..e317164 100755 (executable)
 
 #include "IMessagingTypes.h"
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <dpl/log/log.h>
+#include <algorithm>
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -39,12 +40,15 @@ namespace TizenApis {
 
                const int StorageChangesMessageGenerator::MESSAGE_TYPE_NOT_INITIALIZED = -1;
 
-               StorageChangesMessageGenerator::StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
+               StorageChangesMessageGenerator::StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg, Api::Messaging::IConversationPtr conv) : 
+                       m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) , m_serviceId(-1)
+                       {
 
                        m_type = msg->getMessageType();
                        m_folder = msg->getCurrentFolder();
                        m_dateTime = msg->getDateTime();
                        m_from = msg->getFrom();
+                       m_conversationId = conv->getId();                       
 
                        Recipents = msg->getToRecipientsPtr();
 
@@ -84,6 +88,9 @@ namespace TizenApis {
                                {
                                        m_bcc = Recipents->getRecipientsRef();
                                }
+                               m_hasAttachment = mms->hasAttachment();
+
+
                        }
                        else if(m_type == Api::Messaging::EMAIL)
                        {
@@ -112,6 +119,18 @@ namespace TizenApis {
                                        m_bcc = Recipents->getRecipientsRef();
                                }
                                
+                               m_serviceId =  email->getAccountID();
+                               if (m_serviceId ==  -1) {
+                                       ThrowMsg(WrtDeviceApis::Commons::UnknownException,
+                                       "Couldn't convert e-mail account id");
+                               }
+
+                               m_hasAttachment = email->hasAttachment();
+
+//                             if (m_conversationId == email->getUID())
+//                                     m_isResponseTo = -1;
+                               m_isResponseTo = m_conversationId;
+                               
                        }
 
 
@@ -120,6 +139,8 @@ namespace TizenApis {
                        m_isRead = msg->isRead();
                        m_priority = msg->getPriority();
                        m_subject = msg->getSubject();
+                       m_messageStatus = msg->getMessageStatus();
+               
                        
                        LogDebug("m_type:" << m_type );
                        LogDebug("m_folder:" << m_folder );
@@ -262,14 +283,55 @@ namespace TizenApis {
                        }
                        }
 
+               bool StorageChangesMessageGenerator::getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value)
+               {
+                       std::string tempString1;
+                       std::string tempString2;
+                       
+                       std::string valueString = value->toString();
+                       LogDebug("<<< attrName : " << attrName);
+                       LogDebug("<<< valueString : " << valueString);
+                       
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
+                       
+                       if(tempString1.compare(tempString2) == 0)
+                       {
+                               LogDebug("<<< getMatchFullstringClause SAME >>>");
+                               return TRUE;                            
+                       }
+                       else{
+                               LogDebug("<<< getMatchFullstringClause DIFF >>>");
+                               return FALSE;                                                           
+                       }
+               }
+
                bool StorageChangesMessageGenerator::getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.find(valueString) : " << attrName.find(valueString));
+
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
                        
-                       if(attrName.find(valueString) != std::string::npos)
+                       if(tempString1.find(tempString2) != std::string::npos)
                        {
                                LogDebug("<<< getMatchContainsClause CONTAINS >>>");
                                return TRUE;                            
@@ -281,16 +343,27 @@ namespace TizenApis {
 
                bool StorageChangesMessageGenerator::getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
-                       LogDebug("<<< attrName.compare(0,valueString.size(), valueString) : " << attrName.compare(0,valueString.size(), valueString));
+
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+
+                       LogDebug("<<< attrName : " << tempString1);
+                       LogDebug("<<< valueString : " << tempString2);
 
                        
-                       if(attrName.size()-valueString.size() < 0)
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
                                
-                       if(attrName.compare(0,valueString.size(), valueString) == 0)
+                       if(tempString1.compare(0,tempString2.size(), tempString2) == 0)
                        {
                                LogDebug("<<< getMatchStartwithClause START WITH >>>");
                        return TRUE;
@@ -303,17 +376,27 @@ namespace TizenApis {
 
                bool StorageChangesMessageGenerator::getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value)
                {
+                       std::string tempString1;
+                       std::string tempString2;
+               
                        std::string valueString = value->toString();
 
                        LogDebug("<<< attrName : " << attrName);
                        LogDebug("<<< valueString : " << valueString);
+
+                       tempString1.assign(attrName);
+                       tempString2.assign(valueString);
+
+                       StrLowChange(tempString1);
+                       StrLowChange(tempString2);
+                       
                        LogDebug("<<< attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) : " << attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString));
 
 
-                       if(attrName.size()-valueString.size() < 0)
+                       if(tempString1.size()-tempString2.size() < 0)
                                return FALSE;
                        
-                       if(attrName.compare(attrName.size()-valueString.size(),valueString.size(), valueString) == 0 )
+                       if(tempString1.compare(tempString1.size()-tempString2.size(),tempString2.size(), tempString2) == 0 )
                        {
                                LogDebug("<<< getMatchEndwithClause END WITH >>>");
                                return TRUE;                            
@@ -343,12 +426,23 @@ namespace TizenApis {
                                
                }
 
+               bool StorageChangesMessageGenerator::getMatchExistClause(std::string& attrName)
+               {
+                       LogDebug("<<< attrName : " << attrName);
+                       if(attrName.size()> 0)
+                               return TRUE;
+                       else
+                               return FALSE;
+               }
+
                void StorageChangesMessageGenerator::visitAttribute(std::string& attrName,
                                MatchFlag& matchFlag, Api::Tizen::AnyPtr& matchValue, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
-
-                       if(matchValue == NULL)
+                       if(matchFlag != Api::Tizen::MATCH_EXISTS){
+                               if(matchValue == NULL)  {
                                return;
+                               }
+                       }
 
                        LogDebug("matchValue:" << matchValue->toString());
 
@@ -362,7 +456,37 @@ namespace TizenApis {
                        std::string valueString;
 
 //  Check msg_type and filter_type
-                       if(attrName.compare("type")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID)==0){
+                               LogDebug("<<< value:[" << value << "]");
+                               int nType = atoi(value->toString().c_str());                            
+                               if(m_serviceId == nType)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< Type is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< Type is different");
+                               }
+                               return;
+                       }
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CONVERSATION_ID)==0){
+                               LogDebug("<<< value:[" << value << "]");
+                               int nType = atoi(value->toString().c_str());                            
+                               if(m_conversationId == nType)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< conversationID is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< conversationID is different");
+                               }
+                               return;
+                       }                       
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TYPE)==0){
                                LogDebug("<<< value:[" << value << "]");
                                m_currentType = value->toString();
                                m_messageType = convertMessageType(m_currentType);
@@ -378,10 +502,9 @@ namespace TizenApis {
                                }
                                return;
                                }
-                       if(attrName.compare("folder")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FOLDER_ID)==0){
                                LogDebug("<<< value:[" << value << "]");
-                               std::string convertType = value->toString();
-                               int nType = convertFolderType(convertType);
+                               int nType = atoi(value->toString().c_str());
                                if((int)m_folder == nType)
                                {
                                        m_result.push_back(TRUE);
@@ -394,10 +517,13 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("isRead")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_READ)==0){
                                LogDebug("<<< value:[" << value << "]");
-                               int nType = value->toString().compare("true");
-                               if((int)m_isRead == nType)
+                               std::string lowerString;
+                               lowerString.assign(value->toString());
+                               StrLowChange(lowerString);                              
+                               int nType = lowerString.compare("true");
+                               if((int)m_isRead != nType)
                                {
                                        m_result.push_back(TRUE);
                                        LogDebug("<<< isRead is same");
@@ -409,9 +535,46 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("priority")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_HAS_ATTACHMENT)==0){
+                               LogDebug("<<< value:[" << value << "]");
+                               std::string lowerString;
+                               lowerString.assign(value->toString());
+                               StrLowChange(lowerString);                              
+                               int nType = lowerString.compare("true");
+                               if((int)m_hasAttachment != nType)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< isRead is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< isRead is different");
+                               }
+                               return;
+                       }
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_MESSAGE_STATUS)==0){
                                LogDebug("<<< value:[" << value->toString() << "]");
-                               if(value->toString().compare("true") == 0)
+                               std::string convertStatus = value->toString();
+                               int nStatus = convertMessageStatus(convertStatus);
+                               if((int)m_messageStatus == nStatus)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< folder is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< folder is different");
+                               }
+                               return;
+                       }                       
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY)==0){
+                               LogDebug("<<< value:[" << value->toString() << "]");
+                               std::string lowerString;
+                               lowerString.assign(value->toString());
+                               StrLowChange(lowerString);      
+                               if(lowerString.compare("true"))
                                {
                                        if((int)m_priority == Api::Messaging::MessagePriority::Priority::HIGH)
                                        {
@@ -424,9 +587,9 @@ namespace TizenApis {
                                                LogDebug("<<< priority is LOW OR NORMAL");
                                        }
                                }
-                               else
+                               else if(lowerString.compare("false") == 0)
                                {
-                                       if((int)m_priority == Api::Messaging::MessagePriority::Priority::HIGH)
+                                       if((int)m_priority == Api::Messaging::MessagePriority::Priority::NORMAL)
                                        {
                                                m_result.push_back(FALSE);
                                                LogDebug("<<< priority is HIGH");
@@ -439,7 +602,7 @@ namespace TizenApis {
                                }
                                return;
                        }
-                       if(attrName.compare("body")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BODY)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_body:[" << m_body << "]");
@@ -458,7 +621,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("subject")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_SUBJECT)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_subject:[" << m_subject << "]");
@@ -477,7 +640,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("from")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_FROM)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_from:[" << m_from << "]");
@@ -496,7 +659,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("to")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TO)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_to.size :[" << m_to.size() << "]");
@@ -512,7 +675,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("cc")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_CC)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_cc.size :[" << m_cc.size() << "]");
@@ -528,7 +691,7 @@ namespace TizenApis {
                                return;
                        }
 
-                       if(attrName.compare("bcc")==0){
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_BCC)==0){
                                LogDebug("<<< value:[" << value << "]");
                                LogDebug("<<< value->toString():[" << value->toString() << "]");
                                LogDebug("<<< m_cc.size :[" << m_bcc.size() << "]");
@@ -544,6 +707,21 @@ namespace TizenApis {
                                return;
                        }
 
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_IS_RESPONSE_TO)==0){
+                               LogDebug("<<< value:[" << value << "]");
+                               int nType = atoi(value->toString().c_str());                            
+                               if(m_isResponseTo == nType)
+                               {
+                                       m_result.push_back(TRUE);
+                                       LogDebug("<<< conversationID is same");
+                               }
+                               else
+                               {
+                                       m_result.push_back(FALSE);
+                                       LogDebug("<<< conversationID is different");
+                               }
+                               return;
+                       }
                        LogDebug(">>>");
                }
 
@@ -589,17 +767,65 @@ namespace TizenApis {
                        return retMessageType;
                }
 
+               int StorageChangesMessageGenerator::convertMessageStatus(std::string& stringStatus){
+                       LogDebug("<<< stringType:[" << stringStatus << "]");
+
+                       int retMessageStatus = -1;
+
+                       if(stringStatus.compare("SENT") ==0){
+                               retMessageStatus = Api::Messaging::MESSAGE_STATUS_SENT;
+                       }else if(stringStatus.compare("SENDING") ==0){
+                               retMessageStatus = Api::Messaging::MESSAGE_STATUS_SENDING;
+                       }else if(stringStatus.compare("FAILED") ==0){
+                               retMessageStatus = Api::Messaging::MESSAGE_STATUS_FAILED;
+                       }else if(stringStatus.compare("DRAFT") ==0){
+                               retMessageStatus = Api::Messaging::MESSAGE_STATUS_DRAFT;
+                       }else{
+                               LogError("invalid type:[" << stringStatus << "]");
+                               return -1;
+                       }
+
+                       LogDebug(">>> retMessageType:" << retMessageStatus);
+                       return retMessageStatus;
+               }
+
                void StorageChangesMessageGenerator::visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth) {
                        struct tm startTime;
                        struct tm endTime;
                        bool result = FALSE;
 
+                       string initialValueStr;
+                       string endValueStr;
+
                        if(initialValue == NULL || endValue == NULL)
                                return;
 
-                       if(attrName.compare("timestamp")==0){
-                               startTime = convertToTimeFormat(initialValue->toString());
-                               endTime = convertToTimeFormat(endValue->toString());
+                       if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
+//                             startTime = convertToTimeFormat(initialValueStr);
+//                             endTime = convertToTimeFormat(endValueStr);
+
+                               if (!initialValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==initialValue->getType() ) {
+                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
+                                               startTime = initialValue->getDateTm();
+                                       }
+                                       else {
+                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
+                                       }
+                               }
+                               
+                               if (!endValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==endValue->getType() ) {
+                                               LogDebug("<<<initialValue->getType()[" << endValue->getType() <<"]");                                   
+                                               endTime = endValue->getDateTm();
+                                               LogDebug("<<<valueStr[" << endValueStr <<"]");                                  
+                                       } else {
+                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
+                                       }
+                               }
+
                                result = getBetweenRangeClause(startTime, endTime);
                                if(result == TRUE)
                                {
@@ -619,6 +845,9 @@ namespace TizenApis {
                        if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
+                       }else if(matchFlag == Api::Tizen::MATCH_FULLSTRING){
+                               LogDebug("STRING_MATCH_FULLSTRING");
+                               result = result || getMatchFullstringClause(valueString, value);                                                
                        }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
@@ -628,6 +857,9 @@ namespace TizenApis {
                        }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
+                       }else if(matchFlag == Api::Tizen::MATCH_EXISTS){
+                               LogDebug("STRING_MATCH_EXIST");
+                               result = result || getMatchExistClause(valueString);
                        }else{
                                LogDebug("[ERROR]invalid match flag : iter:" << *iter);
                        }
@@ -643,6 +875,14 @@ namespace TizenApis {
                        LogDebug("result = " << result);        
                        return result;
                }
+
+               void StorageChangesMessageGenerator::StrLowChange(std::string& tempString)
+               {       
+                       std::transform(tempString.begin(), tempString.end(), tempString.begin(), ::tolower);
+                       return;
+               }
+
+
        }
        }               //namespace Platform
 }              //namespace WrtPlugins
index 1ea3a5a..107bb08 100755 (executable)
@@ -47,7 +47,7 @@ namespace TizenApis {
                                        operandIntersection = 4
                                };
                                
-                               StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg);
+                               StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg, Api::Messaging::IConversationPtr convconv);
                                virtual ~StorageChangesMessageGenerator();
 
                                void visitPreComposite(Api::Tizen::FilterType& type, int depth);
@@ -65,13 +65,16 @@ namespace TizenApis {
                        private:
                                std::string convertToEmfAttrName(std::string attrName);
                                bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
+                               bool getMatchFullstringClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
+                               bool getMatchExistClause(std::string& attrName);                                
                                bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
 
                                void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
                                int convertMessageType(std::string& stringType);
+                               int convertMessageStatus(std::string& stringStatus);                            
                                int convertFolderType(std::string& stringType);                         
 
                                struct tm convertToTimeFormat(const std::string& timeString);                   
@@ -81,6 +84,7 @@ namespace TizenApis {
                                std::string createDateTimeType(Api::Tizen::AnyPtr& value);
                                void initAttributeMap();
 
+                               void StrLowChange(std::string& tempString);
 
                        private:
                                int m_messageType;
@@ -104,6 +108,13 @@ namespace TizenApis {
                                Api::Messaging::MessagePriority::Priority m_priority;
                                std::string m_subject;
 
+//new attribute
+                               int m_serviceId;
+                               int m_conversationId;
+                               int m_isResponseTo;
+                               Api::Messaging::MessageStatus  m_messageStatus;
+                               bool m_hasAttachment;
+
                                Api::Messaging::RecipientsPtr Recipents;
                                std::string m_currentType;
 
index 5c943a9..230c63c 100755 (executable)
@@ -84,6 +84,10 @@ void VirtualMessage::updateIsRead()
 {
 }
 
+void VirtualMessage::updateMessage()
+{
+}
+
 void VirtualMessage::addMessageToDraft()
 {
 }
index 5f9fd43..912fef7 100755 (executable)
@@ -77,6 +77,8 @@ class VirtualMessage :
 
     void updateIsRead();       
 
+    void updateMessage();      
+
     void addMessageToDraft();
        
 };
index 48d8763..5f78f81 100755 (executable)
@@ -28,13 +28,29 @@ class EventNFCTemplate : public WrtDeviceApis::Commons::IEvent<templateClass>
 {
 protected:
        bool result;
+       std::string errorName;
+       std::string errorMessage;
 public:
        void setResult(const bool value) {result = value;}
        bool getResult() const {return result;}
-
-       EventNFCTemplate() { }
+       void setError(const std::string &error) { errorName= error;}
+       void setErrorMessage(const std::string &message) { errorMessage= message;}
+       std::string getError() {return errorName;}
+       std::string getErrorMessage() {return errorMessage;}
+       EventNFCTemplate() :result(true), errorName(""), errorMessage("") { }
 };
 
+template <class templateEventClass>
+class EventNFCPtrs
+{
+private:
+       DPL::SharedPtr<templateEventClass> eventPtr;
+       void * thisPtr;
+public:
+       DPL::SharedPtr<templateEventClass> getEventPtrs() const {return eventPtr;}
+       void *getThisPtr() {return thisPtr;}
+       EventNFCPtrs(const DPL::SharedPtr<templateEventClass> &event, void *myPtr) : eventPtr(event), thisPtr(myPtr) {}
+};
 
 } // NFC
 } // Api
index 5fceaf6..1b73570 100755 (executable)
 #include <dpl/shared_ptr.h>
 #include <Commons/ListenerEvent.h>
 #include <Commons/ListenerEventEmitter.h>
+#include "EventNFC.h"
 
 namespace TizenApis {
 namespace Api {
 namespace NFC {
 enum EventNFCType {
        NFC_TAG_TYPE,
-       NFC_TAG_MIFARE_CLASSIC_TYPE,
-       NFC_TAG_MIFARE_ULTRA_TYPE,
        NFC_TARGET_TYPE
 };
 enum EventNFCStatus {
        NFC_ATTATCHED,
        NFC_DETATCHED
 };
-enum nfcSeEventType {
-       NFC_SE_EVENTTYPE_START_TRANSACTION,
-       NFC_SE_EVENTTYPE_END_TRANSACTION,
-       NFC_SE_EVENTTYPE_CONNECTIVITY,
-       NFC_SE_EVENTTYPE_FIELD_ON,
-       NFC_SE_EVENTTYPE_FIELD_OFF
-};
 
 class EventNFCChanged : public WrtDeviceApis::Commons::ListenerEvent<EventNFCChanged>
 {
 private:
        void  *m_props;
-       void *privNFCManager;
+       void *privNFCAdapter;
        EventNFCType m_type;
        EventNFCStatus m_status;
 public:
        void *getNFCProperties() { return m_props; }
        void setNFCProperties(void *props) { m_props = props; }
-       void setPrivateNFCManagerPtr(void* priv) {privNFCManager = priv;}
-        void *getPrivateNFCManagerPtr() {return privNFCManager;}
+       void setPrivateNFCAdapterPtr(void* priv) {privNFCAdapter = priv;}
+        void *getPrivateNFCAdapterPtr() {return privNFCAdapter;}
         EventNFCType getNFCType() const {return m_type;}
         void setNFCType(const EventNFCType type) {m_type = type;}
         EventNFCStatus getNFCStatus() const {return m_status;}
         void setNFCStatus(const EventNFCStatus type) {m_status = type;}         
        EventNFCChanged() {}
 };
-
-class EventNFCChangedNdef : public WrtDeviceApis::Commons::ListenerEvent<EventNFCChangedNdef>
-{
-private:
-       std::vector<unsigned char> rawData;
-public:
-       void setReadNdefResult(std::vector<unsigned char> result) {rawData = result;}
-       std::vector<unsigned char> getReadNdefResult()  {return rawData;}
-       EventNFCChangedNdef(){ }
-};
-
-class EventNFCChangedSeEvent : public WrtDeviceApis::Commons::ListenerEvent<EventNFCChangedSeEvent>
+class EventNFCChangedSetPowered : public EventNFCTemplate<EventNFCChangedSetPowered>
 {
 private:
-       nfcSeEventType eventType;
+       bool powerState;
 public:
-       void setSeEvent(nfcSeEventType event) {eventType = event;}
-       nfcSeEventType getSeEvent()  {return eventType;}
-       EventNFCChangedSeEvent(){ }
+       bool getState()  {return powerState;}
+       EventNFCChangedSetPowered(bool state): powerState(state) { }
 };
 
 typedef DPL::SharedPtr<EventNFCChanged> EventNFCChangedPtr;
 typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventNFCChanged> EventNFCChangedEmitter;
 typedef DPL::SharedPtr<EventNFCChangedEmitter> EventNFCChangedEmitterPtr;
-
-typedef DPL::SharedPtr<EventNFCChangedNdef> EventNFCChangedNdefPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventNFCChangedNdef> EventNFCChangedNdefEmitter;
-typedef DPL::SharedPtr<EventNFCChangedNdefEmitter> EventNFCChangedNdefEmitterPtr;
-
-typedef DPL::SharedPtr<EventNFCChangedSeEvent> EventNFCChangedSeEventPtr;
-typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventNFCChangedSeEvent> EventNFCChangedSeEventEmitter;
-typedef DPL::SharedPtr<EventNFCChangedSeEventEmitter> EventNFCChangedSeEventEmitterPtr;
-
+typedef DPL::SharedPtr<EventNFCChangedSetPowered> EventNFCChangedSetPoweredPtr;
 } // NFC
 } // Api
 } // TizenApis
diff --git a/src/platform/API/NFC/EventTagMifareClassicAction.h b/src/platform/API/NFC/EventTagMifareClassicAction.h
deleted file mode 100755 (executable)
index 15f18be..0000000
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef WRTPLUGINS_API_NFC_EVENT_TAGMIFARECLASSIC_ACTION_H_
-#define WRTPLUGINS_API_NFC_EVENT_TAGMIFARECLASSIC_ACTION_H_
-
-#include <vector>
-#include "EventNFC.h"
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace NFC {
-
-template <class templateClass>
-class EventTagMifareClassicAuthenticate : public EventNFCTemplate<templateClass>
-{
-protected:
-       std::vector<unsigned char> key;
-       int sectorIndex;
-       void setKey(const std::vector<unsigned char> &keyValue) {key = keyValue;}
-       void setSectorIndex(const int index) {sectorIndex = index;}
-public:
-       std::vector<unsigned char> getKey() const {return key;}
-       int getSectorIndex() const {return sectorIndex;}
-       EventTagMifareClassicAuthenticate() { }
-};
-
-class EventTagMifareClassicAuthenticateWithKeyA : public EventTagMifareClassicAuthenticate<EventTagMifareClassicAuthenticateWithKeyA>
-{
-public:
-       EventTagMifareClassicAuthenticateWithKeyA(const std::vector<unsigned char> &keyValue, const int index) {
-               setKey(keyValue);
-               setSectorIndex(index);
-       }
-};
-
-class EventTagMifareClassicAuthenticateWithKeyB : public EventTagMifareClassicAuthenticate<EventTagMifareClassicAuthenticateWithKeyB>
-{
-public:
-       EventTagMifareClassicAuthenticateWithKeyB(const std::vector<unsigned char> &keyValue, const int index) {
-               setKey(keyValue);
-               setSectorIndex(index);
-       }
-};
-
-template <class templateBlockActionClass>
-class EventTagMifareClassicBlockAction : public EventNFCTemplate<templateBlockActionClass>
-{
-       protected:
-               int blockIndex;
-               void setBlockIndex(const int index) {blockIndex = index;}
-       public:
-               EventTagMifareClassicBlockAction() {}
-               int getIndex() const {return blockIndex;}
-};
-
-class EventTagMifareClassicReadBlock : public EventTagMifareClassicBlockAction<EventTagMifareClassicReadBlock>
-{
-       private:
-               std::vector<unsigned char> blockData;
-       public:
-               EventTagMifareClassicReadBlock(const int index) {setBlockIndex(index);}
-               void setBlockData(const std::vector<unsigned char> data) {blockData = data;}
-               std::vector<unsigned char> getBlockData() const {return blockData;}
-};
-
-class EventTagMifareClassicWriteBlock : public EventTagMifareClassicBlockAction<EventTagMifareClassicWriteBlock>
-{
-       private:
-               std::vector<unsigned char> blockData;
-       public:
-               EventTagMifareClassicWriteBlock(const int index, const std::vector<unsigned char> data) : blockData(data) {setBlockIndex(index);}
-               std::vector<unsigned char> getBlockData() const {return blockData;}
-};
-
-class EventTagMifareClassicIncrementBlockValue : public EventTagMifareClassicBlockAction<EventTagMifareClassicIncrementBlockValue>
-{
-       private:
-               int blockValue;
-       public:
-               EventTagMifareClassicIncrementBlockValue(const int index, const int value) : blockValue(value) {setBlockIndex(index);}
-               int getValue() const {return blockValue;}
-};
-
-class EventTagMifareClassicDecrementBlockValue : public EventTagMifareClassicBlockAction<EventTagMifareClassicDecrementBlockValue>
-{
-       private:
-               int blockValue;
-       public:
-               EventTagMifareClassicDecrementBlockValue(const int index, const int value) : blockValue(value) {setBlockIndex(index);}
-               int getValue() const {return blockValue;}
-};
-
-class EventTagMifareClassicTransfer : public EventTagMifareClassicBlockAction<EventTagMifareClassicTransfer>
-{
-       public:
-               EventTagMifareClassicTransfer(const int index) {setBlockIndex(index);}
-};
-
-class EventTagMifareClassicRestore : public EventTagMifareClassicBlockAction<EventTagMifareClassicRestore>
-{
-       public:
-               EventTagMifareClassicRestore(const int index) {setBlockIndex(index);}
-};
-
-typedef DPL::SharedPtr<EventTagMifareClassicAuthenticateWithKeyA> EventTagMifareClassicAuthenticateWithKeyAPtr;
-typedef DPL::SharedPtr<EventTagMifareClassicAuthenticateWithKeyB> EventTagMifareClassicAuthenticateWithKeyBPtr;
-typedef DPL::SharedPtr<EventTagMifareClassicReadBlock> EventTagMifareClassicReadBlockPtr;
-typedef DPL::SharedPtr<EventTagMifareClassicWriteBlock> EventTagMifareClassicWriteBlockPtr;
-typedef DPL::SharedPtr<EventTagMifareClassicIncrementBlockValue> EventTagMifareClassicIncrementBlockValuePtr;
-typedef DPL::SharedPtr<EventTagMifareClassicDecrementBlockValue> EventTagMifareClassicDecrementBlockValuePtr;
-typedef DPL::SharedPtr<EventTagMifareClassicTransfer> EventTagMifareClassicTransferPtr;
-typedef DPL::SharedPtr<EventTagMifareClassicRestore> EventTagMifareClassicRestorePtr;
-
-} // NFC
-} // Api
-} // TizenApis
-
-#endif //WRTPLUGINS_API_NFC_EVENT_TAGMIFARECLASSIC_ACTION_H_
diff --git a/src/platform/API/NFC/EventTagMifareUltraAction.h b/src/platform/API/NFC/EventTagMifareUltraAction.h
deleted file mode 100755 (executable)
index c2527cd..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef WRTPLUGINS_API_NFC_EVENT_TAGMIFAREULTRA_ACTION_H_
-#define WRTPLUGINS_API_NFC_EVENT_TAGMIFAREULTRA_ACTION_H_
-
-#include <vector>
-#include "EventNFC.h"
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Api {
-namespace NFC {
-
-template <class templateClass>
-class EventTagMifareUltraPageAction : public EventNFCTemplate<templateClass>
-{
-       protected:
-               int pageIndex;
-               std::vector<unsigned char> pageData;
-               void setIndex(const int index) {pageIndex = index;}
-               void setPage(const std::vector<unsigned char> page) {pageData = page;}
-               const std::vector<unsigned char> getPage() const {return pageData;}
-       public:
-               EventTagMifareUltraPageAction() {}
-               
-};
-class EventTagMifareUltraReadPage : public EventTagMifareUltraPageAction<EventTagMifareUltraReadPage>
-{
-       public:
-               EventTagMifareUltraReadPage(const int index) {setIndex(index);}
-               int getIndex() const {return pageIndex;}
-               void setReadPageResult(const std::vector<unsigned char> page) {setPage(page);}
-               const std::vector<unsigned char> getReadPageResult() const {return getPage();}                          
-};
-
-class EventTagMifareUltraWritePage : public EventTagMifareUltraPageAction<EventTagMifareUltraWritePage>
-{
-       public:
-               EventTagMifareUltraWritePage(const int index, const std::vector<unsigned char> data) 
-               {
-                       setIndex(index);
-                       setPage(data);
-               }
-               int getIndex() const {return pageIndex;}
-               std::vector<unsigned char> getPageForWriting() const {return getPage();}        
-};
-
-
-typedef DPL::SharedPtr<EventTagMifareUltraReadPage> EventTagMifareUltraReadPagePtr;
-typedef DPL::SharedPtr<EventTagMifareUltraWritePage> EventTagMifareUltraWritePagePtr;
-
-} // NFC
-} // Api
-} // TizenApis
-
-#endif //WRTPLUGINS_API_NFC_EVENT_TAGMIFAREULTRA_ACTION_H_
\ No newline at end of file
similarity index 80%
rename from src/platform/API/NFC/INFCManager.cpp
rename to src/platform/API/NFC/INFCAdapter.cpp
index d54c77f..179db52 100755 (executable)
@@ -15,7 +15,7 @@
  */\r
 \r
 \r
-#include "INFCManager.h"\r
+#include "INFCAdapter.h"\r
 \r
 namespace TizenApis {\r
 namespace Api {\r
@@ -23,10 +23,11 @@ namespace NFC {
 \r
 using namespace WrtDeviceApis::Commons;\r
 \r
-INFCManager::INFCManager() {\r
+INFCAdapter::INFCAdapter() :\r
+       EventNFCSetPoweredRequestReceiver(ThreadEnum::NFC_THREAD) {\r
 }\r
 \r
-INFCManager::~INFCManager() {\r
+INFCAdapter::~INFCAdapter() {\r
 }\r
 \r
 }\r
similarity index 62%
rename from src/platform/API/NFC/INFCManager.h
rename to src/platform/API/NFC/INFCAdapter.h
index 338d46d..c60b4e1 100755 (executable)
@@ -16,8 +16,8 @@
 
 
 
-#ifndef _ABSTRACT_LAYER_INFCMANAGER_H_
-#define _ABSTRACT_LAYER_INFCMANAGER_H_
+#ifndef _ABSTRACT_LAYER_INFCADAPTER_H_
+#define _ABSTRACT_LAYER_INFCADAPTER_H_
 
 #include <dpl/shared_ptr.h>
 #include <vector>
 #include "EventNFCChanged.h"
 #include "TagFilter.h"
 
+typedef WrtDeviceApis::Commons::EventRequestReceiver<TizenApis::Api::NFC::EventNFCChangedSetPowered> EventNFCSetPoweredRequestReceiver;
+
 namespace TizenApis {
 namespace Api {
 namespace NFC {
 
-class INFCManager
+class INFCAdapter :
+               public EventNFCSetPoweredRequestReceiver
 {
     public:
 
-    virtual                     ~INFCManager();
+    virtual                     ~INFCAdapter();
        virtual int setTagListener(const EventNFCChangedEmitterPtr& emitter,    TagFilterPtr filter, void *managerPriv) = 0;
        virtual void unsetTagListener() = 0;
        virtual int setPeerListener(const EventNFCChangedEmitterPtr& emitter,   void *managerPriv) = 0;
        virtual void unsetPeerListener() = 0;
-       virtual int setNDEFListener(const EventNFCChangedNdefEmitterPtr& emitter) = 0;
-       virtual void unsetNDEFListener() = 0;
-       virtual int setSEEventListener(const EventNFCChangedSeEventEmitterPtr& emitter) = 0;
-       virtual void unsetSEEventListener() = 0;
-
-       virtual void NFCHasDetected(void *props, EventNFCType type) = 0;
-       virtual void NDEFHasDetected(std::vector<unsigned char> data) = 0;
-       virtual void SeEventHasDetected(nfcSeEventType event) = 0;
-
        virtual void *getCachedMessage() = 0;
        virtual bool isValidHandle(void * handle) = 0;
-       virtual void updateCurrentHandle(void *handle) = 0;
+
+       virtual bool getPowerState() = 0;
+       virtual void setPowered(const EventNFCChangedSetPoweredPtr& event) = 0;
+
+       virtual void deinitialze() = 0;
 protected:
-    INFCManager();
+        INFCAdapter();
+       virtual void OnRequestReceived(const EventNFCChangedSetPoweredPtr& event) = 0;
        void *curHandle;
 };
 
-typedef DPL::SharedPtr<INFCManager> INFCManagerPtr;
+typedef DPL::SharedPtr<INFCAdapter> INFCAdapterPtr;
 
 }
 }
 }
 
-#endif /* _ABSTRACT_LAYER_INFCMANAGER_H_ */
+#endif /* _ABSTRACT_LAYER_INFCADAPTER_H_ */
index 25f30ca..d577a4c 100755 (executable)
@@ -70,13 +70,8 @@ class INFCTag :
        virtual void transceive(const EventTagActionTransceivePtr& event) = 0;
        virtual void format(const EventTagActionFormatPtr& event) = 0;
 
-       virtual void readNdefManualAnswer(int result , std::vector<unsigned char> data) = 0;
-       virtual void writeNdefManualAnswer(int result) = 0;
-       virtual void transceiveManualAnswer(int result , std::vector<unsigned char> data) = 0;
-       virtual void formatManualAnswer(int result) = 0;
-
-       virtual void setPrivateNFCManagerPtr(void* priv) {privNFCManager = priv;}
-       virtual void *getPrivateNFCManagerPtr() {return privNFCManager;}
+       virtual void setPrivateNFCAdapterPtr(void* priv) {privNFCAdapter = priv;}
+       virtual void *getPrivateNFCAdapterPtr() {return privNFCAdapter;}
     protected:
                INFCTag();
                virtual void OnRequestReceived(const EventTagActionReadPtr& event) = 0;
@@ -84,7 +79,7 @@ class INFCTag :
                virtual void OnRequestReceived(const EventTagActionTransceivePtr& event) = 0;
                virtual void OnRequestReceived(const EventTagActionFormatPtr& event) = 0;
 
-               void *privNFCManager;
+               void *privNFCAdapter;
 };
 
 typedef DPL::SharedPtr<INFCTag> INFCTagPtr;
diff --git a/src/platform/API/NFC/INFCTagMifareClassic.cpp b/src/platform/API/NFC/INFCTagMifareClassic.cpp
deleted file mode 100755 (executable)
index cd01edf..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*\r
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License. \r
- */\r
-\r
-\r
-#include "INFCTagMifareClassic.h"\r
-\r
-namespace TizenApis {\r
-namespace Api {\r
-namespace NFC {\r
-using namespace WrtDeviceApis::Commons;\r
-\r
-INFCTagMifareClassic::INFCTagMifareClassic() : Platform::NFC::NFCTag(NULL),\r
-               EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyA>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyB>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicReadBlock>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicWriteBlock>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicIncrementBlockValue>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicDecrementBlockValue>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicTransfer>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareClassicRestore>(ThreadEnum::NFC_THREAD) {\r
-               \r
-}\r
-\r
-INFCTagMifareClassic::~INFCTagMifareClassic() {\r
-}\r
-\r
-}\r
-}\r
-}\r
diff --git a/src/platform/API/NFC/INFCTagMifareClassic.h b/src/platform/API/NFC/INFCTagMifareClassic.h
deleted file mode 100755 (executable)
index e3f5bff..0000000
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-#ifndef _ABSTRACT_LAYER_NFCTAGMIFARECLASSIC_H_
-#define _ABSTRACT_LAYER_NFCTAGMIFARECLASSIC_H_
-
-#include <dpl/shared_ptr.h>
-#include <vector>
-#include <Commons/ThreadPool.h>
-#include "EventTagMifareClassicAction.h"
-#include <NFC/NFCTag.h>
-
-namespace TizenApis {
-namespace Api {
-namespace NFC {
-using namespace WrtDeviceApis::Commons;
-
-class INFCTagMifareClassic : public Platform::NFC::NFCTag,
-               public EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyA>,
-               public EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyB>,
-               public EventRequestReceiver<EventTagMifareClassicReadBlock>,
-               public EventRequestReceiver<EventTagMifareClassicWriteBlock>,
-               public EventRequestReceiver<EventTagMifareClassicIncrementBlockValue>,
-               public EventRequestReceiver<EventTagMifareClassicDecrementBlockValue>,
-               public EventRequestReceiver<EventTagMifareClassicTransfer>,
-               public EventRequestReceiver<EventTagMifareClassicRestore>
-{
-    public:
-
-       
-       virtual                     ~INFCTagMifareClassic();
-       virtual void authenticateWithKeyA(const EventTagMifareClassicAuthenticateWithKeyAPtr& event) = 0;
-       virtual void authenticateWithKeyB(const EventTagMifareClassicAuthenticateWithKeyBPtr& event) = 0;
-       virtual void readBlock(const EventTagMifareClassicReadBlockPtr& event) = 0;
-       virtual void writeBlock(const EventTagMifareClassicWriteBlockPtr& event) = 0;
-       virtual void incrementBlockValue(const EventTagMifareClassicIncrementBlockValuePtr& event) = 0;
-       virtual void decrementBlockValue(const EventTagMifareClassicDecrementBlockValuePtr& event) = 0;
-       virtual void transfer(const EventTagMifareClassicTransferPtr& event) = 0;
-       virtual void restore(const EventTagMifareClassicRestorePtr& event) = 0;
-       virtual void authenticateWithKeyAManualAnswer(int result) = 0;
-       virtual void authenticateWithKeyBManualAnswer(int result) = 0;
-       virtual void readBlockManualAnswer(int result , std::vector<unsigned char> data) = 0;
-       virtual void writeBlockManualAnswer(int result ) = 0;
-       virtual void incrementBlockValueManualAnswer(int result) = 0;
-       virtual void decrementBlockValueManualAnswer(int result ) = 0;
-       virtual void transferManualAnswer(int result ) = 0;
-       virtual void restoreManualAnswer(int result ) = 0;
-    protected:
-               INFCTagMifareClassic();
-               virtual void OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyAPtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyBPtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicReadBlockPtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicWriteBlockPtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicIncrementBlockValuePtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicDecrementBlockValuePtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicTransferPtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareClassicRestorePtr& event) = 0;
-};
-
-typedef DPL::SharedPtr<INFCTagMifareClassic> INFCTagMifareClassicPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_NFCTAGMIFARECLASSIC_H_ */
diff --git a/src/platform/API/NFC/INFCTagMifareUltra.cpp b/src/platform/API/NFC/INFCTagMifareUltra.cpp
deleted file mode 100755 (executable)
index a725038..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*\r
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
- *\r
- * Licensed under the Apache License, Version 2.0 (the License);\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- * http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an AS IS BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License. \r
- */\r
-\r
-\r
-#include "INFCTagMifareUltra.h"\r
-\r
-namespace TizenApis {\r
-namespace Api {\r
-namespace NFC {\r
-using namespace WrtDeviceApis::Commons;\r
-\r
-INFCTagMifareUltra::INFCTagMifareUltra() : Platform::NFC::NFCTag(NULL),\r
-               EventRequestReceiver<EventTagMifareUltraReadPage>(ThreadEnum::NFC_THREAD),\r
-               EventRequestReceiver<EventTagMifareUltraWritePage>(ThreadEnum::NFC_THREAD) {\r
-               \r
-}\r
-\r
-INFCTagMifareUltra::~INFCTagMifareUltra() {\r
-}\r
-\r
-}\r
-}\r
-}\r
diff --git a/src/platform/API/NFC/INFCTagMifareUltra.h b/src/platform/API/NFC/INFCTagMifareUltra.h
deleted file mode 100755 (executable)
index cbebcac..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-#ifndef _ABSTRACT_LAYER_NFCTTAGMIFAREULTRA_H_
-#define _ABSTRACT_LAYER_NFCTTAGMIFAREULTRA_H_
-
-#include <dpl/shared_ptr.h>
-#include <vector>
-#include <Commons/ThreadPool.h>
-#include "EventTagMifareUltraAction.h"
-#include <NFC/NFCTag.h>
-
-namespace TizenApis {
-namespace Api {
-namespace NFC {
-using namespace WrtDeviceApis::Commons;
-
-class INFCTagMifareUltra : public Platform::NFC::NFCTag,
-               public EventRequestReceiver<EventTagMifareUltraReadPage>,
-               public EventRequestReceiver<EventTagMifareUltraWritePage>
-{
-    public:
-
-       
-       virtual                     ~INFCTagMifareUltra();
-       virtual void readPage(const EventTagMifareUltraReadPagePtr& event) = 0;
-       virtual void writePage(const EventTagMifareUltraWritePagePtr& event) = 0;
-       virtual void readPageManualAnswer(int result , std::vector<unsigned char> data) = 0;
-       virtual void writePageManualAnswer(int result) = 0;
-    protected:
-               INFCTagMifareUltra();
-               virtual void OnRequestReceived(const EventTagMifareUltraReadPagePtr& event) = 0;
-               virtual void OnRequestReceived(const EventTagMifareUltraWritePagePtr& event) = 0;
-};
-
-typedef DPL::SharedPtr<INFCTagMifareUltra> INFCTagMifareUltraPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_NFCTTAGMIFAREULTRA_H_ */
index 49f68ac..de19b09 100755 (executable)
@@ -38,16 +38,14 @@ class INFCTarget : public EventRequestReceiver<EventTargetActionSend>
        virtual                     ~INFCTarget();
        virtual void *getHandle() = 0;
        virtual void setReceiveNDEFListener(const EventTargetActionReceiveEmitterPtr& event) = 0;
-       virtual void receiveNdef(std::vector<unsigned char>messageData) = 0;
        virtual void unsetReceiveNDEFListener() = 0;
        virtual void sendNDEF(const EventTargetActionSendPtr& event) = 0;
-       virtual void sendNDEFManualAnswer(unsigned int result) = 0;
-       virtual void setPrivateNFCManagerPtr(void* priv) {privNFCManager = priv;}
-       virtual void *getPrivateNFCManagerPtr() {return privNFCManager;}
+       virtual void setPrivateNFCAdapterPtr(void* priv) {privNFCAdapter = priv;}
+       virtual void *getPrivateNFCAdapterPtr() {return privNFCAdapter;}
     protected:
                INFCTarget();
                virtual void OnRequestReceived(const EventTargetActionSendPtr& event) = 0;
-               void *privNFCManager;
+               void *privNFCAdapter;
 };
 
 typedef DPL::SharedPtr<INFCTarget> INFCTargetPtr;
index ba89efc..e93e936 100755 (executable)
@@ -38,10 +38,10 @@ class INdefMessage
        virtual std::vector<unsigned char> toByte()= 0;
        virtual long getRecordCount() = 0;
        virtual NdefRecordData getNDEFRecord(const long index) = 0;
-       virtual bool insertNDEFRecord(const long index, const void *recordHandle) = 0;
-       virtual bool appendNDEFRecord(const void *recordHandle) = 0;
+       virtual bool insertNDEFRecord(const long index, void *recordHandle) = 0;
+       virtual bool appendNDEFRecord(void *recordHandle) = 0;
        virtual bool removeNDEFRecord(const long index) = 0;
-       virtual void changeAllRecords(const std::vector<void *> ndefRcords) = 0;
+       virtual void changeAllRecords(std::vector<void *> ndefRcords) = 0;
 };
 
 typedef DPL::SharedPtr<INdefMessage> INdefMessagePtr;
index d803478..962336b 100755 (executable)
@@ -39,6 +39,7 @@ class INdefRecord
        virtual std::vector<unsigned char> getTypeName() = 0;
        virtual std::vector<unsigned char> getID() = 0;
        virtual std::vector<unsigned char> getPayload() = 0;
+       virtual std::vector<unsigned char> toByte() = 0;
        virtual bool getText(char **text) = 0;
        virtual bool getLangCode(char **landCode) = 0;
        virtual bool getEncodeType(nfcTextEncodeUTF *encodeType) = 0;
index c189c76..cf384e4 100755 (executable)
 
 #include "NFCFactory.h"
 
-#include <NFC/NFCManager.h>
+#include <NFC/NFCAdapter.h>
 #include <NFC/NdefMessage.h>
 #include <NFC/NdefRecord.h>
 #include <NFC/NFCTag.h>
-#include <NFC/NFCTagMifareClassic.h>
-#include <NFC/NFCTagMifareUltra.h>
 #include <NFC/NFCTarget.h>
 
 namespace TizenApis {
 namespace Api {
 namespace NFC {
 
-INFCManagerPtr NFCFactory::createNFCManagerObject() {
-       return INFCManagerPtr( new Platform::NFC::NFCManager() );
+INFCAdapterPtr NFCFactory::createNFCAdapterObject() {
+       return INFCAdapterPtr( new Platform::NFC::NFCAdapter() );
 }
 
 INdefMessagePtr NFCFactory::createNDEFMessageObject() {
@@ -53,6 +51,10 @@ INdefRecordPtr NFCFactory::createNDEFRecordObject() {
        return INdefRecordPtr( new Platform::NFC::NdefRecord() );
 }
 
+INdefRecordPtr NFCFactory::createNDEFRecordObject(std::vector<unsigned char> data) {
+       return INdefRecordPtr( new Platform::NFC::NdefRecord(data) );
+}
+
 INdefRecordPtr NFCFactory::createNDEFRecordObject(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload) {
        return INdefRecordPtr( new Platform::NFC::NdefRecord(ndefRecordProperties, payload) );
 }
@@ -73,14 +75,6 @@ INFCTagPtr NFCFactory::createNFCTagObject(void *tagHandle) {
        return INFCTagPtr( new Platform::NFC::NFCTag(tagHandle));
 }
 
-INFCTagMifareClassicPtr NFCFactory::createNFCTagMifareClassicObject(void *tagHandle) {
-       return INFCTagMifareClassicPtr( new Platform::NFC::NFCTagMifareClassic(tagHandle));
-}
-
-INFCTagMifareUltraPtr NFCFactory::createNFCTagMifareUltraObject(void *tagHandle) {
-       return INFCTagMifareUltraPtr( new Platform::NFC::NFCTagMifareUltra(tagHandle));
-}
-
 INFCTargetPtr NFCFactory::createNFCTargetObject(void *targetHandle) {
        return INFCTargetPtr( new Platform::NFC::NFCTarget(targetHandle));
 }
index eaac901..150cc56 100755 (executable)
 #define WRTPLUGINS_API_NFCFACTORY_H_
 
 #include <dpl/noncopyable.h>
-#include "INFCManager.h"
+#include "INFCAdapter.h"
 #include "INdefMessage.h"
 #include "INdefRecord.h"
 #include "INFCTag.h"
-#include "INFCTagMifareClassic.h"
-#include "INFCTagMifareUltra.h"
 #include "INFCTarget.h"
 
 namespace TizenApis {
@@ -39,20 +37,20 @@ private:
      */
     NFCFactory(){;}
 public:
-       INFCManagerPtr createNFCManagerObject();
+       INFCAdapterPtr createNFCAdapterObject();
        INdefMessagePtr createNDEFMessageObject();
        INdefMessagePtr createNDEFMessageObject(void *messageHandle);
        INdefMessagePtr createNDEFMessageObject(std::vector<void *> ndefRcords);
        INdefMessagePtr createNDEFMessageObject(std::vector<unsigned char> rawdata);
        INdefRecordPtr createNDEFRecordObject();
+       INdefRecordPtr createNDEFRecordObject(std::vector<unsigned char> data);
        INdefRecordPtr createNDEFRecordObject(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
        INdefRecordPtr createNDEFRecordObject(const std::string &text, const std::string &langCode, const short encodeType);
        INdefRecordPtr createNDEFRecordObject(const std::string &uri);
        INdefRecordPtr createNDEFRecordObject(const std::string &mimeType, const std::vector<unsigned char> data);
        INFCTagPtr createNFCTagObject(void *tagHandle);
-       INFCTagMifareClassicPtr createNFCTagMifareClassicObject(void *tagHandle);
-       INFCTagMifareUltraPtr createNFCTagMifareUltraObject(void *tagHandle);
        INFCTargetPtr createNFCTargetObject(void *targetHandle);
+
        static NFCFactory& getInstance();
 
 };
index da36668..32d5bfe 100755 (executable)
@@ -2,10 +2,8 @@ get_current_path()
 
 set(SRCS_PLATFORM_API_NFC
   ${CURRENT_PATH}/NFCFactory.cpp
-  ${CURRENT_PATH}/INFCManager.cpp
+  ${CURRENT_PATH}/INFCAdapter.cpp
   ${CURRENT_PATH}/INFCTag.cpp
-  ${CURRENT_PATH}/INFCTagMifareClassic.cpp
-  ${CURRENT_PATH}/INFCTagMifareUltra.cpp
   ${CURRENT_PATH}/TagFilter.cpp  
   ${CURRENT_PATH}/INFCTarget.cpp
   PARENT_SCOPE
index 4f8f43a..0d95371 100644 (file)
@@ -99,6 +99,11 @@ int EventWatchSysteminfo::getId() const
     return m_id;
 }
 
+void EventWatchSysteminfo::setId(int id)
+{
+    m_id = id;
+}
+
 JSValueRef EventWatchSysteminfo::getPropertyValue(JSContextRef context, JSValueRef value, std::string key)
 {
     JSObjectRef object = NULL;
@@ -227,11 +232,11 @@ void EventWatchSysteminfo::processGetValue()
                     propertyLac = getPropertyValue(context, m_lastValue, key);
                     JSStringRef prevLac = JSValueToStringCopy(context, propertyLac, exception);
 
-                    key = "cellid";
-                    JSValueRef propertyCellid = getPropertyValue(context, tmpValue, key);
-                    JSStringRef cellid = JSValueToStringCopy(context, propertyCellid, exception);
-                    propertyCellid = getPropertyValue(context, m_lastValue, key);
-                    JSStringRef prevCellid = JSValueToStringCopy(context, propertyCellid, exception);
+                    key = "cellId";
+                    JSValueRef propertyCellId = getPropertyValue(context, tmpValue, key);
+                    JSStringRef cellId = JSValueToStringCopy(context, propertyCellId, exception);
+                    propertyCellId = getPropertyValue(context, m_lastValue, key);
+                    JSStringRef prevCellId = JSValueToStringCopy(context, propertyCellId, exception);
 
                     key = "isRoaming";
                     JSValueRef propertyRoam = getPropertyValue(context, tmpValue, key);
@@ -240,7 +245,7 @@ void EventWatchSysteminfo::processGetValue()
                     bool prevRoam = JSValueToBoolean(context, propertyRoam);
 
                     if ( !JSStringIsEqual(status, prevStatus) || !JSStringIsEqual(apn, prevApn) || mcc != prevMcc || mnc != prevMnc
-                         || roam != prevRoam || !JSStringIsEqual(lac, prevLac) || !JSStringIsEqual(cellid, prevCellid) ||
+                         || roam != prevRoam || !JSStringIsEqual(lac, prevLac) || !JSStringIsEqual(cellId, prevCellId) ||
                          !JSStringIsEqual(serviceType, prevServiceType)) {
                         m_cbm->callOnSuccess(tmpValue);
                         m_lastValue = tmpValue;
index ebebb69..5e7c1dd 100644 (file)
@@ -43,7 +43,7 @@ class EventWatchSysteminfo : public WrtDeviceApis::Commons::IEvent<EventWatchSys
     void*               m_Systeminfo;
 
        Ecore_Timer *m_initTimer;
-    int m_id;
+    long m_id;
     int m_watchType;
     bool m_canceled;
     JSValueRef m_lastValue;
@@ -63,6 +63,7 @@ class EventWatchSysteminfo : public WrtDeviceApis::Commons::IEvent<EventWatchSys
        const int getWatchType() const;
        void getWatchValue();
        int getId() const;
+       void setId(int id);
        JSValueRef getPropertyValue(JSContextRef context, JSValueRef value, std::string key);
        void processGetValue();
        void setTimer();
index 91f6fe9..bfad0c4 100644 (file)
@@ -46,7 +46,7 @@ class ISysteminfo :
     virtual void get(const EventGetSysteminfoPtr& event) = 0;
     virtual void watch(const EventWatchSysteminfoPtr& event) = 0;    
        virtual BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property) = 0;
-       virtual void clearWatch(const int id) = 0;
+       virtual void clearWatch(const long id) = 0;
 
   protected:
     ISysteminfo();
old mode 100755 (executable)
new mode 100644 (file)
index 758e944..ebdc594
@@ -129,7 +129,7 @@ struct CellularNetworkProperties
        std::string             ipAddress;
        unsigned short  mcc;
        unsigned short  mnc;
-       unsigned short  cellid;
+       unsigned short  cellId;
        unsigned short  lac;
        std::string             serviceType;
        bool                    isRoaming;
@@ -141,7 +141,7 @@ struct CellularNetworkProperties
                ipAddress(""),
                mcc(0),
                mnc(0),
-               cellid(0),
+               cellId(0),
                lac(0),
                serviceType(""),                
                isRoaming(false)
index ce1a8de..6067eca 100755 (executable)
@@ -1,7 +1,6 @@
 include_config_file(Filter)
 include_config_file(Calendar)
 include_config_file(Contact)
-include_config_file(Geocoder)
 include_config_file(Bluetooth)
 include_config_file(Application)
 include_config_file(Messaging)
@@ -10,9 +9,10 @@ include_config_file(TimeUtil)
 include_config_file(Systeminfo)
 include_config_file(NFC)
 include_config_file(Filesystem)
-include_config_file(Account)
 include_config_file(Mediacontent)
 
+#include_config_file(Account)
+#include_config_file(SecureElement)
 #include_config_file(Accelerometer)
 #include_config_file(Orientation)
 #include_config_file(Gyroscope)
diff --git a/src/platform/Tizen/Account/AccountManager.cpp b/src/platform/Tizen/Account/AccountManager.cpp
deleted file mode 100755 (executable)
index 83fd03b..0000000
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        AccountManager.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-#include <algorithm>
-#include <vector>
-
-#include <dpl/log/log.h>
-#include <dpl/scoped_ptr.h>
-
-#include "AccountManager.h"
-#include "AccountWrapper.h"
-
-#include "API/Account/OnAddEventsChanged.h"
-#include "API/Account/OnUpdateEventsChanged.h"
-#include "API/Account/OnDeleteEventsChanged.h"
-#include "account.h"
-
-#include <CommonsJavaScript/Converter.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-int id_list[1024] = {0, };
-int count = 0;
-
-bool GetAccountList(account_h handle, void* user_data)
-{
-       int id = 0;
-       account_get_account_id(handle, &id);
-       id_list[count] = id;
-       count++;
-       return true;
-}
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-int AccountManager::m_instanceCount = 0;
-
-AccountManager::AccountManager()
-{
-    LogDebug("entered");
-
-    DPL::Mutex::ScopedLock mx(&m_constructorMutex);
-    if (m_instanceCount == 0) {
-        LogDebug("opening account DB");
-        if (ACCOUNT_ERROR_NONE != account_connect()) {
-            ThrowMsg(PlatformException, "Account DB initialization failed");
-        }
-    }
-    m_instanceCount++;
-}
-
-AccountManager::~AccountManager()
-{
-    LogDebug("entered");
-    DPL::Mutex::ScopedLock mx(&m_constructorMutex);
-    m_instanceCount--;
-    if (m_instanceCount == 0) {
-        LogDebug("closing account DB");
-        if (ACCOUNT_ERROR_NONE != account_disconnect()) {
-            LogError("Account database not clearly closed.");
-        }
-    }
-}
-
-//void AccountManager::OnRequestReceived(const IEventGetAccountServicesPtr &event)
-//{
-//    LogDebug("entered");
-//    static std::vector<IAccountServicePtr> AccountServices;
-//
-//    Try
-//    {
-//             if (AccountServices.empty()) {
-//                     IAccountServicePtr newAccountService(new AccountService());
-//                     newAccountService->setName("default internet account");
-//                     newAccountService->setId(0);
-//                     newAccountService->setType(AccountService::TYPE_INTERNET);
-//                     AccountServices.push_back(newAccountService);
-//             }
-//             if (!event->checkCancelled()) {
-//                     std::vector<IAccountServicePtr>::const_iterator it = AccountServices.begin();
-//                     for (; it != AccountServices.end(); ++it) {
-//                             event->addAccountService(*it);
-//                     }
-//                     event->setResult(true);
-//             }
-//     }
-//    Catch(Exception)
-//    {
-//        LogError("error occuered during obtaining data");
-//        event->setResult(false);
-//    }
-//    event->setCancelAllowed(true);
-//
-//}
-
-
-void AccountManager::OnRequestReceived(const IEventDeleteAccountPtr &account)
-{
-    LogDebug("entered");
-
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-
-        //TODO: check if ID is valid
-        /*
-        if (!account->getEvent()->getIdIsSet()) {
-            ThrowMsg(Commons::InvalidArgumentException,
-                     "Cannot delete non-existing event.");
-        }
-        */
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-        accountWrapper->deleteAccount();
-        account->setResult(true);
-    }
-    catch (const NotFoundException &ex)
-    {
-        LogError("event doesn't exist");
-        account->setResult(false);
-        account->setExceptionCode(ExceptionCodes::NotFoundException);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during deleting event " << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-}
-
-
-void AccountManager::OnRequestReceived(const IEventAddAccountPtr &account)
-{
-    LogDebug("entered");
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-       /* if (account->getEvent()->getIdIsSet()) {
-            LogWarning("adding event that is already added");
-            account->getEvent()->resetId();
-        }*/
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-
-        accountWrapper->setDummyServices();
-
-        accountWrapper->saveAccount();
-        account->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during adding event" << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-}
-
-void AccountManager::OnRequestReceived(const IEventFindAccountsPtr &event)
-{
-       LogDebug("<<<");
-       Try{
-               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-               if (event->checkCancelled()) {
-                       event->setCancelAllowed(true);
-                       event->setResult(true);
-                       return;
-               }
-
-               EventAccountListPtr accountListPtr = accountWrapper->findAccountsByFilter(event->getFilterProperty());
-               event->setAccountLists(accountListPtr);
-               event->setResult(true);
-       } catch (const Exception &ex) {
-               LogError("Error during adding event" << ex.DumpToString());
-        event->setResult(false);
-       }
-       event->setCancelAllowed(false);
-}
-
-void AccountManager::OnRequestReceived(const IEventFindServicesPtr &event){
-       LogDebug("<<<");
-       Try{
-               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-               if (event->checkCancelled()) {
-                       event->setCancelAllowed(true);
-                       event->setResult(true);
-                       return;
-       }
-
-               AccountServicesArrayPtr serviceListPtr = accountWrapper->findServiceByFilter(event->getFilterProperty());
-               event->setAccountServiceList(serviceListPtr);
-               event->setResult(true);
-       } catch (const Exception &ex) {
-               LogError("Error during adding event" << ex.DumpToString());
-        event->setResult(false);
-    }
-       event->setCancelAllowed(false);
-       LogDebug(">>>");
-}
-
-
-void AccountManager::OnRequestReceived(const IEventUpdateAccountPtr &account)
-{
-    LogDebug("entered");
-
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-  /*      if (!account->getEvent()->getIdIsSet()) {
-            ThrowMsg(
-                Commons::InvalidArgumentException,
-                "Cannot update non-existing event. Event needs adding or ID is wrong");
-        }*/
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-        accountWrapper->saveAccount();
-        account->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during updating event " << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-}
-
-void AccountManager:: OnRequestReceived(const IEventGetAccountByIdPtr &account)
-{
-    LogDebug("entered");
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
-        accountWrapper->getAccountbyId();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-               account->setEvent(accountWrapper->getAbstractAccount());
-        account->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during updating event " << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-}
-
-void AccountManager:: OnRequestReceived(const IEventGetServiceTypeByIdPtr &eventGetServicetypeById)
-{
-       LogDebug("<<<");
-
-       Try{
-               if (!eventGetServicetypeById->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-
-               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(eventGetServicetypeById->getEvent()));
-               if (eventGetServicetypeById->checkCancelled()) {
-                       eventGetServicetypeById->setCancelAllowed(true);
-                       eventGetServicetypeById->setResult(true);
-            return;
-        }
-               eventGetServicetypeById->setEvent(accountWrapper->getAbstractAccount());
-               eventGetServicetypeById->setAccountServiceTypeProperty(accountWrapper->getAccountServiceTypebyId());
-
-               eventGetServicetypeById->setResult(true);
-       } catch (const Exception &ex) {
-        LogError("Error during updating event " << ex.DumpToString());
-               eventGetServicetypeById->setResult(false);
-    }
-       eventGetServicetypeById->setCancelAllowed(false);
-}
-
-void AccountManager:: OnRequestReceived(const IEventGetProviderByIdPtr &event)
-{
-       LogDebug("<<<");
-       Try{
-               if (!event->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(event->getEvent()));
-               if (event->checkCancelled()) {
-                       event->setCancelAllowed(true);
-                       event->setResult(true);
-            return;
-        }
-
-               event->setAccountServiceProviderProperty(accountWrapper->getAccountServiceProviderProperty());
-               event->setResult(true);
-       }catch (const Exception &ex)    {
-        LogError("Error during updating event " << ex.DumpToString());
-               event->setResult(false);
-    }
-       event->setCancelAllowed(false);
-       LogDebug(">>>");
-}
-
-void AccountManager:: OnRequestReceived(const IEventFindProvidersPtr &eventFindProvidersPtr)
-{
-       LogDebug("<<<");
-       Try{
-               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-               AccountServiceProviderPropertyArrayPtr serviceProviderPropertiesPtr = accountWrapper->findProviders(eventFindProvidersPtr->getServiceTypeId());
-
-               if (eventFindProvidersPtr->checkCancelled()) {
-                       eventFindProvidersPtr->setCancelAllowed(true);
-                       LogDebug(">>>");
-                       return;
-               }
-
-               eventFindProvidersPtr->setServiceProviderProperties(serviceProviderPropertiesPtr);
-       }catch (const Exception &ex){
-               LogError("Error during updating event " << ex.DumpToString());
-               eventFindProvidersPtr->setResult(false);
-       }
-       eventFindProvidersPtr->setResult(true);
-       eventFindProvidersPtr->setCancelAllowed(false);
-       LogDebug(">>>");
-}
-
-void AccountManager::OnRequestReceived(const IEventFindServiceTypesPtr &event)
-{
-       LogDebug("<<<");
-    EventAccountPtr m_event;
-
-       AccountWrapperPtr accountWrapper(new AccountWrapper());
-
-       event->setServiceTypeProperties(accountWrapper->findServiceTypes());
-       event->setResult(true);
-       LogDebug(">>>");
-}
-
-void AccountManager::OnRequestReceived(const IEventGetServiceByNamePtr &event){
-       LogDebug("<<< DUMMY IMPLEMENTATION");
-
-       std::string serviceName = event->getServiceName();
-       LogDebug("serviceName:[" << serviceName << "]");
-
-       //dummy implementation
-       AccountServicesPtr dummyServices1(new AccountServices());
-       dummyServices1->setProviderId("dummyProviderId");
-       dummyServices1->setServiceTypeId("dummyServiceTypeId");
-       dummyServices1->setDisplayName("dummyDisplayName");
-       dummyServices1->setName("dummyName");
-       dummyServices1->setId("dummyServiceId");
-
-       event->setAccountService(dummyServices1);
-
-       event->setResult(true);
-
-       LogDebug(">>>");
-}
-
-void AccountManager::OnRequestReceived(const IEventGetServiceByIdPtr &event){
-       LogDebug("<<< DUMMY IMPLEMENTATION");
-
-       std::string serviceId = event->getServiceId();
-       LogDebug("serviceId:[" << serviceId << "]");
-
-       //dummy implementation
-       AccountServicesPtr dummyServices1(new AccountServices());
-       dummyServices1->setProviderId("dummyProviderId");
-       dummyServices1->setServiceTypeId("dummyServiceTypeId");
-       dummyServices1->setDisplayName("dummyDisplayName");
-       dummyServices1->setName("dummyName");
-       dummyServices1->setId("dummyServiceId");
-
-       event->setAccountService(dummyServices1);
-
-       event->setResult(true);
-
-       LogDebug(">>>");
-}
-
-}
-}
-}
diff --git a/src/platform/Tizen/Account/AccountManager.h b/src/platform/Tizen/Account/AccountManager.h
deleted file mode 100755 (executable)
index 00928a2..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        AccountManager.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _TIZEN__ACCOUNTMANAGER_H_
-#define _TIZEN__ACCOUNTMANAGER_H_
-
-#include <vector>
-#include <list>
-#include <dpl/mutex.h>
-//#include "AccountService.h"
-#include "API/Account/IAccountManager.h"
-
-using namespace TizenApis::Api::Account;
-//using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-class AccountManager : public IAccountManager
-{
-       public:
-               AccountManager();
-               virtual ~AccountManager();
-
-       protected:
-//             virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event);
-               virtual void OnRequestReceived(const IEventAddAccountPtr &event);
-               virtual void OnRequestReceived(const IEventDeleteAccountPtr &event);
-               virtual void OnRequestReceived(const IEventFindAccountsPtr &account);
-               virtual void OnRequestReceived(const IEventUpdateAccountPtr &account);
-               virtual void OnRequestReceived(const IEventGetAccountByIdPtr &account);
-               virtual void OnRequestReceived(const IEventGetServiceTypeByIdPtr &account);
-               virtual void OnRequestReceived(const IEventGetProviderByIdPtr &account);
-               virtual void OnRequestReceived(const IEventFindProvidersPtr &account);
-               virtual void OnRequestReceived(const IEventFindServiceTypesPtr &event);
-               virtual void OnRequestReceived(const IEventFindServicesPtr &event);
-               virtual void OnRequestReceived(const IEventGetServiceByNamePtr &event);
-               virtual void OnRequestReceived(const IEventGetServiceByIdPtr &event);
-
-
-       private:
-               static int m_instanceCount;
-               DPL::Mutex m_constructorMutex;
-};
-
-}
-}
-}
-#endif
diff --git a/src/platform/Tizen/Account/AccountWrapper.cpp b/src/platform/Tizen/Account/AccountWrapper.cpp
deleted file mode 100755 (executable)
index e61a29f..0000000
+++ /dev/null
@@ -1,2586 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        AccountWrapper.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include <string.h>
-#include <algorithm>
-#include <pcrecpp.h>
-#include <dpl/log/log.h>
-#include <Commons/Exception.h>
-#include "AccountWrapper.h"
-//#include "AccountService.h"
-#include "account.h"
-
-#include "db-util.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-// For Test
-
-#define _QUERY_DB_NAME "/opt/dbspace/.test-accounts.db"
-#define _QUERY_SQL_STRING_LEN          4096    //short sql string length
-#define _USER_ACCOUNT_TABLE_NAME "user_account"
-#define _SERVICES_TABLE_NAME "service"
-#define _SERVICETYPE_TABLE_NAME "service_type"
-#define _PROVIDER_LIST_TABLE_NAME "provider_list"
-#define _TAGS_MIME_TABLE_NAME "tags_mime"
-#define _RELATION_TABLE_NAME "relation"
-#define _REL_PROVIDER_TABLE_NAME "provider_to_svctype"
-
-#define QUERY_MAX_LEN 4096
-#define SUB_QUERY_LEN 2048
-#define TABLE_LEN 512
-
-static sqlite3 *test_hDBCt;
-typedef sqlite3_stmt* stmt;
-
-#define __USER_ACCOUNT_SCHEMA  "create table %s \n"\
-"(\n"\
-       "user_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "displayname TEXT, "\
-       "icon TEXT, "\
-       "account_id TEXT, "\
-       "enable INTEGER DEFAULT 0, "\
-       "credential_id REAL, "\
-       "settings TEXT, "\
-       "provider_id TEXT, "\
-       "login_id TEXT, "\
-       "_list_id INTEGER "\
-");"
-
-#define __SERVICE_SCHEMA  "create table %s \n"\
-"(\n"\
-       "_svc_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "service_id TEXT, "\
-       "service_name TEXT, "\
-       "application_id TEXT, "\
-       "display_name TEXT, "\
-       "icon TEXT, "\
-       "serviceType_id TEXT,  "\
-       "provider_id TEXT,  "\
-       "setting TEXT, "\
-       "enable INTEGER DEFAULT 0"\
-");"
-
-#define __SERVICETYPE_SCHEMA  "create table %s \n"\
-"(\n"\
-       "type_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "serviceType_id TEXT, "\
-       "display_name TEXT, "\
-       "icon TEXT "\
-");"
-
-#define __TAGS_MIMETYPE_SCHEMA  "create table %s \n"\
-"(\n"\
-       "tags_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "tag_name TEXT "\
-");"
-
-#define __RELATION_SCHEMA  "create table %s \n"\
-"(\n"\
-       "relation_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "tags_id INTEGER, "\
-       "_svc_id INTEGER, "\
-       "type_id INTEGER, "\
-       "tag_name TEXT "\
-");"
-
-#define __REL_PROVIDER_SCHEMA  "create table %s \n"\
-"(\n"\
-       "_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "_list_id INTEGER, "\
-       "type_id INTEGER "\
-");"
-
-#define __PROVIDER_LIST_SCHEMA  "create table %s \n"\
-"(\n"\
-       "_list_id INTEGER PRIMARY KEY AUTOINCREMENT, "\
-       "provider_id TEXT, "\
-       "display_name TEXT, "\
-       "icon TEXT "\
-");"
-
-stmt __query_prepare(char *query) {
-       int rc = -1;
-       stmt pStmt = NULL;
-
-       printf("!! query : %s \n", query);
-
-       rc = sqlite3_prepare_v2(test_hDBCt, query, strlen(query), &pStmt, NULL);
-
-       if (SQLITE_OK != rc) {
-               return NULL;
-       }
-
-       return pStmt;
-}
-
-int _query_exec(char *query) {
-       int rc = -1;
-       char* pszErrorMsg = NULL;
-
-       rc = sqlite3_exec(test_hDBCt, query, NULL, NULL, &pszErrorMsg);
-       if (SQLITE_OK != rc) {
-               sqlite3_free(pszErrorMsg);
-       }
-
-       return rc;
-}
-
-int _query_column_int(stmt pStmt, int pos)
-{
-   return sqlite3_column_int(pStmt, pos);
-}
-
-char* _query_column_text(stmt pStmt, int pos)
-{
-   return (char *)sqlite3_column_text(pStmt, pos);
-}
-
-double _query_column_double(stmt pStmt, int pos)
-{
-   return sqlite3_column_double(pStmt, pos);
-}
-
-int
-_create_all_tables(void)
-{
-       int rc = -1;
-       int error_code = 0;
-       char query[_QUERY_SQL_STRING_LEN + 1] = { 0, };
-
-       //Create test table
-       {
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __USER_ACCOUNT_SCHEMA, _USER_ACCOUNT_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __SERVICE_SCHEMA, _SERVICES_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __SERVICETYPE_SCHEMA, _SERVICETYPE_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __TAGS_MIMETYPE_SCHEMA, _TAGS_MIME_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __RELATION_SCHEMA, _RELATION_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __REL_PROVIDER_SCHEMA, _REL_PROVIDER_TABLE_NAME);
-               rc = _query_exec(query);
-
-               memset(query, 0, sizeof(query));
-               snprintf(query, sizeof(query) - 1, __PROVIDER_LIST_SCHEMA, _PROVIDER_LIST_TABLE_NAME);
-               rc = _query_exec(query);
-
-       }
-
-       return error_code;
-}
-
-int _query_bind_text(stmt pStmt, int pos, char* str)
-{
-       int len = 0;
-       if (str != NULL) {
-               len = strlen(str);
-               return sqlite3_bind_text(pStmt, pos, (const char*) str, len, SQLITE_STATIC);
-       }
-       return -1;
-}
-
-int _query_step(stmt pStmt) {
-       return sqlite3_step(pStmt);
-}
-
-void _query_finalize(stmt pStmt) {
-       int rc = -1;
-
-       if (!pStmt)
-               return;
-
-       rc = sqlite3_finalize(pStmt);
-       if (rc != SQLITE_OK) {
-
-       }
-}
-
-int _query_bind_int(stmt pStmt, int pos, int num) {
-       return sqlite3_bind_int(pStmt, pos, num);
-}
-#if 1
-void insert_dummy_data()
-{
-       int rc = 0;
-       char query[_QUERY_SQL_STRING_LEN + 1] = {0,};
-       stmt hstmt = NULL;
-       int i = 0;
-
-       _create_all_tables();
-
-// insert to tag_name to tag_mime table
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(tag_name) values (?) ", _TAGS_MIME_TABLE_NAME);
-
-       const char* tag_name[] =
-       {
-               "call.voice",
-               "call.video",
-               "call.emergency",
-               "call",
-               "sync.contact",
-               "sync.calendar",
-               "messaging.email"
-       };
-
-       for(i = 0; i < 7; i++)
-       {
-               hstmt = __query_prepare(query);
-
-               _query_bind_text(hstmt, 1, (char*)tag_name[i]);
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-
-//    rc = sqlite3_exec(test_hDBCt, "BEGIN IMMEDIATE TRANSACTION", NULL, NULL, &pszErrorMsg);
-
-// insert to _USER_ACCOUNT_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(displayname, icon, account_id, provider_id, login_id) values "
-                       "(?, ?, ?, ?, ?) ", _USER_ACCOUNT_TABLE_NAME);
-
-       const char* displayname[] =
-       {
-               "Jamie's google account",
-               "William's facebook account",
-               "Craig's twitter account",
-               "Lucille's account"
-       };
-
-       const char* icon[] =
-       {
-               "/opt/icon/image1.jpg",
-               "",
-               "/opt/icon/image1.jpg",
-               "/opt/icon/image2.jpg"
-       };
-
-       const char* account_id[] =
-       {
-               "com.google:Jamie@gmail.com",
-               "com.facebook:William@facebook.com",
-               "com.twitter:Craig@twitter.com",
-               "com.custom:Lucille@gmail.com"
-       };
-
-       const char* provider_id[] =
-       {
-               "com.google",
-               "com.facebook",
-               "com.twitter",
-               "com.custom"
-       };
-
-       const char* login_id[] =
-       {
-               "Jamie@gmail.com",
-               "William@facebook.com",
-               "Craig@twitter.com",
-               "Lucille@gmail.com"
-       };
-
-       for(i = 0; i < 4; i++)
-       {
-               hstmt = __query_prepare(query);
-
-               _query_bind_text(hstmt, 1, (char*)displayname[i]);
-               _query_bind_text(hstmt, 2, (char*)icon[i]);
-               _query_bind_text(hstmt, 3, (char*)account_id[i]);
-               _query_bind_text(hstmt, 4, (char*)provider_id[i]);
-               _query_bind_text(hstmt, 5, (char*)login_id[i]);
-
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-
-// insert to _SERVICETYPE_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(serviceType_id, display_name) values (?, ?) ", _SERVICETYPE_TABLE_NAME);
-
-       const char* service_type_id[] =
-       {
-               "tizen.tel",
-               "tizen.xmpp",
-               "tizen.sip"
-       };
-
-       const char* service_type_display_name[] =
-       {
-               "service_type.tel",
-               "service_type.xmpp",
-               "service_type.sip"
-       };
-
-       for(i = 0; i < 3; i++)
-       {
-               hstmt = __query_prepare(query);
-               _query_bind_text(hstmt, 1, (char*)service_type_id[i]);
-               _query_bind_text(hstmt, 2, (char*)service_type_display_name[i]);
-
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-
-// insert to _SERVICE_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(service_id, provider_id, serviceType_id, service_name, display_name) values "
-               "(?, ?, ?, ?, ?) ", _SERVICES_TABLE_NAME);
-
-       const char* service_id[] =
-       {
-               "com.google.gmail:Jamie@gmail.com",
-               "com.google.gtalk:Jamie@gmail.com",
-               "com.google.picasa:Jamie@gmail.com",
-               "com.facebook.facebook:William@facebook.com",
-               "com.twitter.twitter:Craig@twitter.com",
-               "com.custom.custom:Lucille@gmail.com",
-       };
-
-       const char* service_name[] =
-       {
-               "com.google.gmail",
-               "com.google.gtalk",
-               "com.google.picasa",
-               "com.facebook.facebook",
-               "com.twitter.twitter",
-               "com.custom.custom",
-       };
-
-       const char* service_display_name[] =
-       {
-               "google's gmail",
-               "google's gtalk",
-               "google's picasa",
-               "facebook's service",
-               "twitter's service",
-               "custom's new service",
-       };
-
-       for(i = 0; i < 6; i++)
-       {
-               hstmt = __query_prepare(query);
-
-               _query_bind_text(hstmt, 1, (char*)service_id[i]);
-
-               if(i < 3)
-               {
-                       _query_bind_text(hstmt, 2, (char*)provider_id[0]);
-                       _query_bind_text(hstmt, 3, (char*)service_type_id[i]);
-               } else
-               {
-                       _query_bind_text(hstmt, 2, (char*)provider_id[i-2]);
-                       _query_bind_text(hstmt, 3, (char*)service_type_id[2]);
-               }
-
-               _query_bind_text(hstmt, 4, (char*)service_name[i]);
-               _query_bind_text(hstmt, 5, (char*)service_display_name[i]);
-
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-
-// insert to _PROVIDER_LIST_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(provider_id, display_name) values (?, ?) ", _PROVIDER_LIST_TABLE_NAME);
-
-       const char* provider_display_name[] =
-       {
-               "provider:com.google",
-               "provider:com.facebook",
-               "provider:com.twitter",
-               "provider:com.custom",
-       };
-
-       for(i = 0; i < 4; i++)
-       {
-               hstmt = __query_prepare(query);
-
-               _query_bind_text(hstmt, 1, (char*)provider_id[i]);
-               _query_bind_text(hstmt, 2, (char*)provider_display_name[i]);
-
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-
-// insert to _RELATION_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(tags_id, _svc_id, type_id, tag_name) values (?, ?, ?, ?) ", _RELATION_TABLE_NAME);
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 2);
-       _query_bind_int(hstmt, 2, 1);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[1]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-       _query_bind_int(hstmt, 1, 5);
-       _query_bind_int(hstmt, 2, 2);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[4]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-       _query_bind_int(hstmt, 1, 7);
-       _query_bind_int(hstmt, 2, 3);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 7);
-       _query_bind_int(hstmt, 2, 4);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 7);
-       _query_bind_int(hstmt, 2, 5);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 7);
-       _query_bind_int(hstmt, 2, 6);
-       _query_bind_int(hstmt, 3, 0);
-       _query_bind_text(hstmt, 4, (char*)tag_name[6]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 1);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 1);
-       _query_bind_text(hstmt, 4, (char*)tag_name[0]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 3);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 1);
-       _query_bind_text(hstmt, 4, (char*)tag_name[2]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 4);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 1);
-       _query_bind_text(hstmt, 4, (char*)tag_name[3]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 1);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 2);
-       _query_bind_text(hstmt, 4, (char*)tag_name[0]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 4);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 2);
-       _query_bind_text(hstmt, 4, (char*)tag_name[3]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 5);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 3);
-       _query_bind_text(hstmt, 4, (char*)tag_name[4]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-       hstmt = __query_prepare(query);
-
-       _query_bind_int(hstmt, 1, 6);
-       _query_bind_int(hstmt, 2, 0);
-       _query_bind_int(hstmt, 3, 3);
-       _query_bind_text(hstmt, 4, (char*)tag_name[5]);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       printf("\n !! rc : %d \n", rc);
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-// insert to _REL_PROVIDER_TABLE_NAME
-       memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(_list_id, type_id) values (?, ?) ", _REL_PROVIDER_TABLE_NAME);
-
-       for(i = 0; i < 6; i++)
-       {
-               hstmt = __query_prepare(query);
-
-               if(i<3)
-               {
-                       _query_bind_int(hstmt, 1, 1);
-                       _query_bind_int(hstmt, 2, i+1);
-               } else
-               {
-                       _query_bind_int(hstmt, 1, i-1);
-                       _query_bind_int(hstmt, 2, 3);
-               }
-
-               rc = _query_step(hstmt);
-               if(rc != SQLITE_DONE)
-               {
-                       printf("\n !! rc : %d \n", rc);
-               }
-
-               _query_finalize(hstmt);
-               hstmt = NULL;
-       }
-//    rc = sqlite3_exec(test_hDBCt, "COMMIT TRANSACTION", NULL, NULL, &pszErrorMsg);
-
-}
-#endif
-typedef enum
-{
-       SERVICE_TYPE_ID,
-       TAGS,
-       PROVIDER_ID,
-       FILTER_ATTRIBUTE_MAX
-}filter_e;
-
-typedef enum
-{
-       ENABLE,
-       DISABLE,
-       ALL
-}status_e;
-
-typedef struct
-{
-       char* tag_info;
-       bool enabled;
-}tags_info_t;
-
-typedef struct
-{
-       char* AccountServiceTypeId;
-       char* displayName;
-       char* icon;
-       GList* tags_info; // tags_info_t
-}AccountServiceType_t;
-
-typedef struct
-{
-       char* AccountServiceId;
-       char* serviceName;
-       char* applicationId;
-       char* displayName;
-       char* icon;
-       char* AccountId;
-       char* AccountServiceTypeId;
-       char* AccountServiceProviderId;
-       char* setting;
-       GList* tags_info; // tags_info_t
-       bool enabled;
-}AccountService_t;
-
-typedef struct
-{
-       char* AccountServiceProviderId;
-       char* displayName;
-       char* icon;
-}provider_t;
-
-typedef struct
-{
-       char* displayName;
-       char* icon;
-}UserProperties_t;
-
-UserAccount_t user_account = {0, };
-UserProperties_t property = {0, };
-AccountServiceType_t serviceType = {0, };
-provider_t provider = {0, };
-
-int check_provider_activate(char* providerId, int* activate, char** package_name)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-
-       snprintf(query, sizeof(query) - 1, "select package_name, activate from provider_list where provider_id = ? ");
-
-       stmt hstmt = __query_prepare(query);
-
-       _query_bind_text(hstmt, 1, providerId);
-
-       rc = _query_step(hstmt);
-       if(rc == SQLITE_ROW)
-       {
-               *package_name = g_strdup(_query_column_text(hstmt, 0));
-               *activate = _query_column_int(hstmt, 1);
-               rc = _query_step(hstmt);
-       }
-
-       _query_finalize(hstmt);
-       return error_code;
-}
-
-int _add_platform_to_web()
-{
-
-// update provider_list table
-
-// update user_account table
-       return 0;
-}
-
-int addAccount(char* providerId, UserProperties_t* properties, UserAccount_t* account)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-
-       snprintf(query, sizeof(query) - 1, "insert into user_account(display_name, icon, provider_id) value (?, ?, ?)");
-
-       stmt hstmt = __query_prepare(query);
-
-       _query_bind_text(hstmt, 1, properties->displayName);
-       _query_bind_text(hstmt, 2, properties->icon);
-       _query_bind_text(hstmt, 3, providerId);
-
-       rc = _query_step(hstmt);
-       if(rc != SQLITE_DONE)
-       {
-
-       }
-
-       _query_finalize(hstmt);
-
-       return error_code;
-}
-
-typedef struct {
-               GList* filter_list;
-               status_e status;
-               int tags_count;
-} search_list_t;
-
-typedef struct {
-               filter_e filter_type;
-               char* value;
-} filter_value_t;
-
-int set_account_filter(search_list_t* search_list, filter_e filter_type, const char* value)
-{
-       if(value == NULL || value[0] == '\0')
-       {
-               printf("value is null \n");
-               return 0;
-       }
-       printf("value : %s \n", value);
-
-       filter_value_t* object = NULL;
-       object = g_new0(filter_value_t, 1);
-
-       object->filter_type = filter_type;
-       object->value = g_strdup(value);
-       if (filter_type == TAGS)
-               search_list->tags_count++;
-       search_list->filter_list = g_list_append(search_list->filter_list, object);
-
-       return 0;
-}
-
-const static char* filter_attribute[FILTER_ATTRIBUTE_MAX] =
-{
-       "serviceType_id",
-       "tag_name",
-       "provider_id"
-};
-
-typedef enum {
-       USE_FILTER_NONE = 0x00000000, USE_SERVICE_TYPE_ID = 0x00000001, USE_TAGS = 0x00000002, USE_PROVIDER_ID = 0x00000004
-} used_filter_attr;
-
-typedef enum {
-       TAG_SERVICE, TAG_SERVICE_TYPE
-} tags_owner;
-
-typedef enum {
-       FIND_ACCOUNT, FIND_SERVICE
-} query_type_e;
-
-void _get_tags(tags_owner owner, int id, GList** tags_list)
-{
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-
-       switch (owner) {
-               case TAG_SERVICE:
-                       snprintf(query, sizeof(query) - 1, "select tag_name from relation where _svc_id = %d", id);
-                       break;
-               case TAG_SERVICE_TYPE:
-                       snprintf(query, sizeof(query) - 1, "select tag_name from relation where type_id = %d", id);
-               default:
-                       break;
-       }
-
-       stmt hstmt = __query_prepare(query);
-
-       rc = _query_step(hstmt);
-       while (rc == SQLITE_ROW) {
-               tags_info_t* tag_info = NULL;
-               tag_info = g_new0(tags_info_t, 1);
-               tag_info->tag_info = g_strdup(_query_column_text(hstmt, 0));
-
-               *tags_list = g_list_append(*tags_list, tag_info);
-               rc = _query_step(hstmt);
-       }
-       _query_finalize(hstmt);
-}
-
-char* _make_condition_part(search_list_t* search_list, query_type_e type) {
-       char* query = NULL;
-       char tmp_query[SUB_QUERY_LEN + 1] = { 0, };
-       char pre_query[TABLE_LEN + 1] = { 0, };
-       char table[TABLE_LEN + 1] = { 0, };
-       used_filter_attr use_filter = USE_FILTER_NONE;
-       int filter_count = 0;
-       int tags_count = 0;
-
-       query = g_new0(char, QUERY_MAX_LEN);
-
-       if (type == FIND_ACCOUNT)
-               snprintf(pre_query, sizeof(pre_query) - 1, "where user_account.provider_id in (select a.provider_id from service a ");
-       else
-               snprintf(pre_query, sizeof(pre_query) - 1, "where service._svc_id in (select a._svc_id from service a ");
-
-       GList* tmp_filter_list = search_list->filter_list;
-       while (tmp_filter_list) {
-               filter_value_t* object = (filter_value_t*) tmp_filter_list->data;
-
-               if (object->value != NULL) {
-                       if (object->filter_type == SERVICE_TYPE_ID) {
-                               use_filter = (used_filter_attr) (use_filter | USE_SERVICE_TYPE_ID);
-
-                               if (tmp_query[0] == '\0')
-                                       sprintf(tmp_query, "a.%s = ? ", filter_attribute[object->filter_type]);
-                               else
-                                       sprintf(tmp_query, "and %s a.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
-
-                       } else if (object->filter_type == TAGS) {
-                               use_filter = (used_filter_attr) (use_filter | USE_TAGS);
-                               tags_count++;
-
-                               if (tags_count == 1) {
-                                       if (table[0] == '\0')
-                                               sprintf(table, ", relation b ");
-                                       else
-                                               sprintf(table, "%s, relation b ", table);
-
-                                       if (tmp_query[0] == '\0') {
-                                               if (search_list->tags_count > 1)
-                                                       sprintf(tmp_query, "(a._svc_id = b._svc_id) and (b.%s = ? ", filter_attribute[object->filter_type]);
-                                               else
-                                                       sprintf(tmp_query, "(a._svc_id = b._svc_id) and b.%s = ? ", filter_attribute[object->filter_type]);
-                                       } else {
-                                               if (search_list->tags_count > 1)
-                                                       sprintf(tmp_query, "%s and (a._svc_id = b._svc_id) and (b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
-                                               else
-                                                       sprintf(tmp_query, "%s and (a._svc_id = b._svc_id) and b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
-                                       }
-                               } else {
-                                       sprintf(tmp_query, "%s or b.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
-                                       if (search_list->tags_count > 1 && search_list->tags_count == tags_count)
-                                               sprintf(tmp_query, "%s) ", tmp_query);
-                               }
-                       } else if (object->filter_type == PROVIDER_ID) {
-                               use_filter = (used_filter_attr) (use_filter | USE_PROVIDER_ID);
-
-                               if (tmp_query[0] == '\0')
-                                       sprintf(tmp_query, "a.%s = ? ", filter_attribute[object->filter_type]);
-                               else
-                                       sprintf(tmp_query, "%s and a.%s = ? ", tmp_query, filter_attribute[object->filter_type]);
-                       }
-                       filter_count++;
-               }
-               tmp_filter_list = g_list_next(tmp_filter_list);
-       }
-
-       if (table[0] != '\0')
-               snprintf(query, QUERY_MAX_LEN, "%s %s where %s)", pre_query, table, tmp_query);
-       else
-               snprintf(query, QUERY_MAX_LEN, "%s where %s)", pre_query, tmp_query);
-
-       if (type == FIND_ACCOUNT) {
-               if ((use_filter | USE_PROVIDER_ID) == USE_PROVIDER_ID && filter_count == 1) {
-                       memset(query, 0x00, QUERY_MAX_LEN);
-                       snprintf(query, QUERY_MAX_LEN, "where user_account.provider_id = ? ");
-               } else if ((use_filter | USE_SERVICE_TYPE_ID) == USE_SERVICE_TYPE_ID && filter_count == 1) {
-                       memset(query, 0x00, QUERY_MAX_LEN);
-                       snprintf(query, QUERY_MAX_LEN, ",service where (user_account.provider_id = service.provider_id) and service.serviceType_id = ? ");
-               }
-       } else {
-               if ((use_filter | USE_PROVIDER_ID) == USE_PROVIDER_ID && filter_count == 1) {
-                       memset(query, 0x00, QUERY_MAX_LEN);
-                       snprintf(query, QUERY_MAX_LEN, ",user_account where (user_account.provider_id = service.provider_id) and user_account.provider_id = ? ");
-               }else if((use_filter | USE_SERVICE_TYPE_ID) == USE_SERVICE_TYPE_ID && filter_count == 1)
-               {
-                       memset(query, 0x00, QUERY_MAX_LEN);
-                       snprintf(query, QUERY_MAX_LEN, " where service.serviceType_id = ? ");
-               }
-       }
-
-       if (filter_count == 0)
-               return NULL;
-       else
-               return query;
-}
-
-void _get_service_list_by_account(char* provider_id, GList** service_list) {
-       int rc = 0;
-       int id = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-
-       snprintf(query, sizeof(query) - 1, "select service_id, service_name, application_id, display_name, icon, serviceType_id, provider_id, setting, enable, _svc_id "
-               "from %s where provider_id = ?", _SERVICES_TABLE_NAME);
-
-       stmt hstmt = __query_prepare(query);
-
-       _query_bind_text(hstmt, 1, provider_id);
-
-       rc = _query_step(hstmt);
-       while (rc == SQLITE_ROW) {
-               AccountService_t* service_info = NULL;
-               service_info = g_new0(AccountService_t, 1);
-
-               service_info->AccountServiceId = g_strdup(_query_column_text(hstmt, 0));
-               service_info->serviceName = g_strdup(_query_column_text(hstmt, 1));
-               service_info->applicationId = g_strdup(_query_column_text(hstmt, 2));
-               service_info->displayName = g_strdup(_query_column_text(hstmt, 3));
-               service_info->icon = g_strdup(_query_column_text(hstmt, 4));
-               service_info->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 5));
-               service_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
-               service_info->setting = g_strdup(_query_column_text(hstmt, 7));
-               service_info->enabled = _query_column_int(hstmt, 8);
-               id = _query_column_int(hstmt, 9);
-
-               _get_tags(TAG_SERVICE, id, &(service_info->tags_info));
-
-               *service_list = g_list_append(*service_list, service_info);
-               rc = _query_step(hstmt);
-       }
-       _query_finalize(hstmt);
-}
-
-void _make_account_info(int user_id, UserAccount_t* account_info) {
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-       int rc = 0;
-
-// Get user_account
-       snprintf(query, sizeof(query) - 1, "select displayname, icon, account_id, enable, credential_id, settings, provider_id "
-                       "from %s where user_id = %d", _USER_ACCOUNT_TABLE_NAME, user_id);
-
-       stmt hstmt = __query_prepare(query);
-
-       rc = _query_step(hstmt);
-       account_info->displayName = g_strdup(_query_column_text(hstmt, 0));
-       account_info->icon = g_strdup(_query_column_text(hstmt, 1));
-       account_info->AccountId = g_strdup(_query_column_text(hstmt, 2));
-       account_info->enabled = _query_column_int(hstmt, 3);
-       account_info->credentialId = _query_column_double(hstmt, 4);
-       account_info->settings = g_strdup(_query_column_text(hstmt, 5));
-       account_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
-
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-// Get services
-       _get_service_list_by_account(account_info->AccountServiceProviderId, &(account_info->services));
-}
-
-void _make_service_info(int id, AccountService_t* service_info) {
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-       int rc = 0;
-       stmt hstmt = NULL;
-
-// Get service
-       snprintf(query, sizeof(query) - 1, "select service_id, service_name, application_id, display_name, icon, serviceType_id, provider_id, setting, enable "
-                       "from %s where _svc_id = %d", _SERVICES_TABLE_NAME, id);
-
-       hstmt = __query_prepare(query);
-
-       rc = _query_step(hstmt);
-       service_info->AccountServiceId = g_strdup(_query_column_text(hstmt, 0));
-       service_info->serviceName = g_strdup(_query_column_text(hstmt, 1));
-       service_info->applicationId = g_strdup(_query_column_text(hstmt, 2));
-       service_info->displayName = g_strdup(_query_column_text(hstmt, 3));
-       service_info->icon = g_strdup(_query_column_text(hstmt, 4));
-       service_info->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 5));
-       service_info->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 6));
-       service_info->setting = g_strdup(_query_column_text(hstmt, 7));
-       service_info->enabled = _query_column_int(hstmt, 8);
-
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-// Get account_id
-       snprintf(query, sizeof(query) - 1, "select account_id from %s where provider_id = %s", _USER_ACCOUNT_TABLE_NAME, service_info->AccountServiceProviderId);
-
-       hstmt = __query_prepare(query);
-
-       rc = _query_step(hstmt);
-       service_info->AccountId = g_strdup(_query_column_text(hstmt, 0));
-
-       _query_finalize(hstmt);
-       hstmt = NULL;
-
-// Get tags
-       _get_tags(TAG_SERVICE, id, &(service_info->tags_info));
-
-}
-
-int find_accounts(search_list_t* search_list, status_e status, GList** account_list) {
-       int error_code = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-       int i = 1;
-       int index_list[SUB_QUERY_LEN + 1] = { 0, };
-       int index_count = 0;
-       int rc = 0;
-       stmt hstmt = NULL;
-
-       char* filter = _make_condition_part(search_list, FIND_ACCOUNT);
-
-       switch(status)
-       {
-               case ENABLE :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account %s and user_account.enable = 1", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account where user_account.enable = 1");
-               }
-                       break;
-               case DISABLE :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account %s and user_account.enable = 0", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account where user_account.enable = 0");
-               }
-                       break;
-               case ALL :
-               default :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account %s", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account");
-               }
-                       break;
-       }
-
-       hstmt = __query_prepare(query);
-
-       GList* filter_list_val = search_list->filter_list;
-       while (filter_list_val) {
-               filter_value_t* object = (filter_value_t*) filter_list_val->data;
-
-               if (object->value != NULL)
-                       _query_bind_text(hstmt, i++, object->value);
-               filter_list_val = g_list_next(filter_list_val);
-       }
-
-       rc = _query_step(hstmt);
-       int ret = 0;
-       while (rc == SQLITE_ROW) {
-               ret = _query_column_int(hstmt, 0);
-               index_list[index_count++] = ret;
-               rc = _query_step(hstmt);
-       }
-
-       _query_finalize(hstmt);
-
-// make account object by index_list
-       for (i = 0; i < index_count; i++) {
-// Get account info
-               UserAccount_t* account_info = NULL;
-               account_info = g_new0(UserAccount_t, 1);
-               _make_account_info(index_list[i], account_info);
-
-// Generate account list
-               *account_list = g_list_append(*account_list, account_info);
-       }
-
-       if (filter)
-               free(filter);
-
-       return error_code;
-}
-
-int find_services(search_list_t* search_list, status_e status, GList** service_list) {
-       int error_code = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-       int i = 1;
-       int index_list[SUB_QUERY_LEN + 1] = { 0, };
-       int index_count = 0;
-       int rc = 0;
-
-       char* filter = _make_condition_part(search_list, FIND_SERVICE);
-
-       switch(status)
-       {
-               case ENABLE :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service %s and service.enable = 1", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service where service.enable = 1");
-               }
-                       break;
-               case DISABLE :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service %s and service.enable = 0", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service where service.enable = 0");
-               }
-                       break;
-               case ALL :
-               default :
-               {
-                       if(filter)
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service %s", filter);
-                       else
-                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service");
-               }
-                       break;
-       }
-
-       stmt hstmt = __query_prepare(query);
-
-       GList* filter_list_val = search_list->filter_list;
-       while (filter_list_val) {
-               filter_value_t* object = (filter_value_t*) filter_list_val->data;
-
-               if (object->value != NULL)
-                       _query_bind_text(hstmt, i++, object->value);
-
-               filter_list_val = g_list_next(filter_list_val);
-       }
-
-       rc = _query_step(hstmt);
-       while (rc == SQLITE_ROW) {
-               index_list[index_count++] = _query_column_int(hstmt, 0);
-               rc = _query_step(hstmt);
-       }
-
-       _query_finalize(hstmt);
-
-       for (i = 0; i < index_count; i++) {
-// Get service info
-               AccountService_t* service_info = NULL;
-               service_info = g_new0(AccountService_t, 1);
-               _make_service_info(index_list[i], service_info);
-
-// Generate service list
-               *service_list = g_list_append(*service_list, service_info);
-       }
-
-       if (filter)
-               free(filter);
-
-       return error_code;
-}
-
-int find_providers(char* serviceTypeId, GList** provider_list)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-       char sub_query[SUB_QUERY_LEN + 1] = { 0, };
-
-       if (serviceTypeId == NULL) {
-               snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon from provider_list");
-       } else {
-               snprintf(sub_query, sizeof(sub_query) - 1, "select type_id from service_type where serviceType_id = ?");
-               snprintf(query, sizeof(query) - 1, "select a.provider_id, a.display_name, a.icon from provider_list a, provider_to_svctype b "
-                               "where (a._list_id = b._list_id) and b.type_id in (%s) ", sub_query);
-       }
-
-       stmt hstmt = __query_prepare(query);
-
-       if(serviceTypeId != NULL)
-               _query_bind_text(hstmt, 1, serviceTypeId);
-
-       rc = _query_step(hstmt);
-       while (rc == SQLITE_ROW) {
-               provider_t* provider = NULL;
-               provider = g_new0(provider_t, 1);
-               provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
-               provider->displayName = g_strdup(_query_column_text(hstmt, 1));
-               provider->icon = g_strdup(_query_column_text(hstmt, 2));
-
-               *provider_list = g_list_append(*provider_list, provider);
-               rc = _query_step(hstmt);
-       }
-
-       _query_finalize(hstmt);
-
-       return error_code;
-}
-
-int find_service_types(char* prefix, GList** servicetype_list)
-{
-       int error_code = 0;
-       int rc = 0;
-       int type_id = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-
-       if (prefix == NULL)
-               snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type");
-       else
-               snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type where serviceType_id like (? || '%%')");
-
-       stmt hstmt = __query_prepare(query);
-
-       if (prefix != NULL)
-               _query_bind_text(hstmt, 1, prefix);
-
-       rc = _query_step(hstmt);
-       while (rc == SQLITE_ROW) {
-               type_id = _query_column_int(hstmt, 0);
-
-               AccountServiceType_t* servicetype = NULL;
-               servicetype = g_new0(AccountServiceType_t, 1);
-               servicetype->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 1));
-               servicetype->displayName = g_strdup(_query_column_text(hstmt, 2));
-               servicetype->icon = g_strdup(_query_column_text(hstmt, 3));
-
-               _get_tags(TAG_SERVICE_TYPE, type_id, &(servicetype->tags_info));
-
-               *servicetype_list = g_list_append(*servicetype_list, servicetype);
-               rc = _query_step(hstmt);
-       }
-       _query_finalize(hstmt);
-
-       return error_code;
-}
-
-// use mandatory input parameter
-int getAccountById(char* accountId, UserAccount_t* account) {
-       int error_code = 0;
-       int rc = 0;
-       int user_id = 0;
-       char query[QUERY_MAX_LEN + 1] = { 0, };
-
-       snprintf(query, sizeof(query) - 1, "select user_id from user_account where account_id = ?");
-
-       stmt hstmt = __query_prepare(query);
-       _query_bind_text(hstmt, 1, accountId);
-
-       rc = _query_step(hstmt);
-
-       user_id = _query_column_int(hstmt, 0);
-       _query_finalize(hstmt);
-
-       _make_account_info(user_id, account);
-
-       return error_code;
-}
-
-int getServiceTypeById(char* serviceTypeId, AccountServiceType_t* serviceType) {
-       int error_code = 0;
-       int rc = 0;
-       int type_id = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-       printf("serviceTypeid : %s \n", serviceTypeId);
-
-       snprintf(query, sizeof(query) - 1, "select type_id, serviceType_id, display_name, icon from service_type where serviceType_id = ?");
-
-       stmt hstmt = __query_prepare(query);
-       _query_bind_text(hstmt, 1, serviceTypeId);
-
-       rc = _query_step(hstmt);
-       printf("rc : %d \n", rc);
-
-       type_id = _query_column_int(hstmt, 0);
-
-       serviceType->AccountServiceTypeId = g_strdup(_query_column_text(hstmt, 1));
-       serviceType->displayName = g_strdup(_query_column_text(hstmt, 2));
-       serviceType->icon = g_strdup(_query_column_text(hstmt, 3));
-
-       _get_tags(TAG_SERVICE_TYPE, type_id, &(serviceType->tags_info));
-
-       _query_finalize(hstmt);
-
-       return error_code;
-}
-
-void free_single_value(char* value)
-{
-       if(value)
-       {
-               free(value);
-               value = NULL;
-       }
-}
-
-void _free_tags_list_info(gpointer data, gpointer user_data)
-{
-       free(((tags_info_t*)data)->tag_info);
-       free(data);
-}
-
-void free_tags_list(GList* list)
-{
-       if(list)
-       {
-//             g_list_foreach(list, _free_tags_list_info, NULL);
-//             g_list_free(list);
-       }
-}
-
-void _free_service_list_info(gpointer data, gpointer user_data)
-{
-       free(((AccountService_t*)data)->AccountServiceId);
-       free(((AccountService_t*)data)->serviceName);
-       free(((AccountService_t*)data)->applicationId);
-       free(((AccountService_t*)data)->displayName);
-       free(((AccountService_t*)data)->icon);
-       free(((AccountService_t*)data)->AccountId);
-       free(((AccountService_t*)data)->AccountServiceTypeId);
-       free(((AccountService_t*)data)->AccountServiceProviderId);
-       free(((AccountService_t*)data)->setting);
-       free_tags_list(((AccountService_t*)data)->tags_info);
-
-       free(data);
-}
-
-void free_service_list(GList* list)
-{
-       if(list)
-       {
-//             g_list_foreach(list, _free_service_list_info, NULL);
-//             g_list_free(list);
-       }
-}
-
-void _free_serviceType_list_info(gpointer data, gpointer user_data)
-{
-       free(((AccountServiceType_t*)data)->AccountServiceTypeId);
-       free(((AccountServiceType_t*)data)->displayName);
-       free(((AccountServiceType_t*)data)->icon);
-       free_tags_list(((AccountService_t*)data)->tags_info);
-       free(data);
-}
-
-void free_serviceType_list(GList* list)
-{
-       if(list)
-       {
-//             g_list_foreach(list, _free_serviceType_list_info, NULL);
-//             g_list_free(list);
-       }
-}
-
-void _free_provider_list_info(gpointer data, gpointer user_data)
-{
-       free(((provider_t*)data)->AccountServiceProviderId);
-       free(((provider_t*)data)->displayName);
-       free(((provider_t*)data)->icon);
-       free(data);
-}
-
-void free_provider_list(GList* list)
-{
-       if(list)
-       {
-//             g_list_foreach(list, _free_provider_list_info, NULL);
-//             g_list_free(list);
-       }
-}
-
-int getProviderById(char* serviceProviderId, provider_t* provider)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-
-       snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon from provider_list where provider_id = ?");
-
-       stmt hstmt = __query_prepare(query);
-       _query_bind_text(hstmt, 1, serviceProviderId);
-
-       rc = _query_step(hstmt);
-
-       provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
-       provider->displayName = g_strdup(_query_column_text(hstmt, 1));
-       provider->icon = g_strdup(_query_column_text(hstmt, 2));
-
-       _query_finalize(hstmt);
-
-       return error_code;
-}
-
-int getServiceById(char* serviceId, AccountService_t* service_info)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-
-       snprintf(query, sizeof(query) - 1, "select _svc_id where service_id = ?");
-
-       stmt hstmt = __query_prepare(query);
-       _query_bind_text(hstmt, 1, serviceId);
-       rc = _query_step(hstmt);
-       int index = _query_column_int(hstmt, 0);
-       _query_finalize(hstmt);
-
-       _make_service_info(index, service_info);
-
-       return error_code;
-}
-
-int getServiceByName(char* serviceName, AccountService_t* service_info)
-{
-       int error_code = 0;
-       int rc = 0;
-       char query[QUERY_MAX_LEN + 1] = {0, };
-
-       snprintf(query, sizeof(query) - 1, "select _svc_id where service_name = ?");
-
-       stmt hstmt = __query_prepare(query);
-       _query_bind_text(hstmt, 1, serviceName);
-
-       rc = _query_step(hstmt);
-       int index = _query_column_int(hstmt, 0);
-       _query_finalize(hstmt);
-
-       _make_service_info(index, service_info);
-
-       return error_code;
-}
-
-void test_find_accounts()
-{
-        GList* account_list = NULL;
-
-        search_list_t search_list = {0, };
-        set_account_filter(&search_list, SERVICE_TYPE_ID, "tizen.sms");
-        find_accounts(&search_list, DISABLE, &account_list);
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-        printf("\n");
-
-        search_list_t search_list1 = {0, };
-        set_account_filter(&search_list1, TAGS, "tizen.sharing");
-        find_accounts(&search_list1, DISABLE, &account_list);
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-        printf("\n");
-
-        search_list_t search_list2 = {0, };
-        set_account_filter(&search_list2, PROVIDER_ID, "com.google");
-        find_accounts(&search_list2, DISABLE, &account_list);
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-        printf("\n");
-
-        search_list_t search_list3 = {0, };
-        set_account_filter(&search_list3, SERVICE_TYPE_ID, "tizen.sms");
-        set_account_filter(&search_list3, TAGS, "tizen.sharing");
-        set_account_filter(&search_list3, TAGS, "tizen.email");
-        set_account_filter(&search_list3, PROVIDER_ID, "com.google");
-        find_accounts(&search_list3, DISABLE, &account_list);
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-        printf("\n");
-
-        search_list_t search_list4 = {0, };
-        find_accounts(&search_list4, DISABLE, &account_list);
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n\n\n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-        printf("\n");
-
-        search_list_t search_list5 = {0, };
-        set_account_filter(&search_list5, TAGS, "tizen.sms");
-        set_account_filter(&search_list5, TAGS, "tizen.mms");
-        find_accounts(&search_list5, DISABLE, &account_list);
-
-        while(account_list)
-        {
-                UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-            printf("account_info->AccountId : %s \n", account_info->AccountId);
-            printf("account_info->AccountServiceProviderId : %s \n", account_info->AccountServiceProviderId);
-                account_list = g_list_next(account_list);
-        }
-}
-
-void test_find_service_types()
-{
-       GList* servicetype_list = NULL;
-
-       find_service_types((char*)"tizen", &servicetype_list);
-       while(servicetype_list)
-       {
-               AccountServiceType_t* service_type_info = (AccountServiceType_t*)servicetype_list->data;
-           printf("service_type_info->AccountServiceTypeId : %s \n", service_type_info->AccountServiceTypeId);
-           printf("service_type_info->displayName : %s \n", service_type_info->displayName);
-           printf("service_type_info->icon : %s \n", service_type_info->icon);
-
-               GList* tmp_tag_list = service_type_info->tags_info;
-
-               while(tmp_tag_list)
-               {
-                       tags_info_t* tag = (tags_info_t*)tmp_tag_list->data;
-                   printf("tag->tag_info : %s \n", tag->tag_info);
-
-                       tmp_tag_list = g_list_next(tmp_tag_list);
-               }
-
-               servicetype_list = g_list_next(servicetype_list);
-       }
-}
-
-void test_find_services()
-{
-       GList* service_list = NULL;
-       search_list_t search_list = {0, };
-       set_account_filter(&search_list, SERVICE_TYPE_ID, "tizen.tel");
-       find_services(&search_list, DISABLE, &service_list);
-       while(service_list)
-       {
-               AccountService_t* service_info = (AccountService_t*)service_list->data;
-           printf("service_info->AccountServiceId : %s \n", service_info->AccountServiceId);
-           printf("service_info->AccountServiceProviderId : %s \n", service_info->AccountServiceProviderId);
-               service_list = g_list_next(service_list);
-       }
-       printf("\n");
-       search_list_t search_list1 = {0, };
-       set_account_filter(&search_list1, PROVIDER_ID, "com.google");
-       find_services(&search_list1, DISABLE, &service_list);
-       while(service_list)
-       {
-               AccountService_t* service_info = (AccountService_t*)service_list->data;
-           printf("service_info->AccountServiceId : %s \n", service_info->AccountServiceId);
-           printf("service_info->AccountServiceProviderId : %s \n", service_info->AccountServiceProviderId);
-               service_list = g_list_next(service_list);
-       }
-}
-
-void test_find_providers()
-{
-       GList* provider_list = NULL;
-
-       find_providers(NULL, &provider_list);
-       while(provider_list)
-       {
-               provider_t* provider_info = (provider_t*)provider_list->data;
-           printf("provider_info->AccountId : %s \n", provider_info->AccountServiceProviderId);
-               provider_list = g_list_next(provider_list);
-       }
-       printf("\n");
-
-       find_providers((char*)"tizen.sms", &provider_list);
-       while(provider_list)
-       {
-               provider_t* provider_info = (provider_t*)provider_list->data;
-           printf("provider_info->AccountId : %s \n", provider_info->AccountServiceProviderId);
-               provider_list = g_list_next(provider_list);
-       }
-}
-
-void test_get_account_by_id()
-{
-       UserAccount_t account = {0, };
-       getAccountById((char*)"com.facebook:William@facebook.com", &account);
-
-    printf("account->AccountId : %s \n", account.AccountId);
-}
-
-void test_get_service_type_by_id()
-{
-       AccountServiceType_t serviceType = {0, };
-
-       getServiceTypeById((char*)"tizen.tel", &serviceType);
-    printf("serviceType->AccountServiceTypeId : %s \n", serviceType.AccountServiceTypeId);
-}
-
-void test_get_provider_by_id()
-{
-       provider_t provider = {0, };
-
-       getProviderById((char*)"com.google", &provider);
-    printf("provider->AccountServiceProviderId : %s \n", provider.AccountServiceProviderId);
-}
-
-void test_get_service_by_id()
-{
-       AccountService_t service = {0, };
-
-       getServiceById((char*)"com.google.gtalk", &service);
-    printf("service->AccountServiceProviderId : %s \n", service.AccountServiceId);
-}
-
-void test_get_service_by_name()
-{
-       AccountService_t service = {0, };
-
-       getServiceByName((char*)"com.google.gmail", &service);
-    printf("service->AccountServiceProviderId : %s \n", service.AccountServiceId);
-}
-
-void test_apis()
-{
-       db_util_open(_QUERY_DB_NAME, &test_hDBCt, 0);
-//     insert_dummy_data();
-       printf("\n -------------------------------------------- test_find_accounts --------------------------------------------\n");
-       test_find_accounts();
-
-       printf("\n -------------------------------------------- test_find_services --------------------------------------------\n");
-       test_find_services();
-
-       printf("\n -------------------------------------------- test_find_providers -------------------------------------------\n");
-       test_find_providers();
-
-       printf("\n -------------------------------------------- test_get_account_by_id ----------------------------------------\n");
-       test_get_account_by_id();
-
-       printf("\n -------------------------------------------- test_get_service_type_by_id -----------------------------------\n");
-       test_get_service_type_by_id();
-
-       printf("\n -------------------------------------------- test_get_provider_by_id ---------------------------------------\n");
-       test_get_provider_by_id();
-
-       printf("\n -------------------------------------------- test_find_service_types--------------------------------------- \n");
-       test_find_service_types();
-
-       printf("\n -------------------------------------------- test_get_service_by_id--------------------------------------- \n");
-       test_get_service_by_id();
-
-       printf("\n -------------------------------------------- test_get_service_by_name--------------------------------------- \n");
-       test_get_service_by_name();
-
-}
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-AccountWrapper::AccountWrapper() : m_platformAccount(NULL), m_abstractAccount(NULL)
-{
-    LogDebug("entered");
-    m_abstractAccount = EventAccountPtr(new EventAccount());
-    if (!m_abstractAccount) {
-        ThrowMsg(UnknownException, "abstract object is not created");
-    }
-}
-
-AccountWrapper::AccountWrapper(const EventAccountPtr &event) : m_platformAccount(NULL), m_abstractAccount(event)
-{
-    LogDebug("entered");
-}
-
-AccountWrapper::~AccountWrapper()
-{
-    LogDebug("entered");
-    //TODO: After inserting ,It seems like F/W frees handle. I need to review this later.
-    // After inserting and call freePlatformAccount, Segment fault occurs.
-    //freePlatformAccount();
-}
-
-int AccountWrapper::getIDFromPlatformAccount() const
-{
-    LogDebug("Entered");
-    int error_code = -1;
-       int accountid = 0;
-    if (m_platformAccount == NULL) {
-        ThrowMsg(NullPointerException, "m_platformAccount is not set");
-    }
-
-       error_code = account_get_account_id(m_platformAccount, &accountid);
-
-       if(ACCOUNT_ERROR_NONE != error_code)
-       {
-               ThrowMsg(PlatformException, "Can't get a account id");
-       }
-    return accountid;
-}
-
-//TODO: check if it works to dicriminate update/insert with account id.
-void AccountWrapper::saveAccount()
-{
-    LogDebug("entered");
-
-    int accountID = 0;
-    //Check if platform struct is set.
-    //It could be set here, but forcing user to do it manually can help to avoid problems.
-    if (m_platformAccount == NULL) {
-        ThrowMsg(NullPointerException, "m_platformAccount is not set");
-    }
-
-    accountID = m_abstractAccount->getID();
-
-    displayPlatformAccount();
-
-    int returnID;
-
-    //insert new record or update existing one
-    if (accountID < 0) { // insert new account
-       int err = 0;
-//         err = addAccount(m_abstractAccount->getProviderName().c_str(), &property, &user_account);
-               user_account.AccountId = g_strdup("com.google:myaccount1@gmail.com");
-
-//        int err = account_insert_to_db(m_platformAccount, &returnID);
-        if (ACCOUNT_ERROR_NONE != err) {
-            LogError("Can't insert new account, error code: " << returnID);
-            ThrowMsg(PlatformException, "Can't insert new account.");
-        }
-        m_abstractAccount->setID(returnID);
-               m_abstractAccount->setAccountId(user_account.AccountId);
-
-        LogInfo("New event inserted");
-    } else { //update
-
-          //accountID = getIDFromPlatformAccount();
-         LogDebug("accountID: " << accountID);
-        if (ACCOUNT_ERROR_NONE != account_update_to_db_by_id(m_platformAccount, accountID)) {
-            ThrowMsg(PlatformException, "Can't update new account.");
-        }
-        LogDebug("Account updated");
-    }
-
-                       }
-
-void AccountWrapper::loadAccount(int id)
-{
-       LogDebug("Entered. ID of account to load: " << id);
-
-       freePlatformAccount();
-
-       if (ACCOUNT_ERROR_NONE != account_create(&m_platformAccount)) {
-               ThrowMsg(PlatformException, "Can't create handle");
-       }
-
-       int errorCode = account_query_account_by_account_id(id, &m_platformAccount);
-
-       if (ACCOUNT_ERROR_NONE != errorCode) {
-               LogError("Can't get account with ID = " << id << ", error code: " << errorCode);
-               ThrowMsg(PlatformException, "Can't get account with ID = " << id << ", error code: " << errorCode);
-       }
-       convertPlatformAccountToAbstractAccount();
-       displayAbstractAccount();
-}
-
-void AccountWrapper::deleteAccount()
-{
-    if (m_platformAccount == NULL) {
-        ThrowMsg(NullPointerException, "Failed to delete event (m_platformAccount==NULL)");
-    }
-    int accountID = m_abstractAccount->getID();
-    LogDebug("accountID : " << accountID);
-    if (accountID < 0) {
-        ThrowMsg(InvalidArgumentException, "Failed to delete account from account DB (account is not saved in account DB)");
-    }
-
-    int err = -1;
-    err = account_delete_from_db_by_id(accountID);
-    if (ACCOUNT_ERROR_NONE != err) {
-        ThrowMsg(PlatformException, "Can't delete account. Error code " << err);
-    }
-    //TODO: Is it necessary?
-    //m_abstractAccount->resetId();
-    //setIDToPlatformAccount();
-}
-
-void AccountWrapper::getAccountbyId()
-{
-       account = g_new0(UserAccount_t, 1);
-
-//     int errorCode = getAccountById((char*)m_abstractAccount->getAccountId().c_str(), account);
-       getAccountById((char*)m_abstractAccount->getAccountId().c_str(), account);
-/*
-       if (ACCOUNT_ERROR_NONE != errorCode) {
-               LogError("Can't get account with ID = " << id << ", error code: " << errorCode);
-               ThrowMsg(PlatformException, "Can't get account with ID = " << id << ", error code: " << errorCode);
-       }
-*/
-       if(account->AccountId)
-               m_abstractAccount->setAccountId(account->AccountId);
-
-       if(account->displayName)
-               m_abstractAccount->setDisplayName(account->displayName);
-
-       if(account->icon)
-               m_abstractAccount->setIconPath(account->icon);
-
-       if(account->AccountServiceProviderId)
-               m_abstractAccount->setProviderName(account->AccountServiceProviderId);
-
-       m_abstractAccount->setEnabled(account->enabled);
-       std::stringstream sstream;
-       sstream << account->credentialId;
-       m_abstractAccount->setCredentailId(sstream.str());
-
-       if(account->settings)
-               m_abstractAccount->setSettings(account->settings);
-
-       getAccountServices();
-//     convertPlatformAccountToAbstractAccount();
-
-       free_single_value(account->AccountId);
-       free_single_value(account->displayName);
-       free_single_value(account->icon);
-       free_single_value(account->AccountServiceProviderId);
-       free_single_value(account->settings);
-       free(account);
-
-}
-
-AccountServiceProviderPropertyArrayPtr AccountWrapper::findProviders(std::string serviceTypeId)
-{
-       LogDebug("<<<");
-
-       AccountServiceProviderPropertyArrayPtr serviceProviderPropertiesPtr(new AccountServiceProviderPropertyArray);
-
-       GList* provider_list = NULL;
-       GList* tmp_list = NULL;
-
-       find_providers((char*)serviceTypeId.c_str(), &provider_list);
-       tmp_list = provider_list;
-
-       while(tmp_list)
-       {
-               provider_t* provider = (provider_t*)tmp_list->data;
-
-               AccountServiceProviderPropertyPtr serviceProviderPropertyPtr(new AccountServiceProviderProperty());
-
-               if(provider->AccountServiceProviderId)
-                       serviceProviderPropertyPtr->setId(provider->AccountServiceProviderId);
-
-               if(provider->displayName)
-                       serviceProviderPropertyPtr->setDisplayName(provider->displayName);
-
-               if(provider->icon)
-                       serviceProviderPropertyPtr->setIconPath(provider->icon);
-
-               serviceProviderPropertiesPtr->push_back(serviceProviderPropertyPtr);
-
-               tmp_list = g_list_next(tmp_list);
-       }
-       free_provider_list(provider_list);
-
-       LogDebug(">>>");
-       return serviceProviderPropertiesPtr;
-}
-
-void AccountWrapper::setTags(std::vector<std::string> &tagsVector, GList* tags_list)
-{
-       GList* tmp_tags_list = tags_list;
-       while(tmp_tags_list)
-       {
-               tags_info_t* tag = (tags_info_t*)tmp_tags_list->data;
-               tagsVector.push_back(tag->tag_info);
-               tmp_tags_list = g_list_next(tmp_tags_list);
-       }
-}
-
-AccountServiceTypePropertyArrayPtr AccountWrapper::findServiceTypes()
-{
-       AccountServiceTypePropertyArrayPtr servicetypes(new AccountServiceTypePropertyArray());
-
-       GList* servicetype_list = NULL;
-       find_service_types((char*)m_abstractAccount->getprefix().c_str(), &servicetype_list);
-
-       GList* tmp_list = servicetype_list;
-       while(tmp_list)
-       {
-               AccountServiceType_t* serviceType_info = (AccountServiceType_t*)tmp_list->data;
-
-               AccountServiceTypePropertyPtr serviceType(new AccountServiceTypeProperty());
-
-               if(serviceType_info->AccountServiceTypeId)
-                       serviceType->setId(serviceType_info->AccountServiceTypeId);
-
-               if(serviceType_info->displayName)
-                       serviceType->setDisplayName(serviceType_info->displayName);
-
-               if(serviceType_info->icon)
-                       serviceType->setIconPath(serviceType_info->icon);
-
-// add tags
-               std::vector<std::string> tagsVector;
-
-               setTags(tagsVector, serviceType_info->tags_info);
-               if(serviceType_info->tags_info)
-                       serviceType->setTags(tagsVector);
-
-               servicetypes->push_back(serviceType);
-               tmp_list = g_list_next(tmp_list);
-       }
-       free_serviceType_list(servicetype_list);
-
-       return servicetypes;
-}
-
-char *AccountWrapper::getPlatformAccount() const
-{
-    LogDebug("entered");
-    return (char*)m_platformAccount;
-}
-
-                       EventAccountPtr AccountWrapper::getAbstractAccount() const {
-                               LogDebug("entered");
-                               return m_abstractAccount;
-                       }
-
-                       void AccountWrapper::freePlatformAccount() {
-                               LogDebug("entered");
-                               if (m_platformAccount != NULL) {
-                                       if (ACCOUNT_ERROR_NONE != account_destroy(m_platformAccount)) {
-                                               LogError("Can't free account handle.");
-                                       }
-                                       m_platformAccount = NULL;
-                               }
-                       }
-
-                       char *AccountWrapper::convertAbstractAccountToPlatformAccount() {
-                               LogDebug("entered");
-                               freePlatformAccount();
-
-                               if (ACCOUNT_ERROR_NONE != account_create(&m_platformAccount)) {
-                                       ThrowMsg(PlatformException, "Can't create handle");
-                               }
-
-                               property.displayName = g_strdup(m_abstractAccount->getDisplayName().c_str());
-                               property.icon = g_strdup(m_abstractAccount->getIconPath().c_str());
-
-                               setDisplayNameToPlatformAccount();
-                               setIconPathToPlatformAccount();
-                               setProviderNameToPlatformAccount();
-                               /*
-                                setUserNameToPlatformAccount();
-                                setPackageNameToPlatformAccount();
-
-                                //TODO: check if we need to have  user be able to set  the ID.
-                                //setIDToPlatformAccount();
-                                setEmailAddressToPlatformAccount();
-                                setDomainNameToPlatformAccount();
-
-                                setAccountServices();
-                                */
-                               return getPlatformAccount();
-                       }
-
-                       void AccountWrapper::setIDToPlatformAccount() {
-                               LogDebug("entered");
-
-//TODO: check if we need to have  user be able to set  the ID.
-
-#if 0
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-    if (m_abstractAccount->getIdIsSet()) {
-        if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
-                                                       CAL_VALUE_INT_INDEX,
-                                                       m_abstractEvent->getId()))
-        {
-            ThrowMsg(PlatformException, "Can't set event ID.");
-        }
-    } else {
-        if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
-                                                       CAL_VALUE_INT_INDEX,
-                                                       NEW_EVENT_ID)) {
-            ThrowMsg(PlatformException, "Can't set event ID.");
-        }
-    }
-#endif
-}
-
-                       void AccountWrapper::setDisplayNameToPlatformAccount()
-                       {
-                          LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               if (ACCOUNT_ERROR_NONE != account_set_display_name(m_platformAccount, m_abstractAccount->getDisplayName().c_str()))
-                               {
-                                       ThrowMsg(PlatformException, "Can't set displayname.");
-                               }
-
-                       }
-
-                       void AccountWrapper::setIconPathToPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               if (ACCOUNT_ERROR_NONE != account_set_icon_path(m_platformAccount, m_abstractAccount->getIconPath().c_str())) {
-                                       ThrowMsg(PlatformException, "Can't set iconPath.");
-                               }
-
-                       }
-
-                       void AccountWrapper::setProviderNameToPlatformAccount()
-                       {
-                          LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               if (ACCOUNT_ERROR_NONE != account_set_source(m_platformAccount, m_abstractAccount->getProviderName().c_str()))
-                               {
-                                       ThrowMsg(PlatformException, "Can't set providername.");
-                               }
-                       }
-
-                       void AccountWrapper::setEmailAddressToPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               if (ACCOUNT_ERROR_NONE != account_set_email_address(m_platformAccount, m_abstractAccount->getEmailAddress().c_str())) {
-                                       ThrowMsg(PlatformException, "Can't set packagename.");
-                               }
-                       }
-
-                       void AccountWrapper::setDomainNameToPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               if (ACCOUNT_ERROR_NONE != account_set_domain_name(m_platformAccount, m_abstractAccount->getDomainName().c_str())) {
-                                       ThrowMsg(PlatformException, "Can't set packagename.");
-                               }
-                       }
-
-                       /*
-                        void AccountWrapper::setHasContactFeatureToPlatformAccount()
-                        {
-                        LogDebug("entered");
-                        if (!m_platformAccount) {
-                        ThrowMsg(UnknownException, "Null platform pointer.");
-                        }
-                        account_set_capability(m_platformAccount, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
-                        }
-                        */
-
-                       void AccountWrapper::setAccountServices() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               AccountServicesArrayPtr services = m_abstractAccount->getService();
-                               if ((services == NULL) || (services->size() == 0))
-                                       return;
-
-                               //add new items
-                               for (size_t i = 0; i < services->size(); ++i) {
-                                       LogDebug("getServiceName : " << services->at(i)->getName().c_str());
-//         LogDebug("getServiceType : " << services->at(i)->getServiceType().c_str());
-                               }
-
-                       }
-
-void AccountWrapper::getAccountServices()
-{
-    LogDebug("entered");
-    if (!account) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-
-       AccountServicesArrayPtr services(new AccountServicesArray());
-
-       GList* tmp_service_list = account->services;
-       while(tmp_service_list)
-       {
-               AccountService_t* service_info = (AccountService_t*)tmp_service_list->data;
-
-               AccountServicesPtr service(new AccountServices());
-
-               if(service_info->AccountServiceId)
-                       service->setId(service_info->AccountServiceId);
-
-               if(service_info->serviceName)
-                       service->setName(service_info->serviceName);
-
-               if(service_info->applicationId)
-                       service->setApplicationId(service_info->applicationId);
-
-               if(service_info->displayName)
-                       service->setDisplayName(service_info->displayName);
-
-               if(service_info->icon)
-                       service->setIcon(service_info->icon);
-
-               if(service_info->AccountId)
-                       service->setAccountId(service_info->AccountId);
-
-               if(service_info->AccountServiceTypeId)
-                       service->setServiceTypeId(service_info->AccountServiceTypeId);
-
-               if(service_info->AccountServiceProviderId)
-                       service->setProviderId(service_info->AccountServiceProviderId);
-
-               if(service_info->setting)
-                       service->setSettings(service_info->setting);
-
-// add tags
-               std::vector<std::string> tagsVector;
-               setTags(tagsVector, service_info->tags_info);
-               if(service_info->tags_info)
-                       service->setTags(tagsVector);
-
-               services->push_back(service);
-               tmp_service_list = g_list_next(tmp_service_list);
-
-       }
-
-       m_abstractAccount->setService(services);
-
-       free_service_list(account->services);
-}
-
-AccountServiceTypePropertyPtr AccountWrapper::getAccountServiceTypebyId()
-{
-       std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
-       AccountServiceTypePropertyPtr accountServiceTypePropertyPtr(new AccountServiceTypeProperty);
-
-       db_util_open(_QUERY_DB_NAME, &test_hDBCt, 0);
-
-       AccountServiceType_t serviceType = {0, };
-       getServiceTypeById((char*)serviceTypeId.c_str(), &serviceType);
-
-       if(serviceType.AccountServiceTypeId)
-               accountServiceTypePropertyPtr->setId(serviceType.AccountServiceTypeId);
-
-       if(serviceType.displayName)
-               accountServiceTypePropertyPtr->setDisplayName(serviceType.displayName);
-
-       if(serviceType.icon)
-               accountServiceTypePropertyPtr->setIconPath(serviceType.icon);
-
-// add tags
-       std::vector<std::string> tagsVector;
-       setTags(tagsVector, serviceType.tags_info);
-       if(serviceType.tags_info)
-               accountServiceTypePropertyPtr->setTags(tagsVector);
-
-       free_single_value(serviceType.AccountServiceTypeId);
-       free_single_value(serviceType.displayName);
-       free_single_value(serviceType.icon);
-       free_tags_list(serviceType.tags_info);
-
-       return accountServiceTypePropertyPtr;
-}
-
-AccountServiceProviderPropertyPtr AccountWrapper::getAccountServiceProviderProperty()
-{
-       std::string accountServiceProviderId = m_abstractAccount->getProviderId();
-
-       provider_t provider = {0, };
-       getProviderById((char*)accountServiceProviderId.c_str(), &provider);
-
-       AccountServiceProviderPropertyPtr accountServiceProviderPropertyPtr(new AccountServiceProviderProperty);
-
-       if(provider.AccountServiceProviderId)
-               accountServiceProviderPropertyPtr->setId(provider.AccountServiceProviderId);
-
-       if(provider.displayName)
-               accountServiceProviderPropertyPtr->setDisplayName(provider.displayName);
-
-       if(provider.icon)
-               accountServiceProviderPropertyPtr->setIconPath(provider.icon);
-
-       free_single_value(provider.AccountServiceProviderId);
-       free_single_value(provider.displayName);
-       free_single_value(provider.icon);
-
-       return accountServiceProviderPropertyPtr;
-}
-
-void AccountWrapper::setDummyServices(){
-       LogDebug("<<<");
-
-       AccountServicesArrayPtr services(new AccountServicesArray());
-       for (int i = 0; i < 2; i++) {
-               AccountServicesPtr service(new AccountServices());
-
-               service->setId("dummy_id");
-               service->setName("dummy_name");
-               service->setApplicationId("dummy_applicationId");
-               service->setDisplayName("dummy_displayName");
-               service->setIcon("dummy_Icon");
-               service->setAccountId("dummy_accountId");
-               service->setServiceTypeId("dummy_serviceTypeId");
-               service->setProviderId("dummy_ProviderId");
-//             service->setTags("dummy_");
-                                       service->setSettings("dummy_settings");
-
-                                       services->push_back(service);
-                               }
-
-                               m_abstractAccount->setService(services);
-
-                               LogDebug(">>>");
-                       }
-
-EventAccountListPtr AccountWrapper::findAccountsByFilter(AccountServiceFilterPropertyPtr filterPropertyPtr)
-{
-       std::string provider = filterPropertyPtr->getProvider();
-       std::string serviceTypeId = filterPropertyPtr->getServiceTypeId();
-       std::vector<std::string> tags = filterPropertyPtr->getTags();
-
-       EventAccountListPtr retAccountListPtr(new EventAccountList);
-
-       GList* account_list = NULL;
-       search_list_t search_list = {0, };
-       set_account_filter(&search_list, PROVIDER_ID, (char*)provider.c_str());
-       set_account_filter(&search_list, SERVICE_TYPE_ID, (char*)serviceTypeId.c_str());
-       for (unsigned int i=0; i<tags.size(); i++)
-               set_account_filter(&search_list, TAGS, (char*)tags[i].c_str());
-
-       find_accounts(&search_list, DISABLE, &account_list);
-       while(account_list)
-       {
-               UserAccount_t* account_info = (UserAccount_t*)account_list->data;
-               EventAccountPtr account_ptr(new EventAccount());
-
-               if(account_info->AccountId)
-                       account_ptr->setAccountId(account_info->AccountId);
-
-               if(account_info->displayName)
-                       account_ptr->setDisplayName(account_info->displayName);
-
-               if(account_info->icon)
-                       account_ptr->setIconPath(account_info->icon);
-
-               if(account_info->AccountServiceProviderId)
-                       account_ptr->setProviderName(account_info->AccountServiceProviderId);
-
-               account_ptr->setEnabled(account_info->enabled);
-               std::stringstream sstream;
-               sstream << account_info->credentialId;
-               account_ptr->setCredentailId(sstream.str());
-
-               if(account_info->settings)
-                       account_ptr->setSettings(account_info->settings);
-
-               AccountServicesArrayPtr services(new AccountServicesArray());
-               GList* tmp_service_list = account_info->services;
-               while(tmp_service_list)
-               {
-                       AccountService_t* service_info = (AccountService_t*)tmp_service_list->data;
-
-                       AccountServicesPtr service(new AccountServices());
-
-                       if(service_info->AccountServiceId)
-                               service->setId(service_info->AccountServiceId);
-
-                       if(service_info->serviceName)
-                               service->setName(service_info->serviceName);
-
-                       if(service_info->applicationId)
-                               service->setApplicationId(service_info->applicationId);
-
-                       if(service_info->displayName)
-                               service->setDisplayName(service_info->displayName);
-
-                       if(service_info->icon)
-                               service->setIcon(service_info->icon);
-
-                       if(service_info->AccountId)
-                               service->setAccountId(service_info->AccountId);
-
-                       if(service_info->AccountServiceTypeId)
-                               service->setServiceTypeId(service_info->AccountServiceTypeId);
-
-                       if(service_info->AccountServiceProviderId)
-                               service->setProviderId(service_info->AccountServiceProviderId);
-
-                       if(service_info->setting)
-                               service->setSettings(service_info->setting);
-
-// add tags
-                       std::vector<std::string> tagsVector;
-                       setTags(tagsVector, service_info->tags_info);
-                       if(service_info->tags_info)
-                               service->setTags(tagsVector);
-
-                       services->push_back(service);
-                       tmp_service_list = g_list_next(tmp_service_list);
-
-               }
-               account_ptr->setService(services);
-               free_service_list(account_info->services);
-
-               free_single_value(account_info->AccountId);
-               free_single_value(account_info->displayName);
-               free_single_value(account_info->icon);
-               free_single_value(account_info->AccountServiceProviderId);
-               free_single_value(account_info->settings);
-               free(account_info);
-
-               retAccountListPtr->push_back(account_ptr);
-               account_list = g_list_next(account_list);
-       }
-
-       return retAccountListPtr;
-}
-
-AccountServicesArrayPtr AccountWrapper::findServiceByFilter(AccountServiceFilterPropertyPtr filterPropertyPtr)
-{
-       std::string provider = filterPropertyPtr->getProvider();
-       std::string serviceTypeId = filterPropertyPtr->getServiceTypeId();
-       std::vector<std::string> tags = filterPropertyPtr->getTags();
-
-       AccountServicesArrayPtr retServiceListPtr(new AccountServicesArray);
-
-       GList* service_list = NULL;
-       GList* tmp_service_list = NULL;
-       search_list_t search_list = {0, };
-       set_account_filter(&search_list, PROVIDER_ID, (char*)provider.c_str());
-       set_account_filter(&search_list, SERVICE_TYPE_ID, (char*)serviceTypeId.c_str());
-       for (unsigned int i=0; i<tags.size(); i++)
-               set_account_filter(&search_list, TAGS, (char*)tags[i].c_str());
-
-       find_services(&search_list, DISABLE, &service_list);
-       tmp_service_list = service_list;
-       while(tmp_service_list)
-       {
-               AccountService_t* service_info = (AccountService_t*)tmp_service_list->data;
-
-               AccountServicesPtr service(new AccountServices());
-
-               if(service_info->AccountServiceId)
-                       service->setId(service_info->AccountServiceId);
-
-               if(service_info->serviceName)
-                       service->setName(service_info->serviceName);
-
-               if(service_info->applicationId)
-                       service->setApplicationId(service_info->applicationId);
-
-               if(service_info->displayName)
-                       service->setDisplayName(service_info->displayName);
-
-               if(service_info->icon)
-                       service->setIcon(service_info->icon);
-
-               if(service_info->AccountId)
-                       service->setAccountId(service_info->AccountId);
-
-               if(service_info->AccountServiceTypeId)
-                       service->setServiceTypeId(service_info->AccountServiceTypeId);
-
-               if(service_info->AccountServiceProviderId)
-                       service->setProviderId(service_info->AccountServiceProviderId);
-
-               if(service_info->setting)
-                       service->setSettings(service_info->setting);
-
-// add tags
-               std::vector<std::string> tagsVector;
-               setTags(tagsVector, service_info->tags_info);
-               if(service_info->tags_info)
-                       service->setTags(tagsVector);
-
-               retServiceListPtr->push_back(service);
-               tmp_service_list = g_list_next(tmp_service_list);
-       }
-
-       free_service_list(service_list);
-
-       return retServiceListPtr;
-}
-
-EventAccountPtr AccountWrapper::convertPlatformAccountToAbstractAccount()
-{
-    LogDebug("entered");
-    setDisplayNameFromPlatformAccount();
-       setIconPathFromPlatformAccount();
-    setProviderNameFromPlatformAccount();
-
-/*
-    setUserNameFromPlatformAccount();
-    setPackageNameFromPlatformAccount();
-    setIDFromPlatformAccount();
-    setEmailAddressFromPlatformAccount();
-    setDomainNameFromPlatformAccount();
-
-       getAccountServices();
-*/
-    displayPlatformAccount();
-    return getAbstractAccount();
-}
-
-EventAccountPtr AccountWrapper::convertPlatformAccountToAbstractAccount(account_h account_info)
-{
-    LogDebug("entered");
-       m_platformAccount = account_info;
-    setDisplayNameFromPlatformAccount();
-       setIconPathFromPlatformAccount();
-    setProviderNameFromPlatformAccount();
-/*
-    setUserNameFromPlatformAccount();
-    setPackageNameFromPlatformAccount();
-    setIDFromPlatformAccount();
-    setEmailAddressFromPlatformAccount();
-    setDomainNameFromPlatformAccount();
-
-       getAccountServices();
-*/
-    displayPlatformAccount();
-    return getAbstractAccount();
-}
-
-void AccountWrapper::setIDFromPlatformAccount()
-{
-    LogDebug("entered");
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-    m_abstractAccount->setID(getIDFromPlatformAccount());
-}
-
-void AccountWrapper::setDisplayNameFromPlatformAccount()
-{
-    LogDebug("entered");
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-
-    char *displayname = NULL;
-       account_get_display_name(m_platformAccount, &displayname);
-    if (displayname) {
-        m_abstractAccount->setDisplayName(displayname);
-    }
-}
-
-void AccountWrapper::setIconPathFromPlatformAccount()
-{
-   LogDebug("entered");
-   if (!m_platformAccount) {
-       ThrowMsg(UnknownException, "Null platform pointer.");
-   }
-
-   char *iconPath = NULL;
-        account_get_icon_path(m_platformAccount, &iconPath);
-   if (iconPath) {
-       m_abstractAccount->setIconPath(iconPath);
-   }
-}
-
-                       void AccountWrapper::setProviderNameFromPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               char *providername = NULL;
-                               account_get_source(m_platformAccount, &providername);
-                               if (providername) {
-                                       m_abstractAccount->setProviderName(providername);
-                               }
-                       }
-
-                       void AccountWrapper::setEmailAddressFromPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               char *emailaddress = NULL;
-                               account_get_email_address(m_platformAccount, &emailaddress);
-                               if (emailaddress) {
-                                       m_abstractAccount->setEmailAddress(emailaddress);
-                               }
-                       }
-
-                       void AccountWrapper::setDomainNameFromPlatformAccount() {
-                               LogDebug("entered");
-                               if (!m_platformAccount) {
-                                       ThrowMsg(UnknownException, "Null platform pointer.");
-                               }
-
-                               char *domainname = NULL;
-                               account_get_domain_name(m_platformAccount, &domainname);
-                               if (domainname) {
-                                       m_abstractAccount->setDomainName(domainname);
-                               }
-                       }
-
-                       void AccountWrapper::displayAbstractAccount() {
-                               LogDebug("account id : " << m_abstractAccount->getID());
-                               LogDebug("Display name  : " << m_abstractAccount->getDisplayName());
-                       }
-
-                       void AccountWrapper::displayPlatformAccount() {
-
-                       }
-
-               }
-       }
-}
diff --git a/src/platform/Tizen/Account/AccountWrapper.h b/src/platform/Tizen/Account/AccountWrapper.h
deleted file mode 100755 (executable)
index 138d03d..0000000
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        AccountWrapper.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _TIZEN_ACCOUNT_WRAPPER_H_
-#define _TIZEN_ACCOUNT_WRAPPER_H_
-
-#include <string>
-#include <dpl/shared_ptr.h>
-#include <API/Account/EventAccount.h>
-#include <API/Account/AccountServiceTypeProperty.h>
-#include <API/Account/AccountServiceProviderProperty.h>
-#include <API/Account/AccountServiceFilterProperty.h>
-
-#include "account.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-
-typedef struct
-{
-       char* AccountId;
-       char* displayName;
-       char* icon;
-       bool enabled;
-       char* AccountServiceProviderId;
-       unsigned long credentialId;
-       GList* services; // AccountService_t
-       char* settings;
-}UserAccount_t;
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-
-class AccountWrapper
-{
-       public:
-               AccountWrapper();
-               explicit AccountWrapper(const EventAccountPtr &event);
-               virtual ~AccountWrapper();
-               char  *convertAbstractAccountToPlatformAccount();
-               EventAccountPtr convertPlatformAccountToAbstractAccount();
-               EventAccountPtr convertPlatformAccountToAbstractAccount(account_h account_info);
-
-               char  *getPlatformAccount() const;
-               EventAccountPtr getAbstractAccount() const;
-               void        freePlatformAccount();
-               void        saveAccount();
-               void        loadAccount(int id);
-               void        deleteAccount();
-               void            getAccountbyId();
-               AccountServiceProviderPropertyArrayPtr          findProviders(std::string serviceTypeId);
-               AccountServiceTypePropertyArrayPtr              findServiceTypes();
-               void            setTags(std::vector<std::string> &tagsVector, GList* tags_list);
-
-               AccountServiceTypePropertyPtr getAccountServiceTypebyId();
-               AccountServiceProviderPropertyPtr getAccountServiceProviderProperty();
-
-               EventAccountListPtr findAccountsByFilter(AccountServiceFilterPropertyPtr filterPropertyPtr);
-               AccountServicesArrayPtr findServiceByFilter(AccountServiceFilterPropertyPtr filterPropertyPtr);
-
-               //dummy method
-               void setDummyServices();
-
-       protected:
-               int  getIDFromPlatformAccount() const;
-
-               void setIDFromPlatformAccount();
-               void setIDToPlatformAccount();
-
-               void setDisplayNameFromPlatformAccount();
-               void setDisplayNameToPlatformAccount();
-
-               void setIconPathFromPlatformAccount();
-               void setIconPathToPlatformAccount();
-
-               void setProviderNameFromPlatformAccount();
-               void setProviderNameToPlatformAccount();
-
-               void setEmailAddressFromPlatformAccount();
-               void setEmailAddressToPlatformAccount();
-
-               void setDomainNameFromPlatformAccount();
-               void setDomainNameToPlatformAccount();
-
-               void setAccountServices();
-               void getAccountServices();
-
-       private:
-               void displayAbstractAccount();     //only for debugging
-               void displayPlatformAccount();     //only for debugging
-
-               account_h m_platformAccount;
-               EventAccountPtr m_abstractAccount;
-
-               UserAccount_t* account;
-
-//             static std::map<std::string, std::string> attrSvcMap;
-
-};
-
-typedef DPL::SharedPtr<AccountWrapper> AccountWrapperPtr;
-}
-}
-}
-#endif
diff --git a/src/platform/Tizen/Account/config.cmake b/src/platform/Tizen/Account/config.cmake
deleted file mode 100755 (executable)
index 071ce1a..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-get_current_path()
-
-pkg_search_module(account REQUIRED accounts-svc)
-pkg_search_module(glib REQUIRED glib-2.0)
-pkg_search_module(libpcrecpp REQUIRED libpcrecpp)
-
-set(INCLUDES_PLATFORM_IMPLEMENTATION_ACCOUNT
-  ${account_INCLUDE_DIRS}
-  ${glib_INCLUDE_DIRS}
-  ${libpcrecpp_INCLUDE_DIRS}
-  PARENT_SCOPE
-)
-
-set(LIBS_PLATFORM_IMPLEMENTATION_ACCOUNT
-  ${account_LIBRARIES}
-  ${glib_LIBRARIES}
-  ${libpcrecpp_LIBRARIES}
-  PARENT_SCOPE
-)
-
-set(SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT
-#  ${CURRENT_PATH}/AccountService.cpp
-  ${CURRENT_PATH}/AccountManager.cpp
-  ${CURRENT_PATH}/AccountWrapper.cpp
-  PARENT_SCOPE
-)
diff --git a/src/platform/Tizen/Account/old/AccountService.cpp b/src/platform/Tizen/Account/old/AccountService.cpp
deleted file mode 100755 (executable)
index e596f63..0000000
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        Account.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include <dpl/log/log.h>
-#include <dpl/scoped_ptr.h>
-
-#include "AccountManager.h"
-#include "API/Account/OnAddEventsChanged.h"
-#include "API/Account/OnUpdateEventsChanged.h"
-#include "API/Account/OnDeleteEventsChanged.h"
-#include "account-svc-db.h"
-#include "AccountService.h"
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-
-AccountService::AccountService()
-{
-    LogDebug("entered");
-}
-
-AccountService::~AccountService()
-{
-    LogDebug("entered");
-}
-
-//TODO: implmeting Eventwrapper
-
-
-void AccountService::OnRequestReceived(const IEventDeleteAccountPtr &account)
-{
-    LogDebug("entered");
-#if 1
-
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-
-        //TODO: check if ID is valid
-        /*
-        if (!account->getEvent()->getIdIsSet()) {
-            ThrowMsg(Commons::InvalidArgumentException,
-                     "Cannot delete non-existing event.");
-        }
-        */
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(
-                                                      account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-        accountWrapper->deleteAccount();
-        account->setResult(true);
-    }
-    catch (const NotFoundException &ex)
-    {
-        LogError("event doesn't exist");
-        account->setResult(false);
-        account->setExceptionCode(ExceptionCodes::NotFoundException);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during deleting event " << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-#endif
-}
-
-void AccountService::OnRequestReceived(const IEventUpdateAccountPtr &account)
-{
-    LogDebug("entered");
-#if 1
-
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-  /*      if (!account->getEvent()->getIdIsSet()) {
-            ThrowMsg(
-                Commons::InvalidArgumentException,
-                "Cannot update non-existing event. Event needs adding or ID is wrong");
-        }*/
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(
-                                                      account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-        accountWrapper->saveAccount();
-        account->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during updating event " << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-#endif
-}
-
-void AccountService::OnRequestReceived(const IEventFindAccountsPtr &event)
-{
-    LogDebug("entered");
-
-    const AccountFilterPtr &filter = event->getFilter();
-    char* handle = NULL;
-    int error_code = ACCOUNT_OPERATION_SUCCESS;
-
-       try {
-
-        if (NULL != filter)
-               {
-            if(filter->getIdIsSet()) {
-                std::istringstream istream(filter->getIdFilter());
-                int id;
-                istream>>id;
-                               LogDebug("id : " << id);
-            }
-               }
-
-               if (ACCOUNT_OPERATION_SUCCESS != account_svc_new(ACCOUNT_CATEGORY, &handle)) {
-                       ThrowMsg(PlatformException, "Can't create handle");
-               }
-               if (ACCOUNT_OPERATION_SUCCESS != account_svc_get_account_list(handle, 0)) {
-                       ThrowMsg(PlatformException, "Can't get all  records");
-               }
-
-               while(error_code== ACCOUNT_OPERATION_SUCCESS)
-               {
-                   event->tryCancelled();
-                   int accountId = account_svc_get_value_int(handle, ACCOUNT_ID, &error_code);
-
-                   if(error_code!=ACCOUNT_OPERATION_SUCCESS)   {
-                               ThrowMsg(PlatformException, "Can't get handle");
-                       }
-
-                       DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-                       accountWrapper->loadAccount(accountId);
-                       event->addEvent(accountWrapper->getAbstractAccount());
-                       error_code = account_svc_get_next_val(handle);
-               }
-               event->setResult(true);
-               account_svc_get_finish(handle);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
-        event->setResult(false);
-    }
-
-    event->setCancelAllowed(true);
-}
-
-void AccountService::OnRequestReceived(const IEventCreateAccountPtr &event)
-{
-    LogDebug("entered");
-}
-
-void AccountService::OnRequestReceived(const IEventAddAccountPtr &account)
-{
-    LogDebug("entered");
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-       /* if (account->getEvent()->getIdIsSet()) {
-            LogWarning("adding event that is already added");
-            account->getEvent()->resetId();
-        }*/
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(
-                                                      account->getEvent()));
-        accountWrapper->convertAbstractAccountToPlatformAccount();
-        if (account->checkCancelled()) {
-            account->setCancelAllowed(true);
-            account->setResult(true);
-            return;
-        }
-        accountWrapper->saveAccount();
-        account->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Error during adding event" << ex.DumpToString());
-        account->setResult(false);
-    }
-    account->setCancelAllowed(false);
-}
-
-}
-}
-}
diff --git a/src/platform/Tizen/Account/old/AccountService.h b/src/platform/Tizen/Account/old/AccountService.h
deleted file mode 100755 (executable)
index 0b63ff8..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/**
- * @file        AccountService.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _TIZEN_ACCOUNT_H_
-#define _TIZEN_ACCOUNT_H_
-
-#include <list>
-#include "API/Account/IAccountService.h"
-#include "AccountWrapper.h"
-
-using namespace TizenApis::Api::Account;
-//using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-class AccountService : public IAccountService
-{
-  public:
-    AccountService();
-    virtual ~AccountService();
-  protected:
-    virtual void OnRequestReceived(const IEventDeleteAccountPtr &account);
-    virtual void OnRequestReceived(const IEventUpdateAccountPtr &account);
-    virtual void OnRequestReceived(const IEventFindAccountsPtr &account);
-    virtual void OnRequestReceived(const IEventCreateAccountPtr &account);
-    virtual void OnRequestReceived(const IEventAddAccountPtr &account);
-
-};
-
-}
-}
-}
-#endif 
index ae13b88..97d0b70 100755 (executable)
@@ -40,10 +40,18 @@ using namespace DPL;
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace Platform;
-
 namespace {
 
        extern "C" int service_create_event(bundle *data, struct service_s **service);
+       extern "C" int aul_listen_app_dead_signal(int (*func) (int, void *), void *data);
+
+       static int app_dead_handler(int pid, void* user_data)
+       {
+               LogDebug("kill Callback called");
+               Application* appManager = (Application*)(user_data);
+               appManager->callKillEventCallback(pid);
+               return 0;
+       }
 
        // callback function to get package name. this callback is called from getPackageById()
        static ail_cb_ret_e appinfoCallback(const ail_appinfo_h appinfo, void *user_data)
@@ -192,9 +200,10 @@ namespace {
                                free(iconPath);
                        if (version)
                                free(version);
-                       if (appid)
-                               free(appid);
                }
+               if (appid)
+                       free(appid);
+               
                return true;
        }
 
@@ -267,7 +276,6 @@ namespace {
                                        for (int i = 0; i < length; i++) {
                                                valArray.push_back(value[i]);
                                        }
-
                                        event->addServiceData(keyStr, valArray);
 
                                        for (int i = 0; i < length; i++) {
@@ -276,7 +284,6 @@ namespace {
                                        }
                                        if (value)
                                                free(value);
-                                       
                                        break;
                                }
                                case SERVICE_ERROR_INVALID_PARAMETER:
@@ -369,17 +376,6 @@ void Application::kill(const EventManageApplicationPtr& event)
        EventRequestReceiver<EventManageApplication>::PostRequest(event);
 }
 
-void Application::exit()
-{
-       // should be changed to event raise
-       app_efl_exit();
-}
-
-void Application::hide()
-{
-       // hide application call
-}
-
 void Application::listApplications(const EventListInstalledApplicationsPtr& event)
 {
        if (m_initialized == false) {
@@ -564,7 +560,19 @@ void Application::launchServiceManualAnswer(service_h request, service_h reply,
        EventRequestReceiver<EventLaunchService>::ManualAnswer(m_eventLaunchServicePtr);
 }
 
-
+void Application::callKillEventCallback(int pid)
+{
+       DPL::Mutex::ScopedLock lock(&m_killMapLock);
+       std::map<int, EventManageApplicationPtr>::iterator it = m_killEventMap.find(pid);
+       if (it == m_killEventMap.end()) {
+               return;
+       } else {
+               EventManageApplicationPtr event = it->second;
+               m_killEventMap.erase(it);
+               LogDebug("calling kill success callback for pid::" << pid);
+               EventRequestReceiver<EventManageApplication>::ManualAnswer(event);
+       }
+}
 void Application::OnRequestReceived(const EventManageApplicationPtr& event)
 {
        switch (event->getEventType()) {
@@ -608,20 +616,47 @@ void Application::OnRequestReceived(const EventManageApplicationPtr& event)
                        break;
                }
                case EventManageApplication::APP_MANAGER_KILL_APPLICATION: {
-                       const char *contextId = event->getApplicationContext()->getContextId().c_str();
+                       const char *contextId = event->getContextId().c_str();
                        if (contextId == NULL) {
                                LogError("[ERROR] Can not get context id from context");
                                event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);
                        }
-                       
+
+                       LogError("[ERROR] contextId = "<<contextId);
                        int pid = atoi(contextId);
-                       int result = aul_terminate_pid(pid);
-                       if (result < 0) {
-                               LogError("[ERROR] Fail to terminate application with context");
-                               if (result == AUL_R_EINVAL) {
-                                       event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);
+                       LogError("[ERROR] pid = "<<pid);
+                       if (pid <= 0) {
+                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                               break;
+                       }
+                       char buf[256];
+                       if (aul_app_get_pkgname_bypid(pid, buf, 256) != AUL_R_OK) {
+                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                               break;
+                       }
+                       LogError("[ERROR] pkg = "<<buf);
+
+                       if (!aul_app_is_running(buf)) {
+                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                               break;
+                       }
+                       
+                       int result = aul_listen_app_dead_signal(app_dead_handler, this);
+                       if (result != 0) {
+                               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+                       } else {
+                               result = aul_terminate_pid(pid);
+                               if (result < 0) {
+                                       LogError("[ERROR] Fail to terminate application with context");
+                                       if (result == AUL_R_EINVAL) {
+                                               event->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);
+                                       } else {
+                                               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+                                       }
                                } else {
-                                       event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+                                       DPL::Mutex::ScopedLock lock(&m_killMapLock);
+                                       m_killEventMap[pid] = event;
+                                       event->switchToManualAnswer();
                                }
                        }
                        break;
@@ -689,32 +724,49 @@ void Application::OnRequestReceived(const EventGetApplicationPtr& event)
                        break;
                }
                case EventGetApplication::APP_MANAGER_GET_CONTEXT: {
-                       char *package;
-                       char contextId[PATH_MAX];
-                       snprintf(contextId, PATH_MAX, "%d", getpid());
-
-                       if (app_get_package(&package) != 0) {
-                               LogError("[ERROR] Can not get package name from current pid");
-                               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-                       } else {
-                               char *appId = getIdFromPackage(package);
-                               if (appId == NULL) {
+                       charpackage;
+                       char *appId;
+                       std::string contextId = event->getContextId();
+                       
+                       if (contextId.empty()) {
+                               char currPID[PATH_MAX];
+                               snprintf(currPID, PATH_MAX, "%d", getpid());
+                               contextId = std::string(currPID);
+                               
+                               if (app_get_package(&package) != APP_ERROR_NONE) {
                                        LogError("[ERROR] Can not get package name from current pid");
                                        event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
                                        break;
                                }
-                               
-                               ApplicationContextPtr appContext(new ApplicationContext());
-                               appContext->setAppId(appId);
-                               appContext->setContextId(contextId);
-
-                               event->setApplicationContext(appContext);
-                               
-                               if (package)
-                                       free(package);
-                               if (appId)
-                                       free(appId);
+                       } else {
+                               int pid = atoi(contextId.c_str());
+                               if (pid <= 0) {
+                                       event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                                       break;
+                               }
+                               package = (char*)calloc(sizeof(char), PATH_MAX);
+                               if ((package != NULL) && (aul_app_get_pkgname_bypid(pid, package, PATH_MAX) != AUL_R_OK)) {
+                                       event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                                       break;
+                               }
                        }
+                       appId = getIdFromPackage(package);
+                       if (appId == NULL) {
+                               LogError("[ERROR] Can not get package name from current pid");
+                               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+                               break;
+                       }
+                       
+                       ApplicationContextPtr appContext(new ApplicationContext());
+                       appContext->setAppId(appId);
+                       appContext->setContextId(contextId);
+
+                       event->setApplicationContext(appContext);
+                       
+                       if (package)
+                               free(package);
+                       if (appId)
+                               free(appId);
                        break;
                }
                default:
@@ -754,8 +806,9 @@ void Application::OnRequestReceived(const EventLaunchServicePtr& event)
 {
        switch(event->getEventType()) {
                case EventLaunchService::APPLICATION_SERVICE_GET_REQUEST: {
-                       // TODO: get bundle_str from wrt engine to get real request from caller. below bundle str is test code. 
-                       std::string bundle_str = "NQAAAAEEAAAUAAAAX19BUFBfU1ZDX09QX1RZUEVfXwARAAAAVEhJU19JU19PRVJBVElPTgAsAAAAAQQAABAAAABfX0FQUF9TVkNfVVJJX18ADAAAAFRISVNfSVNfVVJJADMAAAABBAAAFgAAAF9fQVBQX1NWQ19NSU1FX1RZUEVfXwANAAAAVEhJU19JU19NSU1FADUAAAABBAAAFQAAAF9fQVBQX1NWQ19QS0dfTkFNRV9fABAAAABUSElTX0lTX1BBQ0tBR0UAMgAAAAEEAAAQAAAARVhUUkFfREFUQV9LRVkxABIAAABFWFRSQV9EQVRBX1ZBTFVFMQAyAAAAAQQAABAAAABFWFRSQV9EQVRBX0tFWTIAEgAAAEVYVFJBX0RBVEFfVkFMVUUyAHoAAAABBQAAFgAAAEVYVFJBX0RBVEFfQVJSQVlfS0VZMQADAAAAGAAAABgAAAAYAAAARVhUUkFfREFUQV9BUlJBWV9WQUxVRTEARVhUUkFfREFUQV9BUlJBWV9WQUxVRTIARVhUUkFfREFUQV9BUlJBWV9WQUxVRTMA";
+                       std::string bundle_str = event->getEncodedBundle();
+                       //LogError("bundle_str : "<<bundle_str);
+
                        service_h service;
                        char* tmpStr = NULL;
 
@@ -765,7 +818,6 @@ void Application::OnRequestReceived(const EventLaunchServicePtr& event)
                                // TODO: find proper exception.
                                event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
                        }
-
                        ApplicationServicePtr appService(new ApplicationService());
                        appService->setService_h(service);
 
@@ -793,20 +845,9 @@ void Application::OnRequestReceived(const EventLaunchServicePtr& event)
                                        tmpStr = NULL;
                                }                       
                        }
-                       if (service_get_package(service, &tmpStr) == SERVICE_ERROR_NONE) {
-                               LogInfo("package : "<<tmpStr);
-                               if (tmpStr != NULL) {
-                                       char* appId = getIdFromPackage(tmpStr);
-                                       LogInfo("appId : "<<appId);                                     
-                                       if (appId != NULL) {
-                                               appService->setAppId(appId);
-                                               free(appId);
-                                       }
-                                       free(tmpStr);
-                               }                       
-                       }
 
                        event->setService(appService);
+
                        if (service_foreach_extra_data(service, serviceExtraDataCallback, event.Get()) != SERVICE_ERROR_NONE) {
                                LogError("service_foreach_extra_data fail");
                                event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
@@ -834,7 +875,7 @@ void Application::OnRequestReceived(const EventLaunchServicePtr& event)
                        }
 
                        if (appservice->getUri().compare("") != 0) {
-                               LogDebug("uri is not null");
+                               LogDebug("uri is "<<appservice->getUri());
                                service_set_uri(service, appservice->getUri().c_str() );
                        }
 
@@ -843,9 +884,9 @@ void Application::OnRequestReceived(const EventLaunchServicePtr& event)
                                service_set_mime(service, appservice->getMime().c_str() );
                        }
 
-                       if (appservice->getAppId().compare("") != 0) {
-                               LogDebug("appId is "<<appservice->getAppId());
-                               char* pkg = getPackageById(appservice->getAppId().c_str());
+                       if (event->getAppId().compare("") != 0) {
+                               LogDebug("appId is "<<event->getAppId());
+                               char* pkg = getPackageById(event->getAppId().c_str());
                                if (pkg != NULL) {
                                        service_set_package(service, pkg);
                                        free(pkg);
index 230d2fa..d3b3b19 100755 (executable)
@@ -44,8 +44,6 @@ public:
        virtual ~Application();
        virtual void launch(const EventManageApplicationPtr& event);
        virtual void kill(const EventManageApplicationPtr& event);
-       virtual void exit();
-       virtual void hide();    
        virtual void listApplications(const EventListInstalledApplicationsPtr& event);
        virtual void getApplication(const EventGetApplicationPtr& event);
        virtual long addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter);
@@ -54,6 +52,7 @@ public:
        virtual void getApplicationService(const EventLaunchServicePtr& event);
        void launchServiceManualAnswer(service_h request, service_h reply, service_result_e result);            
        void InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package);
+       void callKillEventCallback(int pid);
 
 protected:
        virtual void OnRequestReceived(const EventListInstalledApplicationsPtr& event);
@@ -63,13 +62,15 @@ protected:
  
 private:
        void initialize();
+       EventManageApplicationPtr getKillEvent(int pid);
 
        DPL::Mutex m_initializationMutex;
        bool m_initialized;
        Api::Application::EventLaunchServicePtr m_eventLaunchServicePtr;        
        EventInstalledApplicationChangedEmitterPtr m_installedApplicationsEmitterPtr;
        std::map<std::string, std::string> m_installedApplicationList;
-       
+       std::map<int, EventManageApplicationPtr> m_killEventMap;
+       mutable DPL::Mutex m_killMapLock;
 };
 
 }
index ca9542a..1758d53 100644 (file)
@@ -51,6 +51,7 @@ static void capi_callback_bt_state_changed(int result, bt_adapter_state_e adapte
        {
                LogDebug("State Changed" << adapter_state);
                ((BluetoothAdapterManager*)user_data)->setPoweredManualAnswer();
+
        }
        else
        {
@@ -126,6 +127,13 @@ BluetoothAdapterManager::BluetoothAdapterManager()
 BluetoothAdapterManager::~BluetoothAdapterManager() 
 {
        LogDebug("Enter");
+       bt_adapter_unset_state_changed_cb();
+       bt_adapter_unset_name_changed_cb();
+       bt_adapter_unset_visibility_mode_changed_cb();
+       bt_adapter_unset_device_discovery_state_changed_cb();
+       bt_device_unset_bond_created_cb();
+       bt_device_unset_bond_destroyed_cb();
+       bt_device_unset_service_searched_cb();
 }
 
 void BluetoothAdapterManager::Init()
@@ -223,12 +231,6 @@ bool BluetoothAdapterManager::getVisibility()
 void BluetoothAdapterManager::setPowered(const  EventBTSetPoweredPtr& event) 
 {
        LogDebug("Enter");
-
-       if (event->isEnableRequested())
-       {       
-               Init();
-       }
-
        EventRequestReceiver<EventBTSetPowered>::PostRequest(event);
 }
 
@@ -278,14 +280,24 @@ void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDe
        LogDebug("Enter");
 
        int ret = 0;
-
-       m_discoverDevicesEmitter = emitter;
+       bool status = false;
        
        try 
        {
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
+               }
+
+               
+               if (ret = bt_adapter_is_discovering(&status) != BT_ERROR_NONE)
+               {
+                       ThrowMsg(Commons::UnknownException, "platform exception error" << ret);
+               }
+
+               if (status) 
+               {
+                       ThrowMsg(Commons::AlreadyInUseException, "now discover devices progressing");
                }
 
                if ((ret = bt_adapter_set_device_discovery_state_changed_cb(capi_callback_bt_discovery_state_changed, 
@@ -298,6 +310,7 @@ void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDe
                {
                        ThrowMsg(Commons::UnknownException, "device discovery fail" << ret);                    
                }
+               m_discoverDevicesEmitter = emitter;
                LogDebug("OK Discovery Start");         
        }
        catch (const Commons::Exception& ex) 
@@ -307,12 +320,12 @@ void BluetoothAdapterManager::discoveryDevicesEmitter(const EventBTOnDiscoveryDe
 
                EventBTOnDiscoveryDevicesPtr event(new EventBTOnDiscoveryDevices());
                event->setExceptionCode(ex.getCode());
-               m_discoverDevicesEmitter->emit(event);
+               emitter->emit(event);
        }
 }
 
 
-void BluetoothAdapterManager::discoveryDevicesCallbackEmit(unsigned short error, unsigned short state, 
+void BluetoothAdapterManager::discoveryDevicesCallbackEmit(int error, unsigned short state, 
        bt_adapter_device_discovery_info_s *discovery_info)
 
 {
@@ -325,7 +338,16 @@ void BluetoothAdapterManager::discoveryDevicesCallbackEmit(unsigned short error,
                if (discovery_info != NULL)
                {
                        device.address = discovery_info->remote_address;
-                       device.name = discovery_info->remote_name;
+
+                       if (discovery_info->remote_name == NULL)
+                       {
+                               device.name = "";
+                       }
+                       else 
+                       {
+                               device.name = discovery_info->remote_name;
+                       }
+                       
                        device.btClass.major = discovery_info->bt_class.major_device_class;
                        device.btClass.minor = discovery_info->bt_class.minor_device_class;
                        device.btClass.majorServiceMask = discovery_info->bt_class.major_service_class_mask;
@@ -378,15 +400,14 @@ void BluetoothAdapterManager::updateDevice(BluetoothDeviceData &device)
 
        for (i = 0; i < m_Devices.size(); i++)
        {
-               if (device.address == m_Devices[i].address &&
-                       device.name ==  m_Devices[i].name)
+               if (device.address == m_Devices[i].address)
                {
+                       m_Devices[i].name = device.name;
                        m_Devices[i].isBonded = device.isBonded;
                        m_Devices[i].isConnected = device.isConnected;  
                        m_Devices[i].isTrusted = device.isTrusted;
                        m_Devices[i].btClass = device.btClass;
                        m_Devices[i].uuids = device.uuids;
-                                       
                }
        }
 
@@ -422,7 +443,15 @@ void BluetoothAdapterManager::getKnownDevicesManualAnswer(bt_device_info_s *devi
        {
 
                device.address = device_info->remote_address;
-               device.name = device_info->remote_name;
+
+               if (device_info->remote_name == NULL)
+               {
+                       device.name = "";
+               }
+               else 
+               {
+                       device.name = device_info->remote_name;
+               }
 
                device.btClass.major = device_info->bt_class.major_device_class;
                device.btClass.minor = device_info->bt_class.minor_device_class;
@@ -458,7 +487,7 @@ void BluetoothAdapterManager::getDevice(const  EventBTGetDevicePtr& event)
        EventRequestReceiver<EventBTGetDevice>::PostRequest(event);
 }
 
-void BluetoothAdapterManager::serviceSearchManualAnswer(unsigned short error)
+void BluetoothAdapterManager::serviceSearchManualAnswer(int error)
 {
        try 
        {
@@ -484,7 +513,7 @@ void BluetoothAdapterManager::serviceSearchManualAnswer(unsigned short error)
                LogError("Exception: " << ex.GetMessage());
                m_EventBTGetDevicePtr->setExceptionCode(ex.getCode());
        }
-       
+       bt_device_unset_service_searched_cb();
        EventRequestReceiver<EventBTGetDevice>::ManualAnswer(m_EventBTGetDevicePtr);
 }
 
@@ -501,7 +530,15 @@ bool BluetoothAdapterManager::getDeviceManualAnswer(bt_device_info_s *device_inf
        int index = 0;
 
        device.address = device_info->remote_address;
-       device.name = device_info->remote_name;
+
+       if (device_info->remote_name == NULL)
+       {
+               device.name = "";
+       }
+       else 
+       {
+               device.name = device_info->remote_name;
+       }
 
        device.btClass.major = device_info->bt_class.major_device_class;
        device.btClass.minor = device_info->bt_class.minor_device_class;
@@ -557,17 +594,33 @@ void BluetoothAdapterManager::createBonding(const  EventBTCreateDestroyBondingPt
        EventRequestReceiver<EventBTCreateDestroyBonding>::PostRequest(event);
 }
 
-void BluetoothAdapterManager::createBondingManualAnswer(unsigned short error, bt_device_info_s *device_info)
+void BluetoothAdapterManager::createBondingManualAnswer(int error, bt_device_info_s *device_info)
 {
        int index = 0;
 
-       if (error == BT_ERROR_NONE)
+//     LogDebug("createBondingManualAnswer cancel" << error << " " << BT_ERROR_CANCELLED );
+
+       if (error == BT_ERROR_CANCELLED)
+       {
+               LogDebug("createBondingManualAnswer cancel");
+               m_EventBTCreateDestroyBondingPtr->setExceptionCode(Commons::ExceptionCodes::EventCancelledException);
+       }
+       else if (error == BT_ERROR_NONE)
        {
                LogDebug("createBondingManualAnswer");
                
                BluetoothDeviceData device;
                device.address = device_info->remote_address;
-               device.name = device_info->remote_name;
+
+               if (device_info->remote_name == NULL)
+               {
+                       device.name = "";
+               }
+               else 
+               {
+                       device.name = device_info->remote_name;
+               }
+               
                device.isBonded = device_info->is_bonded;
                device.isConnected = device_info->is_connected;
                device.isTrusted = device_info->is_authorized;
@@ -599,8 +652,17 @@ void BluetoothAdapterManager::createBondingManualAnswer(unsigned short error, bt
        }
        bt_device_unset_bond_created_cb();
        EventRequestReceiver<EventBTCreateDestroyBonding>::ManualAnswer(m_EventBTCreateDestroyBondingPtr);
+       m_EventBTCreateDestroyBondingPtr->setCancelAllowed(false);
 }
 
+bool BluetoothAdapterManager::createBondingCancel()
+{
+       int ret = bt_device_cancel_bonding();
+
+       LogDebug("Cancel returned" << ret);
+
+       return (ret == BT_ERROR_NONE);
+}
 
 
 void BluetoothAdapterManager::destroyBonding(const  EventBTCreateDestroyBondingPtr& event) 
@@ -609,7 +671,7 @@ void BluetoothAdapterManager::destroyBonding(const  EventBTCreateDestroyBondingP
        EventRequestReceiver<EventBTCreateDestroyBonding>::PostRequest(event);
 }
 
-void BluetoothAdapterManager::destroyBondingManualAnswer(unsigned short error)
+void BluetoothAdapterManager::destroyBondingManualAnswer(int error)
 {
        if (error == BT_ERROR_NONE)
        {
@@ -660,7 +722,8 @@ void BluetoothAdapterManager::setAdapterNameManualAnswer(char* deviceName)
        {
                m_EventBTSetNamePtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
        }
-       
+
+       bt_adapter_unset_name_changed_cb();
        EventRequestReceiver<EventBTSetName>::ManualAnswer(m_EventBTSetNamePtr);
 }
 
@@ -681,7 +744,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetPoweredPtr& eve
        {
                event->switchToManualAnswer();
                m_EventBTSetPoweredPtr = event; 
-
+               
                if( bt_adapter_set_state_changed_cb(capi_callback_bt_state_changed, (void*)this) != BT_ERROR_NONE )
                {
                        ThrowMsg(Commons::UnknownException, "call back set error");
@@ -706,7 +769,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetPoweredPtr& eve
                                break;
                        case BT_ERROR_RESOURCE_BUSY:
                                default:
-                               ThrowMsg(Commons::SecurityException, "bt is busy");
+                               ThrowMsg(Commons::AlreadyInUseException, "bt is busy");
                                break;
                        }
                }
@@ -742,7 +805,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTSetVisiblePtr& eve
        {
                if (m_btPowered == false)
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
                
                if (event->isVisibleRequested())
@@ -789,7 +852,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetKnownDevicesPtr
 
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
 
                if (bt_adapter_foreach_bonded_device(capi_callback_bt_adapter_bonded_device, (void*)this)!= BT_ERROR_NONE)
@@ -819,7 +882,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetDevicePtr& even
                
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
 
                if (bt_device_set_service_searched_cb(capi_bt_device_service_searched, (void*)this) != BT_ERROR_NONE)
@@ -838,6 +901,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTGetDevicePtr& even
                LogError("Exception: " << ex.GetMessage());
                event->setExceptionCode(ex.getCode());
                EventRequestReceiver<EventBTGetDevice>::ManualAnswer(event);
+               bt_device_unset_service_searched_cb();
        }
 }
 
@@ -853,9 +917,10 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTCreateDestroyBondi
                m_EventBTCreateDestroyBondingPtr = event;
                event->switchToManualAnswer();
 
+
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
 
 
@@ -891,6 +956,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTCreateDestroyBondi
                        }
 
                }
+               m_EventBTCreateDestroyBondingPtr->setCancelAllowed(true);
        }
        catch (const Commons::Exception& ex) 
        {
@@ -909,6 +975,7 @@ void BluetoothAdapterManager::OnRequestReceived(const  EventBTCreateDestroyBondi
                }
 
                EventRequestReceiver<EventBTCreateDestroyBonding>::ManualAnswer(event);
+               m_EventBTCreateDestroyBondingPtr->setCancelAllowed(false);
        }
 }
 
@@ -917,12 +984,14 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
        LogDebug("Enter");
        try 
        {
+               m_EventBTSetNamePtr = event;            
+               event->switchToManualAnswer();
                std::string adapterName = event->getName();
 
 
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
                
                if (adapterName.length() == 0)
@@ -940,16 +1009,15 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
                        ThrowMsg(Commons::PlatformException, "set name error");                 
                }
                
-               m_EventBTSetNamePtr = event;            
-               event->switchToManualAnswer();
 
        }
        catch (const Commons::Exception& ex) 
        {
                LogError("Exception: " << ex.GetMessage());
                event->setExceptionCode(ex.getCode());
+               EventRequestReceiver<EventBTSetName>::ManualAnswer(event);
+               bt_adapter_unset_name_changed_cb();
        }
-
 }
 
 /*void BluetoothAdapterManager::OnRequestReceived(const EventBTUnregisterRFCOMMServicePtr& event) 
@@ -963,13 +1031,13 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
                
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
 
                
                if (socketFd < 0)
                {
-                       ThrowMsg(Commons::UnsupportedException, "no service socket");
+                       ThrowMsg(Commons::AlreadyInUseException, "no service socket");
                }
 
                if (m_socketMap.size() != 0)
@@ -987,7 +1055,7 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
 
                if (bt_socket_destroy_rfcomm(socketFd) != BT_ERROR_NONE)
                {
-                       ThrowMsg(Commons::UnsupportedException, "socket destroy error");
+                       ThrowMsg(Commons::AlreadyInUseException, "socket destroy error");
                }
                event->setExceptionCode(Commons::ExceptionCodes::None);
        }
@@ -1003,12 +1071,22 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTSetNamePtr& event)
 void BluetoothAdapterManager::OnRequestReceived(const EventBTStopDiscoveryPtr& event)
 {
        LogDebug("Enter");
-       
+       bool state = false;
        try 
        {
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
+               }
+
+               if (bt_adapter_is_discovering(&state) !=  BT_ERROR_NONE)
+               {
+                       ThrowMsg(Commons::PlatformException, "device discovery stop fail");
+               }
+
+               if (state == false)
+               {
+                       ThrowMsg(Commons::PlatformException, "device discovery stop fail");
                }
 
                if (bt_adapter_stop_device_discovery() != BT_ERROR_NONE)                
@@ -1036,7 +1114,7 @@ void BluetoothAdapterManager::OnRequestReceived(const EventBTRegisterRFCOMMPtr&
                
                if (m_btPowered == false)       
                {
-                       ThrowMsg(Commons::UnsupportedException, "bluetooth adpater off");
+                       ThrowMsg(Commons::AlreadyInUseException, "bluetooth adpater off");
                }
 
                if (getVisibility() == false)
index 49b730c..3bdafb1 100644 (file)
@@ -44,6 +44,7 @@ public:
        virtual void getKownDevices(const EventBTGetKnownDevicesPtr& event) ;
        virtual void getDevice(const EventBTGetDevicePtr& event) ;
        virtual void createBonding(const EventBTCreateDestroyBondingPtr& event) ;
+       virtual bool createBondingCancel();
        virtual void destroyBonding(const EventBTCreateDestroyBondingPtr& event) ;
        virtual void registerRFCOMMServiceByUUID(const EventBTRegisterRFCOMMPtr& event);
        virtual void discoveryDevicesEmitter(const EventBTOnDiscoveryDevicesEmitterPtr& emitter);
@@ -60,12 +61,12 @@ public:
        void Test();
        bool canUseBluetooth();
        void setPoweredManualAnswer();
-       void createBondingManualAnswer(unsigned short error, bt_device_info_s *device_info);
-       void destroyBondingManualAnswer(unsigned short error);
+       void createBondingManualAnswer(int error, bt_device_info_s *device_info);
+       void destroyBondingManualAnswer(int error);
        void getKnownDevicesManualAnswer(bt_device_info_s *discovery_info);
-       void serviceSearchManualAnswer(unsigned short error);
+       void serviceSearchManualAnswer(int error);
        bool getDeviceManualAnswer(bt_device_info_s *device_info);
-       void discoveryDevicesCallbackEmit(unsigned short error, unsigned short state, bt_adapter_device_discovery_info_s *discovery_info);
+       void discoveryDevicesCallbackEmit(int error, unsigned short state, bt_adapter_device_discovery_info_s *discovery_info);
        void updateDevice(BluetoothDeviceData &device);
        int findDevice(std::string address, BluetoothDeviceData &device);
        void setAdapterNameManualAnswer(char* deviceName);
index 8ec6e21..f0e3b72 100644 (file)
@@ -34,6 +34,8 @@ BluetoothDeviceManager::BluetoothDeviceManager()
 
 BluetoothDeviceManager::~BluetoothDeviceManager() 
 {
+       bt_device_unset_service_searched_cb();
+       bt_socket_unset_connection_state_changed_cb();
 }
 
 namespace {
@@ -78,7 +80,15 @@ bool BluetoothDeviceManager::deviceFoundAnswer(bt_device_info_s *device_info)
                LogDebug("Minor Class:" << device_info->bt_class.minor_device_class);           
                
                m_remoteDevice.address = device_info->remote_address;
-               m_remoteDevice.name = device_info->remote_name;
+
+               if (device_info->remote_name == NULL)
+               {
+                       m_remoteDevice.name = "";
+               }
+               else 
+               {
+                       m_remoteDevice.name = device_info->remote_name;
+               }
 
                m_remoteDevice.btClass.major = device_info->bt_class.major_device_class;
                m_remoteDevice.btClass.minor = device_info->bt_class.minor_device_class;
index 0b20609..c437fcf 100644 (file)
@@ -64,7 +64,7 @@ void BluetoothServiceHandlerManager::connectionStateChangedEmit(int result,
                socketdata.protocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
                socketdata.state = SOCKET_STATE_OPEN_VALUE_INT;
                socketdata.connectedSocket = connection->socket_fd;
-               socketdata.registeredSocket = connection->socket_fd;
+               socketdata.registeredSocket = m_registerSocket;
                socketdata.peerDevice.address = connection->remote_address;
                socketdata.peerDevice.isConnected = true;
                m_Connected = true;
index 6491686..a077a01 100644 (file)
@@ -36,6 +36,8 @@ BluetoothSocketManager::BluetoothSocketManager()
 BluetoothSocketManager::~BluetoothSocketManager() 
 {
        LogDebug("Enter");
+       bt_socket_unset_connection_state_changed_cb();
+       bt_socket_unset_data_received_cb();     
 }
 
 
@@ -63,9 +65,9 @@ void BluetoothSocketManager::setReadData(EventBTReadDataType readData)
 
 void BluetoothSocketManager::setDataReceivedEmit(bt_socket_received_data_s *data)
 {
-       assert(m_socketData.connectedSocket == data->socket_fd);
+/*     assert(m_socketData.connectedSocket == data->socket_fd);
        assert(data->data != NULL);
-       assert(data->data_size != 0);
+       assert(data->data_size != 0);*/
 
 
        LogDebug("OK" << data->data[0] << data->data[1] << " :" << data->data_size);
@@ -82,8 +84,8 @@ void BluetoothSocketManager::setDataReceivedEmit(bt_socket_received_data_s *data
 void BluetoothSocketManager::connectionStateChangedEmit(int result, 
        bt_socket_connection_state_e connection_state,  bt_socket_connection_s *connection)
 {
-       assert(m_socketData.connectedSocket == connection->socket_fd);
-       assert(strcmp(m_socketData.peerDevice.address.data(), connection->remote_address) == 0);
+/*     assert(m_socketData.connectedSocket == connection->socket_fd);
+       assert(strcmp(m_socketData.peerDevice.address.data(), connection->remote_address) == 0);*/
 
        LogDebug("OK");
        
index b72c676..35e9edd 100755 (executable)
@@ -23,9 +23,6 @@
 #include "CalendarQuery.h"
 #include "CalendarFilter.h"
 #include "CalendarFilterValidator.h"
-#include "API/Calendar/OnAddEventsChanged.h"
-#include "API/Calendar/OnUpdateEventsChanged.h"
-#include "API/Calendar/OnDeleteEventsChanged.h"
 #include "API/Calendar/OnEventsChanged.h"
 #include "API/Calendar/IEventWatchChanges.h"
 #include "API/Calendar/IEventClearWatch.h"
@@ -66,11 +63,6 @@ void Calendar::OnRequestReceived(const IEventAddEventPtr &event)
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvent(), getType()));
         event->getEvent()->setCalendarType(getType());
         eventWrapper->convertAbstractEventToPlatformEvent();
-        if (event->checkCancelled()) {
-            event->setCancelAllowed(true);
-            event->setResult(true);
-            return;
-        }
 
         // Set the account and calendar id before saving the item.
         eventWrapper->setCalendarId(getId());
@@ -78,18 +70,18 @@ void Calendar::OnRequestReceived(const IEventAddEventPtr &event)
         eventWrapper->saveEvent();
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during adding event" << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
 }
 
 void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
 {
     LogDebug("entered");
+
     Try
     {
         if (events->getEvents()->empty()) {
@@ -100,6 +92,12 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
         bool failedAdding = false;
         for(unsigned int i=0; i<events->getEvents()->size(); i++)
         {
+            if (events->checkCancelled()) {
+                events->setCancelAllowed(true);
+                events->setResult(true);
+                return;
+            }
+
             if (events->getEvents()->at(i)->getIdIsSet()) {
                 LogWarning("adding event that is already added: index " << i);
                 events->getEvents()->at(i)->resetId();
@@ -107,19 +105,14 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
             DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(events->getEvents()->at(i), getType()));
             events->getEvents()->at(i)->setCalendarType(getType());
             eventWrapper->convertAbstractEventToPlatformEvent();
-            if (events->checkCancelled()) {
-                events->setCancelAllowed(true);
-                events->setResult(true);
-                return;
-            }
 
-            try {
+            Try {
                 // Set the account and calendar id before saving the item.
                 eventWrapper->setCalendarId(getId());
                 eventWrapper->setCalendarAccountId(getAccountId());
                 eventWrapper->saveEvent();
-            } catch (const Exception &saveException) {
-                LogInfo("Error during saving an event " << saveException.DumpToString());
+            } Catch (Exception) {
+                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
                 failedAdding = true;
             }
             //getAddEmitter()->emit(eventPtr);
@@ -131,9 +124,9 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
             events->setResult(false);
         }
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during adding events" << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         events->setResult(false);
         events->setExceptionCode(ExceptionCodes::UnknownException);
     }
@@ -143,44 +136,101 @@ void Calendar::OnRequestReceived(const IEventAddEventsPtr &events)
 void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
 {
     LogDebug("entered");
+
+    cal_iter *iter = NULL;
     Try
     {
         if (!event->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
+            ThrowMsg(NullPointerException, "Item object is NULL.");
         }
         if (!event->getEvent()->getIdIsSet()) {
-            ThrowMsg(
-                InvalidArgumentException,
-                "Cannot update non-existing event. Event needs adding or ID is wrong");
+            ThrowMsg(InvalidArgumentException, "Item id is not set.");
         }
+
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvent(), getType()));
         event->getEvent()->setCalendarType(getType());
         eventWrapper->convertAbstractEventToPlatformEvent();
-        if (event->checkCancelled()) {
-            event->setCancelAllowed(true);
-            event->setResult(true);
-            return;
-        }
 
-        if ( event->getUpdateAllInstances() || NULL==event->getEvent()->getRecurrenceRule())
+        if ( event->getUpdateAllInstances() || 0>=event->getEvent()->getRecurrenceRule()->getFrequency())
         {
-            // Set the account and calendar id before saving the item.
-            eventWrapper->setCalendarId(getId());
-            eventWrapper->setCalendarAccountId(getAccountId());
+            // Update all parent and child instances with the given uid.
+            int parentId = event->getEvent()->getId();
+
+            // First, the parent event.
             eventWrapper->saveEvent();
+
+            // Next, all the detached instances.
+            cal_struct *platformEvent = NULL;
+            if(CAL_SUCCESS != calendar_svc_find_event_list(getAccountId(), CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
+                LogInfo("No detached instances found.");
+            }
+
+            while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+                platformEvent = NULL;
+                if (CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent)) {
+                    ThrowMsg(PlatformException, "Can't get event info.");
+                }
+
+                int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
+                std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent,
+                                                                            CAL_VALUE_GMT_START_DATE_TIME,
+                                                                            CAL_TZ_FLAG_GMT);
+                std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent,
+                                                                            CAL_VALUE_GMT_END_DATE_TIME,
+                                                                            CAL_TZ_FLAG_GMT);
+
+                DPL::ScopedPtr<EventWrapper> eventWrapperChild(new EventWrapper(event->getEvent(), getType()));
+                eventWrapperChild->convertAbstractEventToPlatformEvent();
+                if (CAL_SUCCESS != calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
+                                                               CAL_VALUE_INT_INDEX,
+                                                               detachedEventId)) {
+                    ThrowMsg(PlatformException, "Can't set event Id.");
+                }
+                if (CAL_SUCCESS != calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
+                                                               CAL_VALUE_INT_ORIGINAL_EVENT_ID,
+                                                               parentId)) {
+                    ThrowMsg(PlatformException, "Can't set parent Id.");
+                }
+                if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                                                               CAL_VALUE_GMT_START_DATE_TIME,
+                                                               CAL_TZ_FLAG_GMT,
+                                                               detachedStartTime)) {
+                    ThrowMsg(PlatformException, "Can't set start time.");
+                }
+                if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                                                               CAL_VALUE_GMT_END_DATE_TIME,
+                                                               CAL_TZ_FLAG_GMT,
+                                                               detachedEndTime)) {
+                    ThrowMsg(PlatformException, "Can't set end time.");
+                }
+                if (CAL_SUCCESS != calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
+                                                               CAL_VALUE_INT_REPEAT_TERM,
+                                                               CAL_REPEAT_NONE)) {
+                    ThrowMsg(PlatformException, "Can't set repeat term.");
+                }
+
+                eventWrapperChild->saveEvent();
+                LogDebug("Updated a detached event by id: "<<detachedEventId);
+            }
         }
         else
         {
             LogDebug("Update the exception record");
             DPL::ScopedPtr<EventWrapper> eventWrapperChild(new EventWrapper(event->getEvent(), getType()));
             eventWrapperChild->convertAbstractEventToPlatformEvent();
-
             if ( CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
                 CAL_VALUE_INT_ORIGINAL_EVENT_ID, event->getEvent()->getId()) ) {
                 ThrowMsg(PlatformException, "cannot save exception event");
+            } 
+            // Use "CAL_VALUE_GMT_COMPLETED_DATE_TIME" as the recurrence id saving point.
+            if ( CAL_SUCCESS!=calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT, event->getEvent()->getRecurrenceId()) ) {
+                ThrowMsg(PlatformException, "cannot save recurrence id");
+            } else {
+                LogInfo("Saved the rid for the child: "<<event->getEvent()->getRecurrenceId());
             }
             if (CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
-                CAL_VALUE_INT_REPEAT_TERM,0) ) {
+                CAL_VALUE_INT_REPEAT_TERM, CAL_REPEAT_NONE) ) {
                 ThrowMsg(PlatformException, "cannot save exception event");
             }
             int childId = calendar_svc_insert(eventWrapperChild->getPlatformEvent());
@@ -190,11 +240,15 @@ void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
 
             GList* list = NULL;
             cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
-            if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, event->getEvent()->getStartTime()) ) {
-                ThrowMsg(PlatformException, "cannot save the exception parent event");
+            if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, event->getEvent()->getRecurrenceId()) ) {
+                ThrowMsg(PlatformException, "cannot save the exception date");
+            } else {
+                LogInfo("Saved the exception date: "<<event->getEvent()->getRecurrenceId());
             }
             if (CAL_SUCCESS!=calendar_svc_value_set_int(value,  CAL_VALUE_INT_EXCEPTION_DATE_ID, childId)) {
                 ThrowMsg(PlatformException, "cannot save the exception parent event");
+            } else {
+                LogInfo("Saved the exception id: "<<childId);
             }
             eventWrapper->loadEvent(event->getEvent()->getId());
             calendar_svc_struct_get_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, &list);
@@ -209,49 +263,99 @@ void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
 
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during updating event " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
+
+    if(iter) {
+        calendar_svc_iter_remove(&iter);
+    }
 }
 
 void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
 {
     LogDebug("entered");
+
+    cal_iter *iter = NULL;
     Try
     {
         if (events->getEvents()->empty()) {
-            ThrowMsg(NullPointerException, "event vector parameter is empty");
+            ThrowMsg(NullPointerException, "Item vector is empty.");
         }
 
         // Update the vector of events iteratively
         bool failedUpdating = false;
         for(unsigned int i=0; i<events->getEvents()->size(); i++)
         {
+            if (events->checkCancelled()) {
+                events->setCancelAllowed(true);
+                events->setResult(true);
+                return;
+            }
+
             CalendarEventPtr thisEvent = events->getEvents()->at(i);
             if (!thisEvent->getIdIsSet()) {
-                ThrowMsg(InvalidArgumentException,
-                    "Cannot update non-existing event. Event needs adding or ID is wrong");
+                ThrowMsg(InvalidArgumentException, "Item id is not set.");
             }
             DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(thisEvent, getType()));
             events->getEvents()->at(i)->setCalendarType(getType());
             eventWrapper->convertAbstractEventToPlatformEvent();
-            if (events->checkCancelled()) {
-                events->setCancelAllowed(true);
-                events->setResult(true);
-                return;
-            }
 
             try {
-                if (events->getUpdateAllInstances() || NULL==thisEvent->getRecurrenceRule())
+                if (events->getUpdateAllInstances() || 0>=thisEvent->getRecurrenceRule()->getFrequency())
                 {
-                    // Set the account and calendar id before saving the item.
-                    eventWrapper->setCalendarId(getId());
-                    eventWrapper->setCalendarAccountId(getAccountId());
+                    // Update all parent and child instances with the given uid.
+                    int parentId = thisEvent->getId();
+
+                    // First, the parent event.
                     eventWrapper->saveEvent();
+                    
+                    // Next, all the detached instances.
+                    cal_struct *platformEvent = NULL;
+                    if(CAL_SUCCESS != calendar_svc_find_event_list(getAccountId(), CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
+                        LogInfo("No detached instances found.");
+                    }
+
+                    while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+                        platformEvent = NULL;
+                        if (CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent)) {
+                            ThrowMsg(PlatformException, "Can't get event info.");
+                        }
+
+                        int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
+                        std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent,
+                                                                                    CAL_VALUE_GMT_START_DATE_TIME,
+                                                                                    CAL_TZ_FLAG_GMT);
+                        std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent,
+                                                                                    CAL_VALUE_GMT_END_DATE_TIME,
+                                                                                    CAL_TZ_FLAG_GMT);
+
+                        DPL::ScopedPtr<EventWrapper> eventWrapperChild(new EventWrapper(thisEvent, getType()));
+                        eventWrapperChild->convertAbstractEventToPlatformEvent();
+                        if (CAL_SUCCESS != calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
+                                                                       CAL_VALUE_INT_INDEX,
+                                                                       detachedEventId)) {
+                            ThrowMsg(PlatformException, "Can't set event Id.");
+                        }
+                        if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                                                                       CAL_VALUE_GMT_START_DATE_TIME,
+                                                                       CAL_TZ_FLAG_GMT,
+                                                                       detachedStartTime)) {
+                            ThrowMsg(PlatformException, "Can't set start time.");
+                        }
+                        if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                                                                       CAL_VALUE_GMT_END_DATE_TIME,
+                                                                       CAL_TZ_FLAG_GMT,
+                                                                       detachedEndTime)) {
+                            ThrowMsg(PlatformException, "Can't set end time.");
+                        }
+
+                        eventWrapper->saveEvent();
+                        LogDebug("Updated a detached event by id: "<<detachedEventId);
+                    }
                 }
                 else
                 {
@@ -261,11 +365,18 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
 
                     if ( CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
                         CAL_VALUE_INT_ORIGINAL_EVENT_ID, thisEvent->getId()) ) {
-                        ThrowMsg(PlatformException, "cannot save exception event");
+                        ThrowMsg(PlatformException, "cannot save parent id.");
+                    }
+                    // Use "CAL_VALUE_GMT_COMPLETED_DATE_TIME" as the recurrence id saving point.
+                    if ( CAL_SUCCESS!=calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
+                        CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT, thisEvent->getRecurrenceId()) ) {
+                        ThrowMsg(PlatformException, "cannot save recurrence id.");
+                    } else {
+                        LogInfo("Saved the rid for the child: "<<thisEvent->getRecurrenceId());
                     }
                     if (CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
-                        CAL_VALUE_INT_REPEAT_TERM,0) ) {
-                        ThrowMsg(PlatformException, "cannot save exception event");
+                        CAL_VALUE_INT_REPEAT_TERM, CAL_REPEAT_NONE) ) {
+                        ThrowMsg(PlatformException, "cannot save repeat term.");
                     }
                     int childId = calendar_svc_insert(eventWrapperChild->getPlatformEvent());
                     if ( childId<0 ) {
@@ -274,11 +385,15 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
 
                     GList* list = NULL;
                     cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
-                    if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, thisEvent->getStartTime()) ) {
+                    if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, thisEvent->getRecurrenceId()) ) {
                         ThrowMsg(PlatformException, "cannot save the exception parent event");
+                    } else {
+                        LogInfo("Saved the exception date: "<<thisEvent->getRecurrenceId());
                     }
                     if (CAL_SUCCESS!=calendar_svc_value_set_int(value,  CAL_VALUE_INT_EXCEPTION_DATE_ID, childId)) {
                         ThrowMsg(PlatformException, "cannot save the exception parent event");
+                    } else {
+                        LogInfo("Saved the exception id: "<<childId);
                     }
                     calendar_svc_struct_get_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, &list);
                     list = g_list_append(list, value);
@@ -289,8 +404,8 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
 
                     thisEvent->setIsDetached(true);
                 }
-            } catch (const Exception &updateException) {
-                LogInfo("Error during updating an event " << updateException.DumpToString());
+            } Catch (Exception) {
+                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
                 failedUpdating = true;
             }
             //getUpdateEmitter()->emit(eventPtr);
@@ -302,12 +417,16 @@ void Calendar::OnRequestReceived(const IEventUpdateEventsPtr &events)
             events->setResult(false);
         }
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during updating events " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         events->setResult(false);
         events->setExceptionCode(ExceptionCodes::UnknownException);
     }
+
+    if(iter) {
+        calendar_svc_iter_remove(&iter);
+    }
     events->setCancelAllowed(false);
 }
 
@@ -317,7 +436,7 @@ void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event)
     Try
     {
         if (!event->getEventId()) {
-            ThrowMsg(NullPointerException, "event Id parameter is NULL");
+            ThrowMsg(NullPointerException, "Item id is not set.");
         }
 
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(getType()));
@@ -325,33 +444,34 @@ void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event)
         std::istringstream stream(event->getEventId()->getUId());
         int id = -1;
         stream>>id;
-        //eventWrapper->getAbstractEvent()->setId(id);
-        eventWrapper->loadEvent(id);
-        LogDebug("event->getEventId()->getRecurrenceId() : " << event->getEventId()->getRecurrenceId());
-        eventWrapper->getAbstractEvent()->setRecurrenceId(event->getEventId()->getRecurrenceId());
+        eventWrapper->getAbstractEvent()->setId(id);
 
-        if (event->checkCancelled()) {
-            event->setCancelAllowed(true);
-            event->setResult(true);
-            return;
-        }
+        std::stringstream ss(event->getEventId()->getRecurrenceId());
+        std::time_t rid;
+        ss>>rid;
+        eventWrapper->getAbstractEvent()->setRecurrenceId(rid);
+
+        LogDebug("id: " << id << ", rid: " << rid);
+
+        eventWrapper->convertAbstractEventToPlatformEvent();
 
+        eventWrapper->setCalendarId(getId());
+        eventWrapper->setCalendarAccountId(getAccountId());
         eventWrapper->deleteEvent();
         event->setResult(true);
     }
-    catch (const NotFoundException &ex)
+    Catch (NotFoundException)
     {
-        LogError("event doesn't exist");
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::NotFoundException);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during deleting event " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
 }
 
 void Calendar::OnRequestReceived(const IEventGetPtr &event)
@@ -364,29 +484,26 @@ void Calendar::OnRequestReceived(const IEventGetPtr &event)
         }
 
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(getType()));
-        event->getItemId()->setCalendarType(getType());
         std::stringstream ss(event->getItemId()->getUId());
         int id = -1;
         ss>>id;
         eventWrapper->loadEvent(id);
 
         event->setItem(eventWrapper->convertPlatformEventToAbstractEvent());
-        event->getItem()->setCalendarType(getType());
         event->setResult(true);
     }
-    catch (const NotFoundException &ex)
+    Catch (NotFoundException)
     {
-        LogError("Item doesn't exist");
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::NotFoundException);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during getting an item " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
 }
 
 void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
@@ -405,25 +522,26 @@ void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
             DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(getType()));
             events->getEventIds()->at(i)->setCalendarType(getType());
             std::istringstream stream(events->getEventIds()->at(i)->getUId());
-            int id;
+            int id = -1;
             stream>>id;
             eventWrapper->getAbstractEvent()->setId(id);
-            eventWrapper->getAbstractEvent()->setRecurrenceId(events->getEventIds()->at(i)->getRecurrenceId());
+
+            std::stringstream ss(events->getEventIds()->at(i)->getRecurrenceId());
+            std::time_t rid;
+            ss>>rid;
+            eventWrapper->getAbstractEvent()->setRecurrenceId(rid);
             eventWrapper->convertAbstractEventToPlatformEvent();
-            if (events->checkCancelled()) {
-                events->setCancelAllowed(true);
-                events->setResult(true);
-                return;
-            }
 
-            try {
+            Try {
+                eventWrapper->setCalendarId(getId());
+                eventWrapper->setCalendarAccountId(getAccountId());
                 eventWrapper->deleteEvent();
-            } catch (const NotFoundException &ex) {
-                LogInfo("Event not found during deleting an event.");
+            } Catch (NotFoundException) {
+                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
                 events->setExceptionCode(ExceptionCodes::NotFoundException);
                 failedDeleting = true;
-            } catch (const Exception &ex) {
-                LogInfo("Exception occurred during deleting an event.");
+            } Catch (Exception) {
+                LogWarning("Exception: "<<_rethrown_exception.GetMessage());
                 events->setExceptionCode(ExceptionCodes::PlatformException);
                 failedDeleting = true;
             }
@@ -436,310 +554,113 @@ void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
             events->setResult(false);
         }
     }
-    catch (const NotFoundException &ex)
+    Catch (NotFoundException)
     {
-        LogError("event doesn't exist");
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         events->setResult(false);
         events->setExceptionCode(ExceptionCodes::NotFoundException);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during deleting event " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         events->setResult(false);
         events->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    events->setCancelAllowed(false);
 }
 
 void Calendar::OnRequestReceived(const IEventFindEventsPtr &event)
 {
     LogDebug("entered");
-    bool useGenericFilter = true;
     event->setResult(true);
 
-    // Tizen Generic filter
-    if ( useGenericFilter )
+    Try
     {
-        try
-        {
-            _db_init();
-
-            CalendarFilterPtr calendarFilter( new CalendarFilter() );
-
-            // Set the attributesOfInterest here if needed.
-            //std::string query ("SELECT " + calendarFilter.concatenateFilterAttributes() + " FROM schedule_table");
-            std::string query (std::string("SELECT ") + CAL_VALUE_INT_INDEX + " FROM schedule_table");
-            LogInfo("Default query statement: "<<query);
-
-               TizenApis::Api::Tizen::IFilterVisitorPtr filterTraversal = DPL::StaticPointerCast<TizenApis::Api::Tizen::IFilterVisitor>(calendarFilter);
+        calendar_db_init();
 
-            std::stringstream ssType;
-            std::stringstream ssAccount;
-            ssAccount<<getAccountId();
-               if (event->getGenericFilterIsSet()) {
-                TizenApis::Api::Tizen::FilterPtr genericFilter = event->getGenericFilter();
+        CalendarFilterPtr calendarFilter( new CalendarFilter() );
 
-                TizenApis::Api::Tizen::FilterValidatorPtr validator = CalendarFilterValidatorFactory::getCalendarFilterValidator();
-                bool success = genericFilter->validate(validator);
-                if(!success) {
-                    ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-                } else {
-                    LogInfo("Filter validation has passed.");
-                }
-
-                       genericFilter->travel(filterTraversal, 0);
-                       LogDebug("Traverse string [" << calendarFilter->getResult() << "]");
-                       query.append(calendarFilter->getResult());
-                query.append(std::string(" AND ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
-                if (getType()==CalendarEvent::TASK_TYPE) {
-                    ssType<<CALS_CALENDAR_TYPE_TODO;
-                    query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0;");
-                } else {
-                    ssType<<CALS_CALENDAR_TYPE_EVENT;
-                    query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0;");
-                }
-               } else {
-                query.append(std::string(" WHERE ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
-                if (getType()==CalendarEvent::TASK_TYPE) {
-                    ssType<<CALS_CALENDAR_TYPE_TODO;
-                    query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0;");
-                } else {
-                    ssType<<CALS_CALENDAR_TYPE_EVENT;
-                    query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0;");
-                }
-               }
-
-               if (event->getSortModesIsSet()) {
-                       query.append(calendarFilter->makeQuerySortMode(event->getSortModes()));
-               }
-
-               LogDebug("Filter query [" << query << "]");
+        std::string query (std::string("SELECT ") + CAL_VALUE_INT_INDEX + " FROM schedule_table");
+        LogInfo("Default query statement: "<<query);
 
-               calendarFilter->executeQuery(query, event->getEvents());
+               TizenApis::Api::Tizen::IFilterVisitorPtr filterTraversal = DPL::StaticPointerCast<TizenApis::Api::Tizen::IFilterVisitor>(calendarFilter);
 
-            LogDebug("Result count [" << event->getEvents()->size() << "]");
+        std::stringstream ssType;
+        std::stringstream ssAccount;
+        ssAccount<<getAccountId();
+               if (event->getGenericFilterIsSet()) {
+            TizenApis::Api::Tizen::FilterPtr genericFilter = event->getGenericFilter();
 
-            _db_finish();
-
-            // Now load the full calendar item using the retrieved id.
-            for( unsigned int i=0; i<event->getEvents()->size(); i++) {
-                // platformEvent is freed when the wrapper destructor is called.
-                DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvents()->at(i), getType()));
-                eventWrapper->loadEvent(event->getEvents()->at(i)->getId());
+            TizenApis::Api::Tizen::FilterValidatorPtr validator = CalendarFilterValidatorFactory::getCalendarFilterValidator();
+            bool success = genericFilter->validate(validator);
+            if(!success) {
+                ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
+            } else {
+                LogInfo("Filter validation has passed.");
             }
-        }
-        catch (const InvalidArgumentException &ex)
-        {
-            LogError("Exception: " << ex.DumpToString());
-            event->setResult(false);
-            event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
-        }
-        catch (const NotFoundException &ex)
-        {
-            LogError("Exception: " << ex.DumpToString());
-            event->setResult(false);
-            event->setExceptionCode(ExceptionCodes::NotFoundException);
-        }
-        catch (const Exception &ex)
-        {
-            LogError("Exception: " << ex.DumpToString());
-            event->setResult(false);
-            event->setExceptionCode(ExceptionCodes::UnknownException);
-        }
-    }
-    // WAC style filter
-    else
-    {
-        cal_iter *iter = NULL;
-        try
-        {
-            const EventFilterPtr filter = event->getFilter();
-            cal_struct *platformEvent = NULL;
-            bool isStartDateSet = false;
-
-            if (NULL==filter)
-            {
-                LogInfo("Filter is not set.");
-                const char *dataType;
-                if(getType() == CalendarEvent::TASK_TYPE) {
-                    dataType = CAL_STRUCT_TODO;
-                } else {
-                    dataType = CAL_STRUCT_SCHEDULE;
-                }
 
-                std::istringstream stream(getId());
-                int calendarId = -1;
-                stream>>calendarId;
-                if (CAL_SUCCESS != calendar_svc_get_all(getAccountId(), calendarId, dataType, &iter)) {
-                        ThrowMsg(PlatformException, "Can't get all records");
-                }
+                       genericFilter->travel(filterTraversal, 0);
+                       LogDebug("Traverse string [" << calendarFilter->getResult() << "]");
+                       query.append(calendarFilter->getResult());
+            query.append(std::string(" AND ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
+            if (getType()==CalendarEvent::TASK_TYPE) {
+                ssType<<CALS_CALENDAR_TYPE_TODO;
+                query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+            } else {
+                ssType<<CALS_CALENDAR_TYPE_EVENT;
+                query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
             }
-            else
-            // Use the new calendar service search function with multiple type/value pairs.
-            {
-                int filterCount = 0;
-                const char *searchType[9];
-                const void *searchValue[9];
-
-                if(filter->getIdIsSet()) {
-                    // Platform supports integer type db index only.
-                    std::istringstream istream(filter->getIdFilter());
-                    int id;
-                    istream>>id;
-                    searchType[filterCount] = CAL_VALUE_INT_INDEX;
-                    searchValue[filterCount++] = (void*)(id);
-                }
-                if(filter->getSubjectIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_TXT_SUMMARY;
-                    searchValue[filterCount++] = (void*)(filter->getSubjectFilter().c_str());
-                }
-                if(filter->getDescriptionIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_TXT_DESCRIPTION;
-                    searchValue[filterCount++] = (void*)(filter->getDescriptionFilter().c_str());
-                }
-                if(filter->getLocationIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_TXT_LOCATION;
-                    searchValue[filterCount++] = (void*)(filter->getLocationFilter().c_str());
-                }
-                if(filter->getCategoryIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_TXT_MEETING_CATEGORY_DETAIL_NAME;
-                    searchValue[filterCount++] = (void*)(filter->getCategoryFilter().c_str());
-                }
-                if(filter->getStatusIsSet()) {
-                    std::stringstream ss;
-                    std::string status;
-                    for( unsigned int i=0; i<filter->getStatusFilter().size(); i++ ) {
-                        cal_status_type_t statusValue = CAL_STATUS_CONFIRM;
-                        switch(filter->getStatusFilter().at(i)) {
-                        case CalendarEvent::TENTATIVE_STATUS:
-                            statusValue = CAL_STATUS_TENTATIVE;
-                            break;
-                        case CalendarEvent::CANCELLED_STATUS:
-                            statusValue = CAL_STATUS_DENIED;
-                            break;
-                        case CalendarEvent::CONFIRMED_STATUS:
-                        default:
-                            statusValue = CAL_STATUS_CONFIRM;
-                            break;
-                        }
-                        ss<<statusValue;
-                    }
-                    searchType[filterCount] = CAL_VALUE_INT_MEETING_STATUS;
-                    status = ss.str();
-                    searchValue[filterCount++] = (void*)(status.c_str());
-                    LogInfo("status filter "<<status.c_str());
-                }
-                if(filter->getStartTimeMinIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_GMT_START_DATE_TIME;
-                    searchValue[filterCount++] = (void*)(filter->getStartTimeMinFilter());
-                    isStartDateSet = true;
-                }
-                if(filter->getStartTimeMaxIsSet()) {
-                    searchType[filterCount] = CAL_VALUE_GMT_END_DATE_TIME;
-                    searchValue[filterCount++] = (void*)(filter->getStartTimeMaxFilter());
-                    isStartDateSet = true;
-                }
-                LogInfo("Filter is set: "<<filterCount);
-
-                if(CAL_SUCCESS !=
-                    calendar_svc_find_event_list_by_filter(0, filterCount, searchType, searchValue, &iter)) {
-                    ThrowMsg(NotFoundException, "Can't find event list by filter.");
-                }
+               } else {
+            query.append(std::string(" WHERE ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
+            if (getType()==CalendarEvent::TASK_TYPE) {
+                ssType<<CALS_CALENDAR_TYPE_TODO;
+                query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+            } else {
+                ssType<<CALS_CALENDAR_TYPE_EVENT;
+                query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
             }
+               }
 
-            while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
-                event->tryCancelled();
+               if (event->getSortModesIsSet()) {
+                       query.append(calendarFilter->makeQuerySortMode(event->getSortModes()));
+                       query.append(std::string(";"));
+               }
 
-                platformEvent = NULL;
-                if (CAL_SUCCESS !=
-                    calendar_svc_iter_get_info(iter, &platformEvent)) {
-                    ThrowMsg(PlatformException, "Can't get event info.");
-                }
+               LogDebug("Filter query [" << query << "]");
 
-                // platformEvent is freed when the wrapper destructor is called.
-                DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(platformEvent, getType()));
+               calendarFilter->executeQuery(query, event->getEvents());
 
-                eventWrapper->convertPlatformEventToAbstractEvent()->setCalendarType(getType());
-                event->addEvent(eventWrapper->getAbstractEvent());
-            }
+        LogDebug("Result count [" << event->getEvents()->size() << "]");
 
-            // Process the recurring event cases here.
-            if ( isStartDateSet ) {
-                LogInfo("Process the recurring evets");
-                if(CAL_SUCCESS !=
-                    calendar_svc_find_recurring_event_list(0, &iter)) {
-                    ThrowMsg(PlatformException, "Can't find recurring event list.");
-                }
+        calendar_db_finish();
 
-                time_t startTime, endTime, nextStartTime, nextEndTime;
-                if (filter->getStartTimeMinIsSet()) {
-                    startTime = filter->getStartTimeMinFilter();
-                } else {
-                    startTime = 0;
-                }
-                if (filter->getStartTimeMaxIsSet()) {
-                    endTime = filter->getStartTimeMaxFilter();
-                } else {
-                    endTime = INT_MAX; // about 60 years in 4 bytes system.
-                }
-
-                while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
-                    event->tryCancelled();
-
-                    nextStartTime = 0; // It's important to reset this before calling calendar_svc_util_next_valid_event.
-                    nextEndTime = 0;
-                    platformEvent = NULL;
-                    if (CAL_SUCCESS !=
-                        calendar_svc_iter_get_info(iter, &platformEvent)) {
-                        ThrowMsg(PlatformException, "Can't get event info.");
-                    }
+        // Now load the full calendar item using the retrieved id.
+        for( unsigned int i=0; i<event->getEvents()->size(); i++) {
+            // platformEvent is freed when the wrapper destructor is called.
+            DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvents()->at(i), getType()));
+            eventWrapper->loadEvent(event->getEvents()->at(i)->getId());
 
-                    if ( CAL_SUCCESS ==
-                        calendar_svc_util_next_valid_event(platformEvent, startTime, endTime, &nextStartTime, &nextEndTime) ) {
-                        bool isDuplicated = false;
-                        for( unsigned int i=0; i<event->getEvents()->size(); i++ ) {
-                            if (calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX)==event->getEvents()->at(i)->getId())
-                                isDuplicated = true;
-                        }
-                        if (!isDuplicated) {
-                            LogInfo("Found a recurring event inbetween the start time period.");
-                            DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(platformEvent, getType()));
-                            eventWrapper->convertPlatformEventToAbstractEvent()->setCalendarType(getType());
-                            event->addEvent(eventWrapper->getAbstractEvent());
-                        }
-                    }
-                }
+            // If it's a detached event, set the saved rid.
+            if (eventWrapper->getAbstractEvent()->getParentId()>0) {
+                LogInfo("Set the saved rid: "<<calendar_svc_struct_get_time(eventWrapper->getPlatformEvent(), CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT));
+                event->getEvents()->at(i)->setRecurrenceId(calendar_svc_struct_get_time(eventWrapper->getPlatformEvent(), CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT));
             }
         }
-        catch (const NotFoundException &ex)
-        {
-            LogError("Exception: " << ex.DumpToString());
-            event->setResult(false);
-            event->setExceptionCode(ExceptionCodes::NotFoundException);
-        }
-        catch (const Exception &ex)
-        {
-            LogError("Exception: " << ex.DumpToString());
-            event->setResult(false);
-            event->setExceptionCode(ExceptionCodes::UnknownException);
-        }
-
-        calendar_svc_iter_remove(&iter);
     }
-}
-
-void Calendar::OnRequestReceived(const IEventCreateEventPtr &event)
-{
-    LogDebug("entered");
-    Try
+    Catch (InvalidArgumentException)
     {
-        event->setEvent(CalendarEventPtr(new CalendarEvent()));
-        event->getEvent()->setCalendarType(getType());
-        event->setResult(event->getEvent().Get() != NULL);
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+    }
+    Catch (NotFoundException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::NotFoundException);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during creating an event " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
@@ -750,26 +671,26 @@ void Calendar::OnRequestReceived(const IEventCreateEventFromStringPtr &event)
     LogDebug("entered");
     Try
     {
-        if (event->checkCancelled()) {
-            event->setCancelAllowed(true);
-            event->setResult(true);
-            return;
-        }
-
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(getType()));
         eventWrapper->createEventFromString(event->getEventString());
         event->setEvent(eventWrapper->convertPlatformEventToAbstractEvent());
         event->getEvent()->setCalendarType(getType());
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch(PlatformException)
     {
-        LogError("Error during creating event from string" << ex.DumpToString());
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        LogInfo("eventString: " + event->getEventString());
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+    }
+    Catch (Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         LogInfo("eventString: " + event->getEventString());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
 }
 
 void Calendar::OnRequestReceived(const IEventExportEventToStringPtr &event)
@@ -781,25 +702,18 @@ void Calendar::OnRequestReceived(const IEventExportEventToStringPtr &event)
             ThrowMsg(NullPointerException, "event parameter is NULL");
         }
 
-        if (event->checkCancelled()) {
-            event->setCancelAllowed(true);
-            event->setResult(true);
-            return;
-        }
-
         DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvent(), getType()));
         event->getEvent()->setCalendarType(getType());
         eventWrapper->convertAbstractEventToPlatformEvent();
         event->setEventString(eventWrapper->exportEventToString());
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during creating string from event" << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(false);
 }
 
 static void eventChangedCb(void *user_data)
@@ -807,7 +721,7 @@ static void eventChangedCb(void *user_data)
     LogDebug("entered");
 
     OnEventsChangedPtr eventPtr(new OnEventsChanged());
-    try
+    Try
     {
         Calendar *thisCalendar = (Calendar*) user_data;
 
@@ -846,7 +760,11 @@ static void eventChangedCb(void *user_data)
             }
 
             DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(thisCalendar->getType()));
-            eventWrapper->loadEvent(index);
+            Try {
+                eventWrapper->loadEvent(index);
+            } Catch (NotFoundException){
+                LogDebug("Handling deleted event with index: "<<index);
+            }
             eventPtr->addEvent(eventWrapper->getAbstractEvent());
 
             if ( CAL_SUCCESS != calendar_svc_struct_free(&platformEvent) ) {
@@ -871,9 +789,9 @@ static void eventChangedCb(void *user_data)
             LogInfo("No actual changes. Skip signal emission.");
         }
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error while emitting the change noti" << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
     }
 }
 
@@ -899,9 +817,9 @@ void Calendar::OnRequestReceived(const IEventWatchChangesPtr &event)
         event->setWatchId(event->getEmitter()->getId());
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during creating a watch " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
@@ -923,9 +841,9 @@ void Calendar::OnRequestReceived(const IEventClearWatchPtr &event)
         }
         event->setResult(true);
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Error during clearing the watch " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
@@ -935,11 +853,11 @@ void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event)
 {
     LogDebug("entered");
     const CalendarEventPtr calEvent = event->getEvent();
-    const time_t startDate = event->getStartDate();
-    const time_t endDate = event->getEndDate();
+    const std::time_t startDate = event->getStartDate();
+    const std::time_t endDate = event->getEndDate();
     event->setResult(true);
 
-    try {
+    Try {
         if ( 0 >= calEvent->getRecurrenceRule()->getFrequency())
         {
             ThrowMsg(PlatformException, "This is not a recurring event.");
@@ -948,30 +866,67 @@ void Calendar::OnRequestReceived(const IEventExpandEventRecurrencePtr &event)
         std::time_t nextStartTime = 0;
         std::time_t nextEndTime = 0;
 
-        DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvent(), getType()));
-        eventWrapper->convertAbstractEventToPlatformEvent();
-
-        event->tryCancelled();
+        DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(CalendarEvent::EVENT_TYPE));
+        // We must load the event from the DB in order to get the auto-calculated repeat end time.
+        eventWrapper->loadEvent(event->getEvent()->getId());
+        //eventWrapper->displayPlatformEvent();
 
-        while ( CAL_SUCCESS ==
-            calendar_svc_util_next_valid_event(eventWrapper->getPlatformEvent(), startDate, endDate, &nextStartTime, &nextEndTime) ) {
-            LogInfo("Found a next vaild event: "<<nextStartTime);
+        while ( CAL_SUCCESS==calendar_svc_util_next_valid_event(eventWrapper->getPlatformEvent(), startDate, endDate, &nextStartTime, &nextEndTime) )
+        {
+            LogInfo("Found a next valid event: "<<nextStartTime);
             DPL::ScopedPtr<EventWrapper> recurringEventWrapper(new EventWrapper(getType()));
             recurringEventWrapper->loadEvent(calEvent->getId());
+
+            // Set distintive attributes of each instance.
             recurringEventWrapper->getAbstractEvent()->setRecurrenceId(nextStartTime);
+            recurringEventWrapper->getAbstractEvent()->setStartTime(nextStartTime);
+            recurringEventWrapper->getAbstractEvent()->setEndTime(nextEndTime);
+
             event->addExpandedEvent(recurringEventWrapper->getAbstractEvent());
         }
+        LogInfo("Length of expanded events from parent: "<<event->getExpandedEventList()->size());
+
+        // Consider the detached events also.
+        cal_iter *iter = NULL;
+        cal_struct *platformEvent = NULL;
+        int parentId = event->getEvent()->getId();
+        if(CAL_SUCCESS != calendar_svc_find_event_list(getAccountId(), CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
+            LogInfo("No detached instances found.");
+        }
 
-        LogInfo("Length of expanded events: "<<event->getExpandedEventList()->size());
+        while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+            platformEvent = NULL;
+            if (CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent)) {
+                ThrowMsg(PlatformException, "Can't get event info.");
+            }
+
+            int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
+            std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_GMT);
+            std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_GMT);
+            if (detachedStartTime>=startDate && detachedStartTime<=endDate) {
+                LogInfo("Found a valid detached event: "<<detachedStartTime);
+                DPL::ScopedPtr<EventWrapper> detachedEventWrapper(new EventWrapper(getType()));
+                detachedEventWrapper->loadEvent(detachedEventId);
+
+                // Set the same parent uid to each instances
+                detachedEventWrapper->getAbstractEvent()->setId(parentId);
+                // Set distintive attributes of each instance.
+                detachedEventWrapper->getAbstractEvent()->setRecurrenceId(detachedStartTime);
+                detachedEventWrapper->getAbstractEvent()->setStartTime(detachedStartTime);
+                detachedEventWrapper->getAbstractEvent()->setEndTime(detachedEndTime);
+
+                event->addExpandedEvent(detachedEventWrapper->getAbstractEvent());
+            }
+        }
+
+        LogInfo("Length of total expanded events: "<<event->getExpandedEventList()->size());
     }
-    catch (const Exception &ex)
+    Catch (Exception)
     {
-        LogError("Exception: " << ex.DumpToString());
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-
-    event->setCancelAllowed(true);
 }
 
 }
index 64c16e1..37f4e2b 100755 (executable)
@@ -40,7 +40,6 @@ class Calendar : public ICalendar
     virtual void OnRequestReceived(const IEventUpdateEventPtr &event);
     virtual void OnRequestReceived(const IEventUpdateEventsPtr &events);
     virtual void OnRequestReceived(const IEventFindEventsPtr &event);
-    virtual void OnRequestReceived(const IEventCreateEventPtr &event);
     virtual void OnRequestReceived(const IEventCreateEventFromStringPtr &event);
     virtual void OnRequestReceived(const IEventExportEventToStringPtr &event);
     virtual void OnRequestReceived(const IEventWatchChangesPtr &event);
index 3123eee..b8daf53 100755 (executable)
@@ -33,10 +33,11 @@ namespace Calendar {
 // The selected fields for the generic filter support.
 std::map<std::string, std::string> CalendarFilter::m_attributeMap = {
     {CALENDAR_FILTER_ATTRIBUTE_ID_UID,                              CAL_VALUE_INT_INDEX},
+    {CALENDAR_FILTER_ATTRIBUTE_ID,                              CAL_VALUE_INT_INDEX},
     {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,              CAL_VALUE_GMT_LAST_MODIFIED_TIME},
     {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,                     CAL_VALUE_TXT_DESCRIPTION},
     {CALENDAR_FILTER_ATTRIBUTE_SUMMARY,                         CAL_VALUE_TXT_SUMMARY},
-    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,                       CAL_VALUE_GMT_START_DATE_TIME},
+    {CALENDAR_FILTER_ATTRIBUTE_START_DATE,                      CAL_VALUE_GMT_START_DATE_TIME},
     {CALENDAR_FILTER_ATTRIBUTE_LOCATION,                        CAL_VALUE_TXT_LOCATION},
     {CALENDAR_FILTER_ATTRIBUTE_LATITUDE,                        CAL_VALUE_DBL_LATITUDE},
     {CALENDAR_FILTER_ATTRIBUTE_LONGITUDE,                       CAL_VALUE_DBL_LONGITUDE},
@@ -48,9 +49,9 @@ std::map<std::string, std::string> CalendarFilter::m_attributeMap = {
     {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,                      CAL_VALUE_LST_MEETING_CATEGORY}, // string array
     {CALENDAR_FILTER_ATTRIBUTE_PRIORITY,                        CAL_VALUE_INT_PRIORITY},
     {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,                        CAL_VALUE_GMT_END_DATE_TIME},
-    //{"completedDate",                   CAL_VALUE_GMT_COMPLETED_DATE_TIME}, // not yet supported in platform
-    //{"progress",                        CAL_VALUE_INT_PROGRESS}, // not yet supported in platform
-    //{"isDetached",                      CAL_VALUE_INT_PRIORITY}, // needs special manipulation
+    {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE,                                 CAL_VALUE_GMT_COMPLETED_DATE_TIME},
+    {CALENDAR_FILTER_ATTRIBUTE_PROGRESS,                                               CAL_VALUE_INT_PROGRESS},
+    {CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED,                      CAL_VALUE_INT_ORIGINAL_EVENT_ID},
     {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,                      CAL_VALUE_INT_ALL_DAY_EVENT},
     //{CALENDAR_FILTER_ATTRIBUTE_DURATION,                        CAL_VALUE_GMT_END_DATE_TIME}, // needs end date calculation
     //{"attendees",                       CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME}, // object array interface
@@ -109,6 +110,14 @@ void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen
                time << mktime(&date);
                valueString = time.str();
        }
+       else if(matchValue->isType(TizenApis::Api::Tizen::PrimitiveType_Boolean))
+       {
+               if (matchValue->getBool()) {
+                       valueString = std::string("1");
+               } else {
+                       valueString = std::string("0");
+               }
+       }
        else
        {
                valueString = matchValue->toString();
@@ -135,8 +144,15 @@ void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen
                matchString = " is not null";
        }
 
-       // If the attrName is not directly mapped, branch here.
-       conditionQuery.append(" (" + m_attributeMap[attrName] + matchString + ") ");
+       if (attrName=="isDetached") {
+               if (valueString=="1") {
+                       conditionQuery.append(" (" + m_attributeMap[attrName] + " > 0 )");
+               } else {
+                       conditionQuery.append(" (" + m_attributeMap[attrName] + " < 0 )");
+               }
+       } else {
+               conditionQuery.append(" (" + m_attributeMap[attrName] + matchString + ") ");
+       }
 
        LogInfo("Generated condition query: [" << conditionQuery << "]");
 
@@ -218,16 +234,16 @@ bool CalendarFilter::executeQuery(std::string &query, CalendarEventListPtr calen
        stmt hstmt = NULL;
        int ret = 0;
 
-       hstmt = _query_prepare((char *)(query.c_str()));
+       hstmt = calendar_query_prepare((char *)(query.c_str()));
     if( NULL==hstmt) {
         ThrowMsg(PlatformException, "Can't prepare query!");
     }
 
        do {
-               ret = _query_step(hstmt);
+               ret = calendar_query_step(hstmt);
                LogDebug("Query result : [" << ret << "]");
                if (ret == SQLITE_ROW) { // 100
-                       query_data.id = _query_column_int(hstmt, 0);
+                       query_data.id = calendar_query_column_int(hstmt, 0);
 
                        convertToCalendar(&query_data, calendarListPtr);
                } else if (ret == SQLITE_DONE) { // 101
@@ -239,7 +255,7 @@ bool CalendarFilter::executeQuery(std::string &query, CalendarEventListPtr calen
                }
        } while (1);
 
-       _query_finalize(hstmt);
+       calendar_query_finalize(hstmt);
 
        return true;
 }
index 346bf7b..6d938e7 100755 (executable)
@@ -33,7 +33,8 @@ namespace Platform {
 namespace Calendar {
 
 // List of attributes that can be used as the filter argument.
-#define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid"
+#define CALENDAR_FILTER_ATTRIBUTE_ID_UID "id.uid" // for event
+#define CALENDAR_FILTER_ATTRIBUTE_ID "id" // for task
 #define CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE "lastModificationDate"
 #define CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION "description"
 #define CALENDAR_FILTER_ATTRIBUTE_SUMMARY "summary"
@@ -51,9 +52,9 @@ namespace Calendar {
 #define CALENDAR_FILTER_ATTRIBUTE_CATEGORIES "categories"
 //#define CALENDAR_FILTER_ATTRIBUTE_ATTENDEES "attendees"
 #define CALENDAR_FILTER_ATTRIBUTE_DUE_DATE "dueDate"
-//#define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
+#define CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE "completedDate"
 #define CALENDAR_FILTER_ATTRIBUTE_PROGRESS "progress"
-//#define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
+#define CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED "isDetached"
 #define CALENDAR_FILTER_ATTRIBUTE_END_DATE "endDate"
 #define CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY "availability"
 //#define CALENDAR_FILTER_ATTRIBUTE_RECURRENCE_RULE "recurrenceRule"
index 730efce..268491b 100755 (executable)
@@ -27,6 +27,7 @@ using namespace TizenApis::Api::Tizen;
 static PropertyStructArray properties =
 {
     {CALENDAR_FILTER_ATTRIBUTE_ID_UID,              PrimitiveType_String},
+    {CALENDAR_FILTER_ATTRIBUTE_ID,                     PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_LAST_MODIFIED_DATE,  PrimitiveType_Time},
     {CALENDAR_FILTER_ATTRIBUTE_DESCRIPTION,         PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_SUMMARY,             PrimitiveType_String},
@@ -40,8 +41,11 @@ static PropertyStructArray properties =
     {CALENDAR_FILTER_ATTRIBUTE_CATEGORIES,          PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_PRIORITY,            PrimitiveType_String},
     {CALENDAR_FILTER_ATTRIBUTE_DUE_DATE,            PrimitiveType_Time},
+       {CALENDAR_FILTER_ATTRIBUTE_IS_DETACHED,                 PrimitiveType_Boolean},
     {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,          PrimitiveType_Boolean},
     {CALENDAR_FILTER_ATTRIBUTE_END_DATE,            PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_COMPLETED_DATE,      PrimitiveType_Time},
+    {CALENDAR_FILTER_ATTRIBUTE_PROGRESS,               PrimitiveType_Integer},
     {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY,        PrimitiveType_String},
     {0,        PrimitiveType_NoType}
 };
index 3a21b73..da5a7e6 100755 (executable)
@@ -64,7 +64,8 @@ CalendarManager::~CalendarManager()
 void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
 {
     LogDebug("entered");
-    static std::vector<ICalendarPtr> calendars;
+
+    std::vector<ICalendarPtr> calendars;
     Try
     {
         cal_iter *iter = NULL;
@@ -76,9 +77,6 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
         }
         cal_struct *calendar = NULL;
         while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
-            if (event->checkCancelled()) {
-                break;
-            }
             if (CAL_SUCCESS ==
                 calendar_svc_iter_get_info(iter, &calendar)) {
                 const char* name = calendar_svc_struct_get_str(
@@ -111,13 +109,11 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
         }
         calendar_svc_iter_remove(&iter);
 
-        if (!event->checkCancelled()) {
-            std::vector<ICalendarPtr>::const_iterator it = calendars.begin();
-            for (; it != calendars.end(); ++it) {
-                event->addCalendar(*it);
-            }
-            event->setResult(true);
+        std::vector<ICalendarPtr>::const_iterator it = calendars.begin();
+        for (; it != calendars.end(); ++it) {
+            event->addCalendar(*it);
         }
+        event->setResult(true);
     }
     Catch(Exception)
     {
@@ -125,12 +121,12 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(true);
 }
 
 void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event)
 {
     LogDebug("entered");
+
     ICalendarPtr newCalendar(new Calendar());
     Try
     {
@@ -144,9 +140,6 @@ void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event
         }
         cal_struct *calendar = NULL;
         while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
-            if (event->checkCancelled()) {
-                break;
-            }
             if (CAL_SUCCESS ==
                 calendar_svc_iter_get_info(iter, &calendar)) {
                 const char* name = calendar_svc_struct_get_str(
@@ -187,7 +180,6 @@ void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(true);
 }
 
 void CalendarManager::OnRequestReceived(const IEventGetCalendarPtr &event)
@@ -247,7 +239,6 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarPtr &event)
         event->setResult(false);
         event->setExceptionCode(ExceptionCodes::UnknownException);
     }
-    event->setCancelAllowed(true);
 }
 
 }
index 4c5e8af..dcf8004 100755 (executable)
@@ -23,10 +23,10 @@ sqlite3 *hDBCt;
 
 static int db_connnect_count = 0;
 
-query_error _db_init()
+calendar_query_error calendar_db_init()
 {
        int rc = 0;
-       query_error error_code = QUERY_SUCCESS;
+       calendar_query_error error_code = QUERY_SUCCESS;
 
        db_connnect_count++;
        if(!hDBCt)
@@ -38,10 +38,10 @@ query_error _db_init()
        return error_code;
 }
 
-query_error _db_finish()
+calendar_query_error calendar_db_finish()
 {
        int rc = 0;
-       query_error error_code = QUERY_SUCCESS;
+       calendar_query_error error_code = QUERY_SUCCESS;
 
        db_connnect_count--;
        if(db_connnect_count == 0)
@@ -55,11 +55,11 @@ query_error _db_finish()
        return error_code;
 }
 
-query_error _exec_query(char* query)
+calendar_query_error calendar_exec_query(char* query)
 {
        int rc = -1;
        char* pszErrorMsg = NULL;
-       query_error             error_code = QUERY_SUCCESS;
+       calendar_query_error error_code = QUERY_SUCCESS;
 
        rc = sqlite3_exec(hDBCt, query, NULL, NULL, &pszErrorMsg);
 
@@ -74,22 +74,12 @@ query_error _exec_query(char* query)
        return error_code;
 }
 
-int _query_step(stmt pStmt)
+int calendar_query_step(stmt pStmt)
 {
        return sqlite3_step(pStmt);
 }
 
-int _calendar_query_column_int(stmt pStmt, int pos)
-{
-       return (int)sqlite3_column_int(pStmt, pos);
-}
-
-char* _calendar_query_column_text(stmt pStmt, int pos)
-{
-       return (char *)sqlite3_column_text(pStmt, pos);
-}
-
-void _query_finalize(stmt pStmt)
+void calendar_query_finalize(stmt pStmt)
 {
        int rc = -1;
 
@@ -103,17 +93,17 @@ void _query_finalize(stmt pStmt)
        }
 }
 
-int _query_bind_double(stmt pStmt, int pos, double num)
+int calendar_query_bind_double(stmt pStmt, int pos, double num)
 {
    return sqlite3_bind_double(pStmt, pos, num);
 }
 
-int _query_bind_int(stmt pStmt, int pos, int num)
+int calendar_query_bind_int(stmt pStmt, int pos, int num)
 {
    return sqlite3_bind_int(pStmt, pos, num);
 }
 
-int _query_bind_text(stmt pStmt, int pos, char* str)
+int calendar_query_bind_text(stmt pStmt, int pos, char* str)
 {
        int len = 0;
        if(str != NULL)
@@ -124,28 +114,28 @@ int _query_bind_text(stmt pStmt, int pos, char* str)
        return -1;
 }
 
-void _query_stmt_reset(stmt stmt)
+void calendar_query_stmt_reset(stmt stmt)
 {
    sqlite3_reset(stmt);
    sqlite3_clear_bindings(stmt);
 }
 
-int _query_column_int(stmt pStmt, int pos)
+int calendar_query_column_int(stmt pStmt, int pos)
 {
    return sqlite3_column_int(pStmt, pos);
 }
 
-double _query_column_double(stmt pStmt, int pos)
+double calendar_query_column_double(stmt pStmt, int pos)
 {
    return sqlite3_column_double(pStmt, pos);
 }
 
-char* _query_column_text(stmt pStmt, int pos)
+char* calendar_query_column_text(stmt pStmt, int pos)
 {
    return (char *)sqlite3_column_text(pStmt, pos);
 }
 
-stmt _query_prepare(char *query)
+stmt calendar_query_prepare(char *query)
 {
        int rc = -1;
        stmt pStmt = NULL;
index 36777a1..b6b63e9 100755 (executable)
@@ -53,39 +53,33 @@ typedef enum
        QUERY_ALLOCATE_MEMORY_FAIL,             /**< memory allocation fail */
        QUERY_FAIL = -1,                                /**< fail */
        QUERY_SUCCESS = 0,                              /**< no error */
-}query_error;
+}calendar_query_error;
 
-query_error _db_init();
+calendar_query_error calendar_db_init();
 
-query_error _db_finish();
+calendar_query_error calendar_db_finish();
 
-query_error _exec_query(char* query);
+calendar_query_error calendar_exec_query(char* query);
 
-int _query_step(stmt pStmt);
+int calendar_query_step(stmt pStmt);
 
-void _calendar_query_finalize(stmt pStmt);
+void calendar_query_finalize(stmt pStmt);
 
-int _calendar_query_column_int(stmt pStmt, int pos);
+int calendar_query_bind_int(stmt pStmt, int pos, int num);
 
-char* _calendar_query_column_text(stmt pStmt, int pos);
+int calendar_query_bind_double(stmt pStmt, int pos, double num);
 
-void _query_finalize(stmt pStmt);
+int calendar_query_bind_text(stmt pStmt, int pos, char* str);
 
-int _query_bind_int(stmt pStmt, int pos, int num);
+void calendar_query_stmt_reset(stmt stmt);
 
-int _query_bind_double(stmt pStmt, int pos, double num);
+int calendar_query_column_int(stmt pStmt, int pos);
 
-int _query_bind_text(stmt pStmt, int pos, char* str);
+double calendar_query_column_double(stmt pStmt, int pos);
 
-void _query_stmt_reset(stmt stmt);
+char* calendar_query_column_text(stmt pStmt, int pos);
 
-int _query_column_int(stmt pStmt, int pos);
-
-double _query_column_double(stmt pStmt, int pos);
-
-char* _query_column_text(stmt pStmt, int pos);
-
-stmt _query_prepare(char *query);
+stmt calendar_query_prepare(char *query);
 
 #ifdef __cplusplus
 }
index 6dac29b..702b22b 100755 (executable)
@@ -36,7 +36,7 @@ namespace TizenApis {
 namespace Platform {
 namespace Calendar {
 
-EventWrapper::EventWrapper(Api::Calendar::CalendarEvent::CalendarType type) :
+EventWrapper::EventWrapper(CalendarEvent::CalendarType type) :
     m_platformEvent(NULL),
     m_abstractEvent(NULL),
     m_calendarType(type)
@@ -48,7 +48,7 @@ EventWrapper::EventWrapper(Api::Calendar::CalendarEvent::CalendarType type) :
     }
 }
 
-EventWrapper::EventWrapper(const CalendarEventPtr &event, Api::Calendar::CalendarEvent::CalendarType type) :
+EventWrapper::EventWrapper(const CalendarEventPtr &event, CalendarEvent::CalendarType type) :
     m_platformEvent(NULL),
     m_abstractEvent(event),
     m_calendarType(type)
@@ -56,7 +56,7 @@ EventWrapper::EventWrapper(const CalendarEventPtr &event, Api::Calendar::Calenda
     LogDebug("entered");
 }
 
-EventWrapper::EventWrapper(cal_struct *event, Api::Calendar::CalendarEvent::CalendarType type) :
+EventWrapper::EventWrapper(cal_struct *event, CalendarEvent::CalendarType type) :
     m_platformEvent(event),
     m_abstractEvent(NULL),
     m_calendarType(type)
@@ -74,7 +74,7 @@ EventWrapper::~EventWrapper()
     freePlatformEvent();
 }
 
-int EventWrapper::getIDFromPlatformEvent() const
+int EventWrapper::getIdFromPlatformEvent() const
 {
     LogDebug("Entered");
     if (m_platformEvent == NULL) {
@@ -118,25 +118,20 @@ void EventWrapper::saveEvent()
         ThrowMsg(NullPointerException, "m_platformEvent is not set");
     }
 
-    int eventID = getIDFromPlatformEvent();
-    LogDebug("Before saving/update eventID: " << eventID);
+    int eventId = getIdFromPlatformEvent();
+    LogDebug("Before saving/update eventId: " << eventId);
 
-    displayPlatformEvent();
+    //displayPlatformEvent();
 
     //insert new record or update existing one
-    if (eventID < 0) {
+    if (eventId < 0) {
         int returnValue = calendar_svc_insert(m_platformEvent);
         if (CAL_SUCCESS > returnValue) {
             LogError("Can't insert new event, error code: " << returnValue);
             ThrowMsg(PlatformException, "Can't insert new event.");
         }
         m_abstractEvent->setId(returnValue);
-
-        //save the uid here too.
-        std::stringstream ss;
-        ss<<returnValue;
-        m_abstractEvent->setUId(ss.str());
-        LogInfo("New calendar event inserted with id "<<returnValue);
+        LogInfo("New calendar item inserted with id "<<returnValue);
     } else {
         int errorCode = calendar_svc_update(m_platformEvent);
         if (CAL_SUCCESS != errorCode) {
@@ -148,7 +143,7 @@ void EventWrapper::saveEvent()
 
 void EventWrapper::loadEvent(int id)
 {
-    LogDebug("Entered. ID of event to load: " << id);
+    LogDebug("Entered. Id of event to load: " << id);
     freePlatformEvent();
     
     const char *dataType;
@@ -164,41 +159,35 @@ void EventWrapper::loadEvent(int id)
                                      &m_platformEvent);
     if (CAL_SUCCESS > errorCode) {
         ThrowMsg(PlatformException,
-            "Can't get event with ID = " << id << ", error code: " <<
-            errorCode);
+            "Can't get item with id = " << id << ", error code: " <<errorCode);
     }
-    // Consider that the event is not found if the last modified date is 0.
-    if ( 0==calendar_svc_struct_get_time(
-            m_platformEvent,
-            CAL_VALUE_GMT_LAST_MODIFIED_TIME,
-            CAL_TZ_FLAG_GMT) ) {
-        ThrowMsg(NotFoundException, "Can't get event with provided id.");
+
+    if ( 1==calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_DELETED) ) {
+        ThrowMsg(NotFoundException, "Deleted item.");
     }
 
     convertPlatformEventToAbstractEvent();
     m_abstractEvent->setCalendarType(m_calendarType);
-    displayAbstractEvent();
+    //displayAbstractEvent();
 }
 
 void EventWrapper::deleteEvent()
 {
     LogDebug("entered");
+
     if (m_platformEvent == NULL) {
-        ThrowMsg(NullPointerException,
-                 "Failed to delete event in calendar (m_platformEvent==NULL)");
+        ThrowMsg(NullPointerException, "Platform event is null.");
     }
 
     // If the recurrenceId is set, delete the instance of recurring event only.
-    int eventID = getIDFromPlatformEvent();
+    int itemId = getIdFromPlatformEvent();
     std::time_t recurrenceId = m_abstractEvent->getRecurrenceId();
-    LogDebug("eventID to delete: " << eventID << ", recurrenceId: " << recurrenceId);
-    if (eventID < 0) {
-        ThrowMsg(
-            InvalidArgumentException,
-            "Failed to delete event in calendar (event is not saved in calendar)");
+    LogDebug("eventId to delete: " << itemId << ", recurrenceId: " << recurrenceId);
+    if (itemId <= 0) {
+        ThrowMsg(InvalidArgumentException, "Item id is invalid.");
     }
 
-    cal_struct *event = NULL;
+    cal_struct *item = NULL;
     const char *dataType;
     if(getType() == CalendarEvent::TASK_TYPE) {
         dataType = CAL_STRUCT_TODO;
@@ -206,44 +195,75 @@ void EventWrapper::deleteEvent()
         dataType = CAL_STRUCT_SCHEDULE;
     }
 
-    int error = calendar_svc_get(dataType, eventID, NULL, &event);
+    int error = calendar_svc_get(dataType, itemId, NULL, &item);
     if (CAL_SUCCESS != error) {
-        if (event) {
-            calendar_svc_struct_free(&event);
+        if (item) {
+            calendar_svc_struct_free(&item);
         }
-        ThrowMsg(PlatformException,
-            "Can't get calendar event. Error code "<< error);
+        ThrowMsg(PlatformException, "Can't get item. Error code "<< error);
     }
-    // Consider that the event is not found if the last modified date is 0.
-    if ( 0==calendar_svc_struct_get_time(
-            event,
-            CAL_VALUE_GMT_LAST_MODIFIED_TIME,
-            CAL_TZ_FLAG_GMT) ) {
-            if (event) {
-                calendar_svc_struct_free(&event);
-            }
-        ThrowMsg(NotFoundException, "Can't get event with provided id.");
+
+    if ( 1==calendar_svc_struct_get_int(item, CAL_VALUE_INT_DELETED) ) {
+        LogInfo("The item is already deleted.");
+        if (item) {
+            calendar_svc_struct_free(&item);
+        }
+        return;
     }
-    if (event) {
-        calendar_svc_struct_free(&event);
+
+    if (item) {
+        calendar_svc_struct_free(&item);
     }
 
     if ( 0>=recurrenceId || 
-        !(EventRecurrenceRule::DAILY_RECURRENCE <= m_abstractEvent->getRecurrenceRule()->getFrequency() && m_abstractEvent->getRecurrenceRule()->getFrequency() <= EventRecurrenceRule::MONTHLY_ON_DAY_RECURRENCE)) {
-        const char *dataType;
-        if(getType() == CalendarEvent::TASK_TYPE) {
-            dataType = CAL_STRUCT_TODO;
-        } else {
-            dataType = CAL_STRUCT_SCHEDULE;
-        }
-        error = calendar_svc_delete(dataType, eventID);
+        !(EventRecurrenceRule::DAILY_RECURRENCE <= m_abstractEvent->getRecurrenceRule()->getFrequency() 
+        && m_abstractEvent->getRecurrenceRule()->getFrequency() <= EventRecurrenceRule::MONTHLY_ON_DAY_RECURRENCE)) {
+        // Remove the parent and child instances by the given uid.
+        int parentId = itemId;
+
+        // First, the parent event.
+        error = calendar_svc_delete(dataType, parentId);
         if (CAL_SUCCESS != error) {
-            ThrowMsg(PlatformException,
-                     "Can't delete calendar event. Error code " << error);
+            ThrowMsg(PlatformException, "Can't delete calendar event. Error code " << error);
         }
         m_abstractEvent->resetId();
-        setIDToPlatformEvent();
-        LogDebug("The event is deleted regardless of recurrence");
+        setIdToPlatformEvent();
+
+        LogDebug("The parent item is deleted.");
+
+        // Next, all the detached instances.
+        cal_iter *iter = NULL;
+        cal_struct *platformEvent = NULL;
+        if(CAL_SUCCESS != calendar_svc_find_event_list(m_calendarAccountId, CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
+            LogInfo("Founding detached instances failed.");
+        }
+
+        while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+            LogInfo("Deleting a detached instance...");
+            platformEvent = NULL;
+            if (CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent)) {
+                if(iter) {
+                    calendar_svc_iter_remove(&iter);
+                }
+                ThrowMsg(PlatformException, "Can't get event info.");
+            }
+
+            int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
+            LogDebug("detachedEventId "<<detachedEventId);
+            int error = calendar_svc_delete(dataType, detachedEventId);
+            if (CAL_SUCCESS != error) {
+                if(iter) {
+                    calendar_svc_iter_remove(&iter);
+                }
+                ThrowMsg(PlatformException, "Can't delete calendar event. Error code " << error);
+            } else {
+                LogDebug("Deleted a detached event by id: "<<detachedEventId);
+            }
+        }
+
+        if(iter) {
+            calendar_svc_iter_remove(&iter);
+        }
     } else {
         GList* list = NULL;
         cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
@@ -281,7 +301,7 @@ void EventWrapper::createEventFromString(std::string value)
         ThrowMsg(PlatformException, "Can't convert string");
     }
 
-    displayPlatformEvent();
+    //displayPlatformEvent();
 }
 
 std::string EventWrapper::exportEventToString()
@@ -317,11 +337,12 @@ void EventWrapper::freePlatformEvent()
     }
 }
 
-cal_struct *EventWrapper::convertAbstractEventToPlatformEvent()
+cal_structEventWrapper::convertAbstractEventToPlatformEvent()
 {
     LogDebug("entered");
     freePlatformEvent();
     const char *dataType;
+
     if(getType() == CalendarEvent::TASK_TYPE) {
         dataType = CAL_STRUCT_TODO;
     } else {
@@ -331,6 +352,7 @@ cal_struct *EventWrapper::convertAbstractEventToPlatformEvent()
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "cannot create platform event");
     }
+
     setDescriptionToPlatformEvent();
     setSummaryToPlatformEvent();
     setStartTimeToPlatformEvent();
@@ -344,11 +366,12 @@ cal_struct *EventWrapper::convertAbstractEventToPlatformEvent()
     setAttendeesToPlatformEvent();
     setPositionToPlatformEvent();
     setVisibilityToPlatformEvent();
-    setLastModifiedDateToPlatformEvent();
+    //setLastModifiedDateToPlatformEvent(); // read-only in platform.
     setAvailabilityToPlatformEvent();
     setRecurrenceRuleToPlatformEvent();
-    setIDToPlatformEvent();
+    setIdToPlatformEvent();
     //setUIdToPlatformEvent(); // We don't set uid but use id field instead.
+    setParentIdToPlatformEvent();
     setPriorityToPlatformEvent();
     setCreatedDateToPlatformEvent();
     setCompletedDateToPlatformEvent();
@@ -390,7 +413,7 @@ void EventWrapper::setStartTimeToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    time_t time = m_abstractEvent->getStartTime();
+    std::time_t time = m_abstractEvent->getStartTime();
     if (time == 0) {
         time = m_abstractEvent->getEndTime();
     }
@@ -414,7 +437,7 @@ void EventWrapper::setEndTimeToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    time_t time = m_abstractEvent->getEndTime();
+    std::time_t time = m_abstractEvent->getEndTime();
     if (time == 0) {
         time = m_abstractEvent->getStartTime();
     }
@@ -492,7 +515,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         if( 0 != rrule->getDaysOfTheWeek().size() ) {
             convertDaysOfTheWeekToFlag(rrule->getDaysOfTheWeek(), weekFlag);
         } else {
-            time_t date = m_abstractEvent->getStartTime();
+            std::time_t date = m_abstractEvent->getStartTime();
             tm* time = localtime(&date);
             if (!time) {
                 LogError("localtime failed");
@@ -517,8 +540,8 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
                                                         weekFlag));
 
         LogInfo("Applied weekFlag "<<weekFlag);
+        break;
     }
-    break;
     case EventRecurrenceRule::MONTHLY_ON_DAY_RECURRENCE:
     {
         char weekFlag[] = "0000000";
@@ -526,7 +549,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         if( 0 != rrule->getDaysOfTheWeek().size() ) {
             convertDaysOfTheWeekToFlag(rrule->getDaysOfTheWeek(), weekFlag);
         } else {
-            time_t date = m_abstractEvent->getStartTime();
+            std::time_t date = m_abstractEvent->getStartTime();
             int days = localtime(&date)->tm_wday;
             if (days < 0 || days > 6) {
                 LogError("invalid week day");
@@ -540,8 +563,8 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
                                                         CAL_VALUE_TXT_WEEK_FLAG,
                                                         weekFlag));
         LogInfo("Applied weekFlag "<<weekFlag);
+        break;
     }
-    break;
     case EventRecurrenceRule::MONTHLY_RECURRENCE:
     {
         char weekFlag[] = "0000000";
@@ -549,7 +572,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         if( 0 != rrule->getDaysOfTheWeek().size() ) {
             convertDaysOfTheWeekToFlag(rrule->getDaysOfTheWeek(), weekFlag);
         } else {
-            time_t date = m_abstractEvent->getStartTime();
+            std::time_t date = m_abstractEvent->getStartTime();
             int days = localtime(&date)->tm_wday;
             if (days < 0 || days > 6) {
                 LogError("invalid week day");
@@ -567,10 +590,9 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
                                                         CAL_VALUE_TXT_WEEK_FLAG,
                                                         weekFlag));
         LogInfo("Applied weekFlag "<<weekFlag);
+        break;
     }
-    break;
     case EventRecurrenceRule::WEEKDAY_RECURRENCE:
-    {
         ret = (CAL_SUCCESS == calendar_svc_struct_set_int(m_platformEvent,
                                                           CAL_VALUE_INT_REPEAT_TERM,
                                                           CAL_REPEAT_EVERY_WEEK))
@@ -578,8 +600,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
             (CAL_SUCCESS == calendar_svc_struct_set_str(m_platformEvent,
                                                         CAL_VALUE_TXT_WEEK_FLAG,
                                                         WEEKDAYS));
-    }
-    break;
+        break;
     case EventRecurrenceRule::YEARLY_RECURRENCE:
     {
         char weekFlag[] = "0000000";
@@ -587,7 +608,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         if( 0 != rrule->getDaysOfTheWeek().size() ) {
             convertDaysOfTheWeekToFlag(rrule->getDaysOfTheWeek(), weekFlag);
         } else {
-            time_t date = m_abstractEvent->getStartTime();
+            std::time_t date = m_abstractEvent->getStartTime();
             int days = localtime(&date)->tm_wday;
             if (days < 0 || days > 6) {
                 LogError("invalid week day");
@@ -605,9 +626,8 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
                                                         CAL_VALUE_TXT_WEEK_FLAG,
                                                         weekFlag));
         LogInfo("Applied weekFlag "<<weekFlag);
+        break;
     }
-    break;
-    case EventRecurrenceRule::INVALID_RECURRENCE:
     case EventRecurrenceRule::UNDEFINED_RECURRENCE:
     default:
         LogError("invalid reccurence rule frequency " << rrule->getFrequency());
@@ -615,17 +635,9 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         break;
     }
 
-    // set the recurrency interval
-    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
-                                                   CAL_VALUE_INT_REPEAT_INTERVAL,
-                                                   rrule->getInterval()))
-    {
-        ThrowMsg(PlatformException, "Can't set interval.");
-        ret = 0;
-    }
-
     // set the ocurrence count
     if (-1 != rrule->getOccurrenceCount()) {
+        LogInfo("Set the occurrence count: "<<rrule->getOccurrenceCount());
         if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
                                                        CAL_VALUE_INT_REPEAT_OCCURRENCES,
                                                        rrule->getOccurrenceCount()))
@@ -633,44 +645,12 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
             ThrowMsg(PlatformException, "Can't set occurrence count.");
             ret = 0;
         }
-    } else {
-        if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
-                                                       CAL_VALUE_INT_REPEAT_OCCURRENCES,
-                                                       0))
-        {
-            ThrowMsg(PlatformException, "Can't set the ocurrence count.");
-            ret = 0;
-        }
-    }
-
-    // set the recurrence end date
-    if (0!=rrule->getEndDate()) {
-        if (CAL_SUCCESS != calendar_svc_struct_set_time(
-                m_platformEvent,
-                CAL_VALUE_GMT_REPEAT_END_DATE,
-                CAL_TZ_FLAG_GMT,
-                m_abstractEvent->getRecurrenceRule()->getEndDate()))
-        {
-            ThrowMsg(PlatformException, "Can't set recurrence end date.");
-            ret = 0;
-        }
-    } else {
-        // Platform needs default positive end date in the sql query statement for the recurrence event!
-        if (CAL_SUCCESS != calendar_svc_struct_set_time(
-                m_platformEvent,
-                CAL_VALUE_GMT_REPEAT_END_DATE,
-                CAL_TZ_FLAG_GMT,
-                1))
-        {
-            ThrowMsg(PlatformException, "Can't set recurrence end date.");
-            ret = 0;
-        }
     }
 
     // set the exceptions
     if ( !rrule->getExceptions().empty() )
     {
-        LogInfo("Set the exceptions.");
+        LogInfo("Set the exceptions of length: "<<rrule->getExceptions().size());
         GList* list = NULL;
         calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_EXCEPTION_DATE, &list);
 
@@ -694,6 +674,29 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
         }
     }
 
+    // set the recurrence interval
+    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                   CAL_VALUE_INT_REPEAT_INTERVAL,
+                                                   rrule->getInterval()))
+    {
+        ThrowMsg(PlatformException, "Can't set interval.");
+        ret = 0;
+    }
+
+    // set the recurrence end date. This is automatically calculated by platform if empty.
+    if (0!=rrule->getEndDate()) {
+        LogInfo("Setting the end date: "<<rrule->getEndDate());
+        if (CAL_SUCCESS != calendar_svc_struct_set_time(
+                m_platformEvent,
+                CAL_VALUE_GMT_REPEAT_END_DATE,
+                CAL_TZ_FLAG_GMT,
+                m_abstractEvent->getRecurrenceRule()->getEndDate()))
+        {
+            ThrowMsg(PlatformException, "Can't set recurrence end date.");
+            ret = 0;
+        }
+    }
+
     // "day_date" flag means the day of week by 0 and the date of month by 1 based on the start date,
     // which takes effects in monthly/yearly repeat term.
     if( true == rrule->getSetPosition() ) {
@@ -726,12 +729,13 @@ void EventWrapper::setAlarmsToPlatformEvent()
     }
 
     if( 0 != m_abstractEvent->getAlarmsTick().size() ) {
-        LogInfo("Set the alarms.");
         GList* list = NULL;
         calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &list);
 
         for( unsigned int i=0; i<m_abstractEvent->getAlarmsTick().size(); i++ )
         {
+            LogInfo("Set the alarms #"<<i);
+
             cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_ALARM);
 
             // We have to use alarm tick and tick unit for alarm creation.
@@ -896,7 +900,7 @@ void EventWrapper::setCategoriesToPlatformEvent()
     }
 }
 
-void EventWrapper::setIDToPlatformEvent()
+void EventWrapper::setIdToPlatformEvent()
 {
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "Null platform pointer.");
@@ -906,17 +910,31 @@ void EventWrapper::setIDToPlatformEvent()
                                                        CAL_VALUE_INT_INDEX,
                                                        m_abstractEvent->getId()))
         {
-            ThrowMsg(PlatformException, "Can't set event ID.");
+            ThrowMsg(PlatformException, "Can't set event Id.");
         }
     } else {
         if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
                                                        CAL_VALUE_INT_INDEX,
                                                        NEW_EVENT_ID)) {
-            ThrowMsg(PlatformException, "Can't set event ID.");
+            ThrowMsg(PlatformException, "Can't set event Id.");
         }
     }
 }
 
+void EventWrapper::setParentIdToPlatformEvent()
+{
+    if (!m_platformEvent) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    if (CAL_SUCCESS != calendar_svc_struct_set_int(m_platformEvent,
+                                                   CAL_VALUE_INT_ORIGINAL_EVENT_ID,
+                                                   m_abstractEvent->getParentId()))
+    {
+        ThrowMsg(PlatformException, "Can't set parent Id.");
+    }
+}
+
 void EventWrapper::setIsAllDayToPlatformEvent()
 {
     if (!m_platformEvent) {
@@ -947,7 +965,7 @@ void EventWrapper::setLastModifiedDateToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    time_t time = m_abstractEvent->getLastModifiedDate();
+    std::time_t time = m_abstractEvent->getLastModifiedDate();
 
     if (CAL_SUCCESS != calendar_svc_struct_set_time(m_platformEvent,
                                                     CAL_VALUE_GMT_LAST_MODIFIED_TIME,
@@ -1201,7 +1219,7 @@ void EventWrapper::setAttendeesToPlatformEvent()
                 ThrowMsg(PlatformException, "Cannot set attendee delegate uri");
             }
 
-            // save contactId only
+            // save contactId
             if (CAL_SUCCESS !=
                 calendar_svc_value_set_str(attendee, CAL_VALUE_TXT_ATTENDEE_UID,
                                            attendeeList->at(i)->getContactId().c_str())) {
@@ -1210,6 +1228,18 @@ void EventWrapper::setAttendeesToPlatformEvent()
                 ThrowMsg(PlatformException, "Cannot set attendee uid");
             }
 
+            // save addressBookId
+            std::stringstream ss(attendeeList->at(i)->getAddressBookId());
+            int addressBookId;
+            ss>>addressBookId;
+            if (CAL_SUCCESS !=
+                calendar_svc_value_set_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX,
+                                           addressBookId)) {
+                LogError("error during setting attendee address book id");
+                calendar_svc_value_free(&attendee);
+                ThrowMsg(PlatformException, "Cannot set attendee address book id");
+            }
+
             attendees = g_list_append(attendees, attendee);
         }
 
@@ -1242,13 +1272,13 @@ void EventWrapper::setPositionToPlatformEvent()
 
     if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
                                                    CAL_VALUE_DBL_LATITUDE,
-                                                   m_abstractEvent->getGeolocation()->getLatitude())) {
+                                                   m_abstractEvent->getLatitude())) {
         ThrowMsg(PlatformException, "Can't set latitude.");
     }
 
     if (CAL_SUCCESS != calendar_svc_struct_set_double(m_platformEvent,
                                                    CAL_VALUE_DBL_LONGITUDE,
-                                                   m_abstractEvent->getGeolocation()->getLongitude())) {
+                                                   m_abstractEvent->getLongitude())) {
         ThrowMsg(PlatformException, "Can't set longitude.");
     }
 }
@@ -1289,7 +1319,7 @@ void EventWrapper::setCreatedDateToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-        time_t time = m_abstractEvent->getCreatedDate();
+        std::time_t time = m_abstractEvent->getCreatedDate();
         if (CAL_SUCCESS != calendar_svc_struct_set_time(m_platformEvent,
                                                         CAL_VALUE_GMT_CREATED_DATE_TIME,
                                                         CAL_TZ_FLAG_GMT,
@@ -1304,7 +1334,7 @@ void EventWrapper::setCompletedDateToPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-        time_t time = m_abstractEvent->getCompletedDate();
+        std::time_t time = m_abstractEvent->getCompletedDate();
         if (CAL_SUCCESS != calendar_svc_struct_set_time(m_platformEvent,
                                                         CAL_VALUE_GMT_COMPLETED_DATE_TIME,
                                                         CAL_TZ_FLAG_GMT,
@@ -1346,13 +1376,14 @@ CalendarEventPtr EventWrapper::convertPlatformEventToAbstractEvent()
     setLastModifiedDateFromPlatformEvent();
     setAvailabilityFromPlatformEvent();
     setRecurrenceRuleFromPlatformEvent();
-    setIDFromPlatformEvent();
+    setIdFromPlatformEvent();
+    setParentIdFromPlatformEvent();
     //setUIdFromPlatformEvent(); // We set the uid value as the same with id.
-    //setRecurrenceIdFromPlatformEvent();
     setPriorityFromPlatformEvent();
     setCreatedDateFromPlatformEvent();
     setCompletedDateFromPlatformEvent();
     setProgressFromPlatformEvent();
+    setIsDetachedFromPlatformEvent();
 
     return getAbstractEvent();
 }
@@ -1387,7 +1418,7 @@ void EventWrapper::setStartTimeFromPlatformEvent()
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
-    time_t startTime = calendar_svc_struct_get_time(
+    std::time_t startTime = calendar_svc_struct_get_time(
             m_platformEvent,
             CAL_VALUE_GMT_START_DATE_TIME,
             CAL_TZ_FLAG_GMT);
@@ -1407,7 +1438,7 @@ void EventWrapper::setEndTimeFromPlatformEvent()
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
-    time_t endTime = calendar_svc_struct_get_time(m_platformEvent,
+    std::time_t endTime = calendar_svc_struct_get_time(m_platformEvent,
                                                   CAL_VALUE_GMT_END_DATE_TIME,
                                                   CAL_TZ_FLAG_GMT);
     m_abstractEvent->setEndTime(endTime);
@@ -1427,11 +1458,19 @@ void EventWrapper::setLocationFromPlatformEvent()
 
 std::vector<std::string> convertFlagToDaysOfTheWeek(const char *daysFlag)
 {
-    if( strlen(daysFlag)<7 )
-        LogError("daysFlag is too short!");
-
     std::vector<std::string> daysOfTheWeek;
 
+    if(NULL==daysFlag) {
+        LogWarning("daysFlag is NULL.");
+        return daysOfTheWeek;
+    }
+    if( strlen(daysFlag)<7 ) {
+        LogWarning("daysFlag is too short or empty.");
+        return daysOfTheWeek;
+    }
+
+    LogInfo("daysFlag "<<daysFlag);
+
     if( daysFlag[0]=='1' )
         daysOfTheWeek.push_back("SU");
     if( daysFlag[1]=='1' )
@@ -1527,27 +1566,33 @@ void EventWrapper::setRecurrenceRuleFromPlatformEvent()
     rrule->setOccurrenceCount(occurrrenceCount);
 
     // load the recurrence end date
-    time_t endDate = calendar_svc_struct_get_time(m_platformEvent,
+    std::time_t endDate = calendar_svc_struct_get_time(m_platformEvent,
                                                   CAL_VALUE_GMT_REPEAT_END_DATE,
                                                   CAL_TZ_FLAG_GMT);
     rrule->setEndDate(endDate);
+       LogDebug("endDate from platform = " << endDate);
 
     // load the exceptions
-    rrule->getExceptions().clear();
+    std::vector<std::time_t> exceptions = rrule->getExceptions();
+    exceptions.clear();
     GList* exceptionList = NULL;
     calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_EXCEPTION_DATE, &exceptionList);
     cal_value* exceptionValue = NULL;
     for (; exceptionList; exceptionList = g_list_next(exceptionList)) {
         exceptionValue = static_cast<cal_value*>(exceptionList->data);
-        std::time_t exceptoinTime = calendar_svc_value_get_time(exceptionValue,
+        std::time_t exceptionTime = calendar_svc_value_get_time(exceptionValue,
                                                         CAL_VALUE_GMT_EXCEPTION_DATE_TIME,
                                                         CAL_TZ_FLAG_GMT);
-        if (CAL_ERR_FAIL == exceptoinTime) {
-            LogError("cannot read exceptoin time");
-            return;
+        if (CAL_ERR_FAIL == exceptionTime) {
+            LogError("Cannot read exception time. Break.");
+            break;
+        } else {
+            LogInfo("Read an exception instance: "<<exceptionTime);
         }
-        rrule->getExceptions().push_back(exceptoinTime);
+        exceptions.push_back(exceptionTime);
     }
+    rrule->setExceptions(exceptions);
+    LogInfo("Number of exceptions: "<<rrule->getExceptions().size());
 
     // load the setPosition
     int day_date = calendar_svc_struct_get_int(m_platformEvent,
@@ -1568,48 +1613,59 @@ void EventWrapper::setAlarmsFromPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
+    std::vector<long> alarmsTick;
+    std::vector<CalendarEvent::EventAlarmType> alarmsType;
+    std::vector<std::string> alarmsDescription;
+
     GList* alarmList = NULL;
     calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_ALARM, &alarmList);
     cal_value* alarmValue = NULL;
     for (; alarmList; alarmList = g_list_next(alarmList)) {
+        LogDebug("Processing alarm...");
         alarmValue = static_cast<cal_value*>(alarmList->data);
 
         int tick = calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TICK);
         if (CAL_ERR_FAIL == tick) {
-            LogError("cannot read alarm tick");
+            LogError("Cannot read alarm tick. Stop processing alarms.");
             return;
         }
-        m_abstractEvent->getAlarmsTick().push_back(tick);
+        alarmsTick.push_back(tick);
 
         cal_alert_type_t type = static_cast<cal_alert_type_t>(calendar_svc_value_get_int(alarmValue, CAL_VALUE_INT_ALARMS_TYPE));
         if ( 0 > type) {
-            LogError("cannot read alarm type");
-            return;
+            LogError("Cannot read alarm type. Setting the default value.");
         }
         switch (type) {
         case CAL_ALERT_VIBRATION:
-            m_abstractEvent->getAlarmsType().push_back(CalendarEvent::SILENT_ALARM);
+            alarmsType.push_back(CalendarEvent::SILENT_ALARM);
             break;
         case CAL_ALERT_MELODY:
         case CAL_ALERT_INCREASING_MELODY:
         case CAL_ALERT_VIBRATION_THEN_MELODY:
         case CAL_ALERT_VIBMELODY:
         case CAL_ALERT_VIB_INCREASING_MELODY:
-            m_abstractEvent->getAlarmsType().push_back(CalendarEvent::SOUND_ALARM);
+            alarmsType.push_back(CalendarEvent::SOUND_ALARM);
             break;
         case CAL_ALERT_MUTE:
         default:
-            m_abstractEvent->getAlarmsType().push_back(CalendarEvent::NO_ALARM);
+            alarmsType.push_back(CalendarEvent::NO_ALARM);
             break;
         }
 
-        const char* description = calendar_svc_value_get_str(alarmValue, CAL_VALUE_TXT_ALARMS_DESCRIPTION);
+        char* description = calendar_svc_value_get_str(alarmValue, CAL_VALUE_TXT_ALARMS_DESCRIPTION);
         if (NULL == description) {
-            LogError("cannot read alarm description");
-            return;
+            LogError("Cannot read alarm description. Setting NULL.");
+            alarmsDescription.push_back("");
+        } else {
+            alarmsDescription.push_back(description);
         }
-        m_abstractEvent->getAlarmsDescription().push_back(description);
+
+        // Save the vectors.
+        m_abstractEvent->setAlarmsTick(alarmsTick);
+        m_abstractEvent->setAlarmsType(alarmsType);
+        m_abstractEvent->setAlarmsDescription(alarmsDescription);
     }
+    LogInfo("Number of alarms: "<<m_abstractEvent->getAlarmsTick().size());
 }
 
 void EventWrapper::setStatusFromPlatformEvent()
@@ -1666,26 +1722,39 @@ void EventWrapper::setCategoriesFromPlatformEvent()
         char* categoryName = calendar_svc_value_get_str(category,
                                                         "category_name");
         if (NULL == categoryName) {
-            LogError("cannot read category name");
-            return;
+            LogError("Cannot read category name. Setting an empty string.");
+            m_abstractEvent->getCategories()->push_back("");
+        } else {
+            m_abstractEvent->getCategories()->push_back(categoryName);
         }
-        m_abstractEvent->getCategories()->push_back(categoryName);
     }
 }
 
-void EventWrapper::setIDFromPlatformEvent()
+void EventWrapper::setIdFromPlatformEvent()
 {
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
-    m_abstractEvent->setId(getIDFromPlatformEvent());
+    m_abstractEvent->setId(getIdFromPlatformEvent());
 
-    // Set the uid here.
+    // Set the uid also.
     std::stringstream ss;
-    ss<<getIDFromPlatformEvent();
+    ss<<getIdFromPlatformEvent();
     m_abstractEvent->setUId(ss.str());
 }
 
+void EventWrapper::setParentIdFromPlatformEvent()
+{
+    if (!m_platformEvent) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+       int parentId = calendar_svc_struct_get_int(m_platformEvent,
+               CAL_VALUE_INT_ORIGINAL_EVENT_ID);
+
+    m_abstractEvent->setParentId(parentId);
+}
+
 void EventWrapper::setIsAllDayFromPlatformEvent()
 {
     if (!m_platformEvent) {
@@ -1714,7 +1783,7 @@ void EventWrapper::setLastModifiedDateFromPlatformEvent()
     if (!m_platformEvent) {
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
-    time_t lastModifiedDate = calendar_svc_struct_get_time(
+    std::time_t lastModifiedDate = calendar_svc_struct_get_time(
             m_platformEvent,
             CAL_VALUE_GMT_LAST_MODIFIED_TIME,
             CAL_TZ_FLAG_GMT);
@@ -1786,23 +1855,6 @@ void EventWrapper::setUIdFromPlatformEvent()
     }
 }
 
-void EventWrapper::setRecurrenceIdFromPlatformEvent()
-{
-    if (!m_platformEvent) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-
-    if( (EventRecurrenceRule::DAILY_RECURRENCE <= m_abstractEvent->getRecurrenceRule()->getFrequency() && m_abstractEvent->getRecurrenceRule()->getFrequency() <= EventRecurrenceRule::MONTHLY_ON_DAY_RECURRENCE) ) {
-        time_t recurrenceID = calendar_svc_struct_get_time(
-                m_platformEvent,
-                CAL_VALUE_GMT_START_DATE_TIME,
-                CAL_TZ_FLAG_GMT);
-        m_abstractEvent->setRecurrenceId(recurrenceID);
-    } else {
-        m_abstractEvent->setRecurrenceId(0);
-    }
-}
-
 void EventWrapper::setAttendeesFromPlatformEvent()
 {
     LogDebug("entered");
@@ -1819,38 +1871,40 @@ void EventWrapper::setAttendeesFromPlatformEvent()
         calendar_svc_struct_get_list(m_platformEvent,
                                      CAL_VALUE_LST_ATTENDEE_LIST,
                                      &attendees)) {
-        LogError("cannot read attendees list");
+        LogError("Cannot read attendees list");
         return;
     }
     cal_value* attendee = NULL;
     for (; attendees; attendees = g_list_next(attendees)) {
+        LogDebug("Processing attendee...");
         attendee = static_cast<cal_value*>(attendees->data);
         EventAttendeePtr attendeePtr(new EventAttendee());
 
         // load name
         char* attendeeName = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
         if (NULL == attendeeName) {
-            LogError("cannot read attendee name");
-            return;
+            LogError("Cannot read attendee name. Setting an empty string.");
+            attendeePtr->setName("");
+        } else {
+            attendeePtr->setName(attendeeName);
         }
-        attendeePtr->setName(attendeeName);
 
         // load URI
         char* attendeeURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_EMAIL);
         if (NULL == attendeeURI) {
-            LogError("cannot read attendee URI");
-            return;
+            LogError("Cannot read attendee URI. Setting an empty string.");
+            attendeePtr->setURI("");
+        } else {
+            attendeePtr->setURI(attendeeURI);
         }
-        attendeePtr->setURI(attendeeURI);
 
         // load role
         cal_event_attendee_role_type_t attendeeRole =
-            static_cast<cal_event_attendee_role_type_t>(calendar_svc_struct_get_int(
-                                              m_platformEvent,
+            static_cast<cal_event_attendee_role_type_t>(calendar_svc_value_get_int(
+                                              attendee,
                                               CAL_VALUE_INT_ATTENDEE_ROLE));
         if (0 > attendeeRole) {
-            LogError("cannot read attendee role");
-            return;
+            LogError("Cannot read attendee role. Setting the default value.");
         }
         switch (attendeeRole) {
         case EVENT_ATTENDEE_REQ_PARTICIPANT_ROLE:
@@ -1866,18 +1920,17 @@ void EventWrapper::setAttendeesFromPlatformEvent()
             attendeePtr->setRole(EventAttendee::CHAIR_ROLE);
             break;
         default:
-            attendeePtr->setRole(EventAttendee::CHAIR_ROLE);
+            attendeePtr->setRole(EventAttendee::REQ_PARTICIPANT_ROLE);
             break;
         }
 
         // load status
         cal_event_attendee_status_type_t attendeeStatus =
-            static_cast<cal_event_attendee_status_type_t>(calendar_svc_struct_get_int(
-                                              m_platformEvent,
+            static_cast<cal_event_attendee_status_type_t>(calendar_svc_value_get_int(
+                                              attendee,
                                               CAL_VALUE_INT_ATTENDEE_DETAIL_STATUS));
         if (0 > attendeeStatus) {
-            LogError("cannot read attendee status");
-            return;
+            LogError("Cannot read attendee status. Setting the default value.");
         }
         switch (attendeeStatus) {
         case EVENT_ATTENDEE_NEEDS_ACTION_AT_STATUS:
@@ -1909,19 +1962,17 @@ void EventWrapper::setAttendeesFromPlatformEvent()
         // load RSVP
         int attendeeRSVP = calendar_svc_value_get_int(attendee, CAL_VALUE_INT_ATTENDEE_RSVP);
         if (0 > attendeeRSVP) {
-            LogError("cannot read attendee RSVP");
-            return;
+            LogError("Cannot read attendee RSVP. Setting the default value.");
         }
         attendeePtr->setRSVP(attendeeRSVP>0 ? true : false);
 
         // load type
         cal_event_attendee_type_t attendeeType =
-            static_cast<cal_event_attendee_type_t>(calendar_svc_struct_get_int(
-                                              m_platformEvent,
+            static_cast<cal_event_attendee_type_t>(calendar_svc_value_get_int(
+                                              attendee,
                                               CAL_VALUE_INT_ATTENDEE_DETAIL_TYPE));
         if (0 > attendeeType) {
-            LogError("cannot read attendee type");
-            return;
+            LogError("Cannot read attendee type. Setting the default value.");
         }
         switch (attendeeType) {
         case EVENT_ATTENDEE_INDIVIDUAL_TYPE:
@@ -1947,34 +1998,52 @@ void EventWrapper::setAttendeesFromPlatformEvent()
         // load group
         char* attendeeGroup = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_GROUP);
         if (NULL == attendeeGroup) {
-            LogError("cannot read attendee group");
-            return;
+            LogError("Cannot read attendee group. Setting an empty string.");
+            attendeePtr->setGroup("");
+        } else {
+            attendeePtr->setGroup(attendeeGroup);
         }
-        attendeePtr->setGroup(attendeeGroup);
 
         // load delegatorURI
         char* attendeeDelegatorURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATOR_URI);
         if (NULL == attendeeDelegatorURI) {
-            LogError("cannot read attendee delegatorURI");
-            return;
+            LogError("Cannot read attendee delegatorURI. Setting an empty string.");
+            attendeePtr->setDelegatorURI("");
+        } else {
+            attendeePtr->setDelegatorURI(attendeeDelegatorURI);
         }
-        attendeePtr->setDelegatorURI(attendeeDelegatorURI);
 
         // load delegateURI
         char* attendeeDelegateURI = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DELEGATE_URI);
         if (NULL == attendeeDelegateURI) {
-            LogError("cannot read attendee delegateURI");
-            return;
+            LogError("Cannot read attendee delegateURI. Setting an empty string.");
+            attendeePtr->setDelegateURI("");
+        } else {
+            attendeePtr->setDelegateURI(attendeeDelegateURI);
         }
-        attendeePtr->setDelegateURI(attendeeDelegateURI);
 
         // load contactId
         char* attendeeContactId = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_UID);
         if (NULL == attendeeContactId) {
-            LogError("cannot read attendee UId");
-            return;
+            LogError("Cannot read attendee UId. Setting an empty string.");
+            attendeePtr->setContactId("");
+        } else {
+            attendeePtr->setContactId(attendeeContactId);
         }
-        attendeePtr->setContactId(attendeeContactId);
+
+        // load addressBookId
+        int attendeeAddressBookId = calendar_svc_value_get_int(attendee, CAL_VALUE_INT_ATTENDEE_DETAIL_CT_INDEX);
+        if ( 0>attendeeAddressBookId) {
+            LogError("Cannot read attendee address book id. Setting an empty string.");
+            attendeeAddressBookId = -1;
+        }
+        std::stringstream ss;
+        if (attendeeAddressBookId>=0) {
+            ss<<attendeeAddressBookId;
+        } else {
+            ss<<"";
+        }
+        attendeePtr->setAddressBookId(ss.str());
 
         m_abstractEvent->getAttendees()->push_back(attendeePtr);
     }
@@ -1986,19 +2055,15 @@ void EventWrapper::setPositionFromPlatformEvent()
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
-    CalendarItemGeoPtr geoInfo(new CalendarItemGeo());
-
     double value = calendar_svc_struct_get_double(
             m_platformEvent,
             CAL_VALUE_DBL_LATITUDE);
-    geoInfo->setLatitude(value);
+    m_abstractEvent->setLatitude(value);
 
     value = calendar_svc_struct_get_double(
             m_platformEvent,
             CAL_VALUE_DBL_LONGITUDE);
-    geoInfo->setLongitude(value);
-
-    m_abstractEvent->setGeolocation(geoInfo);
+    m_abstractEvent->setLongitude(value);
 }
 
 void EventWrapper::setPriorityFromPlatformEvent()
@@ -2065,6 +2130,21 @@ void EventWrapper::setProgressFromPlatformEvent()
     m_abstractEvent->setProgress(progress);
 }
 
+void EventWrapper::setIsDetachedFromPlatformEvent()
+{
+    if (!m_platformEvent) {
+        ThrowMsg(UnknownException, "Null platform pointer.");
+    }
+
+    int isDetached = calendar_svc_struct_get_int(m_platformEvent, CAL_VALUE_INT_ORIGINAL_EVENT_ID);
+    if (isDetached>0) {
+        m_abstractEvent->setIsDetached(true);
+        LogInfo("This is a detached event.");
+    } else {
+        m_abstractEvent->setIsDetached(false);
+    }
+}
+
 void EventWrapper::displayAbstractEvent()
 {
     m_abstractEvent->display();
@@ -2074,9 +2154,14 @@ void EventWrapper::displayPlatformEvent()
 {
     LogDebug("event id: " << calendar_svc_struct_get_int(m_platformEvent,
                                                          CAL_VALUE_INT_INDEX));
-    LogDebug("event start time: " << calendar_svc_struct_get_time(
+
+    std::time_t startTime = calendar_svc_struct_get_time(
                  m_platformEvent, CAL_VALUE_GMT_START_DATE_TIME,
-                 CAL_TZ_FLAG_GMT));
+                 CAL_TZ_FLAG_GMT);
+    LogDebug("event start time: " << startTime);
+    tm* startDate = localtime(&startTime);
+    LogDebug("year: "<<startDate->tm_year<<", month: "<<startDate->tm_mon<<", day: "<<startDate->tm_mday<<", hour: "<<startDate->tm_hour);
+
     LogDebug("event end time: " << calendar_svc_struct_get_time(m_platformEvent,
                                                                 CAL_VALUE_GMT_END_DATE_TIME,
                                                                 CAL_TZ_FLAG_GMT));
@@ -2142,14 +2227,31 @@ void EventWrapper::displayPlatformEvent()
 
     LogDebug("event repeat frequency: " << calendar_svc_struct_get_int(
                  m_platformEvent, CAL_VALUE_INT_REPEAT_TERM));
+    LogDebug("event repeat interval: " << calendar_svc_struct_get_int(
+                 m_platformEvent, CAL_VALUE_INT_REPEAT_INTERVAL));
     LogDebug("event repeat occurrence count: " << calendar_svc_struct_get_int(
                  m_platformEvent, CAL_VALUE_INT_REPEAT_OCCURRENCES));
-    LogDebug("event repeat occurrence end date: " << calendar_svc_struct_get_time(
+    LogDebug("event repeat end date: " << calendar_svc_struct_get_time(
                  m_platformEvent, CAL_VALUE_GMT_REPEAT_END_DATE,
                  CAL_TZ_FLAG_GMT));
+
+    GList* exceptionList = NULL;
+    calendar_svc_struct_get_list(m_platformEvent, CAL_VALUE_LST_EXCEPTION_DATE, &exceptionList);
+    cal_value* exceptionValue = NULL;
+    for (; exceptionList; exceptionList = g_list_next(exceptionList)) {
+        exceptionValue = static_cast<cal_value*>(exceptionList->data);
+        std::time_t exceptionTime = calendar_svc_value_get_time(exceptionValue,
+                                                        CAL_VALUE_GMT_EXCEPTION_DATE_TIME,
+                                                        CAL_TZ_FLAG_GMT);
+        if (CAL_ERR_FAIL == exceptionTime) {
+            LogError("cannot read exception time");
+            return;
+        }
+        LogDebug("event repeat exception: "<<exceptionTime);
+    }
 }
 
-Api::Calendar::CalendarEvent::CalendarType EventWrapper::getType()
+CalendarEvent::CalendarType EventWrapper::getType()
 {
     return m_calendarType;
 }
index baaea6a..efca8a7 100755 (executable)
  */
 
 
-#ifndef _EVENT_WRAPPER_H_
-#define _EVENT_WRAPPER_H_
+#ifndef _CALENDAR_EVENT_WRAPPER_H_
+#define _CALENDAR_EVENT_WRAPPER_H_
 
 #include <string>
 #include <calendar-svc-provider.h>
 #include <dpl/shared_ptr.h>
 #include <API/Calendar/CalendarEvent.h>
-#include <API/Calendar/EventFilter.h>
 #include <API/Calendar/EventAttendee.h>
 #include <API/Calendar/EventRecurrenceRule.h>
-#include <API/Calendar/CalendarItemGeo.h>
+
+using namespace TizenApis::Api::Calendar;
 
 namespace TizenApis {
 namespace Platform {
@@ -34,14 +34,14 @@ namespace Calendar {
 class EventWrapper
 {
   public:
-    EventWrapper(Api::Calendar::CalendarEvent::CalendarType type = Api::Calendar::CalendarEvent::EVENT_TYPE);
-    explicit EventWrapper(const Api::Calendar::CalendarEventPtr &event, Api::Calendar::CalendarEvent::CalendarType type = Api::Calendar::CalendarEvent::EVENT_TYPE);
-    explicit EventWrapper(cal_struct *event, Api::Calendar::CalendarEvent::CalendarType type = Api::Calendar::CalendarEvent::EVENT_TYPE);
+    EventWrapper(CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE);
+    explicit EventWrapper(const CalendarEventPtr &event, CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE);
+    explicit EventWrapper(cal_struct *event, CalendarEvent::CalendarType type = CalendarEvent::EVENT_TYPE);
     virtual ~EventWrapper();
     cal_struct  *convertAbstractEventToPlatformEvent();
-    Api::Calendar::CalendarEventPtr convertPlatformEventToAbstractEvent();
+    CalendarEventPtr convertPlatformEventToAbstractEvent();
     cal_struct* getPlatformEvent() const;
-    Api::Calendar::CalendarEventPtr getAbstractEvent() const;
+    CalendarEventPtr getAbstractEvent() const;
     void        freePlatformEvent();
     void        saveEvent();
     void        loadEvent(int id);
@@ -52,8 +52,12 @@ class EventWrapper
        void setCalendarId(const std::string &value);
        void setCalendarAccountId(const int value);
 
+    void displayAbstractEvent();     //only for debugging
+    void displayPlatformEvent();     //only for debugging
+
   protected:
-    int  getIDFromPlatformEvent() const;
+    int  getIdFromPlatformEvent() const;
+
     void setDescriptionToPlatformEvent();
     void setSummaryToPlatformEvent();
     void setStartTimeToPlatformEvent();
@@ -63,7 +67,8 @@ class EventWrapper
     void setAlarmsToPlatformEvent();
     void setStatusToPlatformEvent();
     void setCategoriesToPlatformEvent();
-    void setIDToPlatformEvent();
+    void setIdToPlatformEvent();
+    void setParentIdToPlatformEvent();
     void setIsAllDayToPlatformEvent();
     void setOrganizerToPlatformEvent();
     void setLastModifiedDateToPlatformEvent();
@@ -86,29 +91,28 @@ class EventWrapper
     void setAlarmsFromPlatformEvent();
     void setStatusFromPlatformEvent();
     void setCategoriesFromPlatformEvent();
-    void setIDFromPlatformEvent();
+    void setIdFromPlatformEvent();
+    void setParentIdFromPlatformEvent();
     void setIsAllDayFromPlatformEvent();
     void setOrganizerFromPlatformEvent();
     void setLastModifiedDateFromPlatformEvent();
     void setVisibilityFromPlatformEvent();
     void setAvailabilityFromPlatformEvent();
     void setUIdFromPlatformEvent();
-    void setRecurrenceIdFromPlatformEvent();
     void setAttendeesFromPlatformEvent();
     void setPositionFromPlatformEvent();
        void setPriorityFromPlatformEvent();
        void setCreatedDateFromPlatformEvent();
        void setCompletedDateFromPlatformEvent();
        void setProgressFromPlatformEvent();
+       void setIsDetachedFromPlatformEvent();
 
   private:
-    void displayAbstractEvent();     //only for debugging
-    void displayPlatformEvent();     //only for debugging
-    Api::Calendar::CalendarEvent::CalendarType getType();
+    CalendarEvent::CalendarType getType();
 
     cal_struct             *m_platformEvent;
-    Api::Calendar::CalendarEventPtr m_abstractEvent;
-    Api::Calendar::CalendarEvent::CalendarType    m_calendarType;
+    CalendarEventPtr m_abstractEvent;
+    CalendarEvent::CalendarType    m_calendarType;
     std::string m_calendarId;
     int m_calendarAccountId;
 };
@@ -118,4 +122,4 @@ typedef DPL::SharedPtr<EventWrapper> EventWrapperPtr;
 }
 }
 }
-#endif /* _EVENT_WRAPPER_H_ */
+#endif /* _CALENDAR_EVENT_WRAPPER_H_ */
index 3f34a74..0c095e5 100755 (executable)
@@ -88,6 +88,7 @@ bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistory
        StringArrayPtr stringArray(new StringArray());
        RemotePartyPtr remoteParty(new RemoteParty());
        RemotePartyListPtr remotePartyList(new RemotePartyList());
+       Api::Contact::ContactRefPtr contactRef(new Api::Contact::ContactRef());
 
        std::string callType("");
        std::string tags("");
@@ -163,16 +164,14 @@ bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistory
                return false;
        }
 
-       std::stringstream contactId;
-       contactId << query_log->contact_db_id;
-
        callHistoryItem->setEntryId(query_log->calllog_db_id);
        callHistoryItem->setCallType(callType);
        stringArray->push_back(tags);
        callHistoryItem->setTags(stringArray);
 
        remoteParty->setRemoteParty(number);
-       remoteParty->setContactId(contactId.str());
+       contactRef->setContactId(query_log->contact_db_id);
+       remoteParty->setContactRef(contactRef);
        remotePartyList->push_back(remoteParty);
        callHistoryItem->setRemoteParties(remotePartyList);
 
@@ -225,11 +224,11 @@ long CallHistory::addListener(const EventCallHistoryListenerEmitterPtr& emitter)
                if (ret == CTS_SUCCESS) {
                        CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
                        std::string query(STR_BASE_QUERY);
-                       query.append(" WHERE log_type <= 12 ORDER BY log_time DESC LIMIT 1");
+                       query.append(" WHERE log_type <= 12 ORDER BY id DESC LIMIT 1");
                        executeQuery(query, callHistoryListPtr);
 
                        if (callHistoryListPtr->size() > 0) {
-                               watcher->setCurrentLogTime((*callHistoryListPtr)[0]->getStartTime());
+                               watcher->setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
                        }
                }
 
@@ -266,19 +265,20 @@ void CallHistory::addedListenerCB(void *user_data)
 {
        CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
        std::string query(STR_BASE_QUERY);
-       query.append(" WHERE  log_type <= 12 AND log_time > ");
 
-       std::stringstream currentLogTime;
-       currentLogTime << static_cast<int>(((CallHistory::Watcher*)user_data)->getCurrentLogTime());
-       query.append(currentLogTime.str());
+       query.append(" WHERE  log_type <= 12 AND id > ");
+
+       std::stringstream currentLogId;
+       currentLogId << static_cast<int>(((CallHistory::Watcher*)user_data)->getCurrentLogId());
+       query.append(currentLogId.str());
+       query.append(" ORDER BY id DESC");
 
-       query.append(" ORDER BY log_time DESC");
        ((CallHistory::Watcher*)user_data)->executeQuery(query, callHistoryListPtr);
 
        if (callHistoryListPtr->size() > 0) {
-               ((CallHistory::Watcher*)user_data)->addMissedCall(callHistoryListPtr);
-               ((CallHistory::Watcher*)user_data)->setCurrentLogTime((*callHistoryListPtr)[callHistoryListPtr->size() - 1]->getStartTime());
+               ((CallHistory::Watcher*)user_data)->setCurrentLogId((*callHistoryListPtr)[0]->getEntryId());
                ((CallHistory::Watcher*)user_data)->stateHasChanged(callHistoryListPtr, EventCallHistoryListener::ADDED);
+               ((CallHistory::Watcher*)user_data)->addMissedCall(callHistoryListPtr);
        }
 }
 
@@ -471,6 +471,7 @@ void CallHistory::OnRequestReceived(const EventRemoveBatchPtr& event)
                        ret = calllog_delete_from_db(static_cast<int>(entryIds[cnt]));
                        if (ret != CALLLOG_ERROR_NONE) {
                                event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+                               break;
                        }
                }
        } catch (const Commons::PlatformException& ex) {
@@ -496,7 +497,7 @@ void CallHistory::OnRequestReceived(const EventRemoveAllPtr& event)
 CallHistory::Watcher::Watcher(int handle, const Api::Call::EventCallHistoryListenerEmitterPtr& emitter) :
                        m_handle(handle),
                        m_emitter(emitter),
-                       m_currentLogTime(0)
+                       m_currentLogId(0)
 {
        m_missedCallList = MissedCallListPtr(new MissedCallList());
        _db_init();
index 63e1c7b..d850da8 100755 (executable)
@@ -60,7 +60,7 @@ public:
        private:
                int m_handle;
                Api::Call::EventCallHistoryListenerEmitterPtr m_emitter;
-               time_t m_currentLogTime;
+               unsigned int m_currentLogId;
                Platform::Call::MissedCallListPtr m_missedCallList;
 
        public:
@@ -77,14 +77,14 @@ public:
                        return m_handle;
                }
 
-               void setCurrentLogTime(time_t logTime)
+               void setCurrentLogId(unsigned int logId)
                {
-                       m_currentLogTime = logTime;
+                       m_currentLogId = logId;
                }
 
-               time_t getCurrentLogTime()
+               unsigned int getCurrentLogId()
                {
-                       return m_currentLogTime;
+                       return m_currentLogId;
                }
 
                void setMissedCallList(const Platform::Call::MissedCallListPtr &missedCallList)
index 2f48427..4d1c797 100755 (executable)
@@ -109,7 +109,7 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (attrName.compare(STR_RP_REMOTEPARTY) == 0) {
                name = F_NUMBER;
-       } else if (attrName.compare(STR_RP_CONTACTID) == 0) {
+       } else if (attrName.compare(STR_RP_CONTACTREF) == 0) {
                name = F_RELATED_ID;
        } else if (attrName.compare(STR_START_TIME) == 0) {
                name = F_LOG_TIME;      
@@ -224,7 +224,7 @@ std::string CallHistoryFilter::convertAttribute(std::string &name, AnyPtr& value
                }
        } else if (name.compare(STR_RP_REMOTEPARTY) == 0) {
                query = F_LEFT_BRACKET + F_NUMBER + F_EQUAL + F_S_QUOTATION + value->toString() + F_S_QUOTATION + F_RIGHT_BRACKET;
-       } else if (name.compare(STR_RP_CONTACTID) == 0) {
+       } else if (name.compare(STR_RP_CONTACTREF) == 0) {
                query = F_LEFT_BRACKET + F_RELATED_ID + F_EQUAL + F_S_QUOTATION + value->toString() + F_S_QUOTATION + F_RIGHT_BRACKET;
        } else if (name.compare(STR_START_TIME) == 0) {
                std::string dateStr ("");
index 6666187..438220b 100755 (executable)
 #include <Commons/Exception.h>
 #include <call.h>
 #include <dpl/log/log.h>
-#include <API/Account/AccountServices.h>
 #include <API/Call/CallDefine.h>
 #include "CallManager.h"
 
 using namespace WrtDeviceApis::Commons;
 using namespace TizenApis::Api::Call;
-using namespace TizenApis::Api::Account;
 using namespace DPL;
 
 namespace TizenApis {
@@ -68,77 +66,6 @@ bool CallManager::isCallInProgress()
 
 }
 
-void CallManager::getCallService(const EventGetCallServicePtr& event)
-{
-       EventRequestReceiver<EventGetCallService>::PostRequest(event);
-}
-
-void CallManager::OnRequestReceived(const EventGetCallServicePtr& event)
-{
-       try {
-               event->switchToManualAnswer();
-
-               CallServiceFilterPtr filter(event->getFilter());
-               if (filter->getServiceName().size() > 0) {
-                       ThrowMsg(UnsupportedException, "Not supported filter : serviceName");
-               }
-
-               if (filter->getProviderId().size() > 0) {
-                       ThrowMsg(UnsupportedException, "Not supported filter : providerId");
-               }
-
-               std::string typeId(filter->getCallType());
-               StringArrayPtr tags(filter->getTags());
-
-               if (typeId.compare(STR_TIZEN_TEL) != 0
-                       && typeId.compare(STR_TIZEN_XMPP) != 0
-                       && typeId.compare(STR_TIZEN_SIP) != 0
-                       && typeId.compare("") != 0) {
-                       ThrowMsg(InvalidArgumentException, "Invalid value : ServiceTypeId");
-               }
-
-               size_t cnt = 0;
-               for (; cnt < tags->size(); cnt++) {
-                       if (((*tags)[cnt]).compare(STR_CALL) != 0
-                               &&((*tags)[cnt]).compare(STR_CALL_VOICE) != 0
-                               && ((*tags)[cnt]).compare(STR_CALL_VIDEO) != 0
-                               && ((*tags)[cnt]).compare(STR_CALL_EMERGENCY) != 0)  {
-                               ThrowMsg(InvalidArgumentException, "Invalid value : tags");
-                       }
-               }
-
-               AccountServicesArrayPtr accountServicesList(new AccountServicesArray());
-               AccountServicesPtr callServices(new AccountServices());
-
-               if (typeId.compare(STR_TIZEN_XMPP) == 0
-                       || typeId.compare(STR_TIZEN_SIP) == 0) {
-                       event->setResult(accountServicesList);
-                       EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
-               }
-
-               callServices->setServiceTypeId(STR_TIZEN_TEL);
-               StringArrayPtr supportTags(new StringArray());
-               supportTags->push_back(STR_CALL_VOICE);
-               supportTags->push_back(STR_CALL_VIDEO);
-               supportTags->push_back(STR_CALL_EMERGENCY);
-               callServices->setTags(*supportTags);
-               callServices->setApplicationId(STR_TIZEN_DIALER);
-
-               accountServicesList->push_back(callServices);
-               event->setResult(accountServicesList);
-
-               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
-       } catch (const InvalidArgumentException& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
-               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
-       } catch (const PlatformException& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ExceptionCodes::PlatformException);
-               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
-       }
-}
-
 }
 }
 }
index 655b534..9d21daa 100755 (executable)
@@ -24,7 +24,6 @@
 #include <TapiCommon.h>
 #include <API/Call/ICallManager.h>
 #include <API/Call/CallFactory.h>
-#include <API/Call/EventGetCallService.h>
 #include <app.h>
 
 namespace TizenApis {
@@ -43,15 +42,6 @@ public:
        * active, held, dialing, alerting, incoming, or waiting; otherwise false.
        */
        bool isCallInProgress();
-
-       /**
-        * Synchronously get call services instances.
-        */
-       void getCallService(const Api::Call::EventGetCallServicePtr& event);
-
-protected:
-       void OnRequestReceived(const Api::Call::EventGetCallServicePtr& event);
-
 };
 
 }
diff --git a/src/platform/Tizen/Call/CallService.cpp b/src/platform/Tizen/Call/CallService.cpp
deleted file mode 100755 (executable)
index a64947f..0000000
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#include <cassert>
-#include <Commons/Exception.h>
-#include <ITapiCall.h>
-#include <ITapiSs.h>
-#include <ITapiSim.h>
-#include <call.h>
-#include <dpl/log/log.h>
-#include <API/Call/CallDefine.h>
-#include "CallService.h"
-
-using namespace WrtDeviceApis::Commons;
-using namespace TizenApis::Api::Call;
-using namespace DPL;
-
-namespace TizenApis {
-namespace Platform {
-namespace Call {
-
-namespace {
-static void callAsyncCB(TelTapiEvent_t *event, void *userdata)
-{
-       if (event == NULL || userdata == NULL) {
-               return;
-       }
-
-       (static_cast<CallService*>(userdata))->changedEvent(static_cast<void*>(event));
-}
-}
-
-CallService::CallService() : m_lockSendUSSD(false)
-{
-       m_handles = handleListPtr(new handleList());
-       if (tel_init() == TAPI_API_SUCCESS) {
-               LogDebug("TAPI init success");
-               std::string widget("org.tizen.widget");
-               tel_register_app_name((char*)(widget.c_str()));
-       }
-}
-
-CallService::~CallService()
-{
-       deregisterCallEvent();
-       tel_deinit();
-}
-
-void CallService::registerCallEvent()
-{
-       TapiResult_t api_err = TAPI_API_SUCCESS;
-       unsigned int handle = 0;
-
-       int call_event_list[] =
-       {
-               TAPI_EVENT_SS_USSD_CNF,
-       };
-
-       int num_event = sizeof(call_event_list)/sizeof(int);
-       for (int index = 0 ; index < num_event; index++) {
-               api_err = (TapiResult_t)tel_register_event(call_event_list[index], &handle, (TelAppCallback)&callAsyncCB, this);
-               m_handles->push_back(handle);
-       }
-       LogDebug("register TAPI event count[" << m_handles->size() << "]");
-}
-
-void CallService::deregisterCallEvent()
-{
-       std::vector<unsigned int>::iterator it = m_handles->begin();
-
-       for (;it < m_handles->end();) {
-               tel_deregister_event((*it));
-               it = CallService::m_handles->erase(it);
-               ++it;
-       }
-       LogDebug("The handle of TAPI event is removed. (" << m_handles->size() << ")");
-}
-
-void CallService::launchDialer(const EventLaunchDialerPtr& event)
-{
-       EventRequestReceiver<EventLaunchDialer>::PostRequest(event);
-}
-
-void CallService::sendUSSD(const EventSendUSSDPtr& event)
-{
-       EventRequestReceiver<EventSendUSSD>::PostRequest(event);
-}
-
-StringListPtr CallService::getVoicemailNumbers()
-{
-       StringListPtr numberList = StringListPtr(new StringList());
-       TelSimMailboxNumbers_s mbox;
-
-       if (tel_get_sim_mailbox_info(&mbox) != TAPI_API_SUCCESS) {
-               return numberList;
-       }
-
-       if (mbox.voice_line1.bUsed != 0) {
-               std::string DiallingNum1(mbox.voice_line1.DiallingNum);
-               if (DiallingNum1.size() > 0)
-                       numberList->push_back(DiallingNum1);
-       }
-
-       if (mbox.voice_line2.bUsed != 0) {
-               std::string DiallingNum2(mbox.voice_line2.DiallingNum);
-               if (DiallingNum2.size() > 0)
-                       numberList->push_back(DiallingNum2);
-       }
-
-       if (mbox.video.bUsed != 0) {
-               std::string DiallingNum3(mbox.video.DiallingNum);
-               if (DiallingNum3.size() > 0)
-                       numberList->push_back(DiallingNum3);
-       }
-
-       if (mbox.fax.bUsed != 0) {
-               std::string DiallingNum4(mbox.fax.DiallingNum);
-               if (DiallingNum4.size() > 0)
-                       numberList->push_back(DiallingNum4);
-       }
-
-       if (mbox.email.bUsed != 0) {
-               std::string DiallingNum5(mbox.email.DiallingNum);
-               if (DiallingNum5.size() > 0)
-                       numberList->push_back(DiallingNum5);
-       }
-
-       LogDebug("return voicemail Numbers count [" << numberList->size() << "]");
-       return numberList;
-
-}
-
-StringListPtr CallService::getSubscriberNumbers()
-{
-       StringListPtr numberList = StringListPtr(new StringList());
-       TelSimSubscriberInfo_t msisdn;
-
-       if (tel_get_sim_msisdn(&msisdn) != TAPI_API_SUCCESS) {
-               return numberList;
-       }
-
-       std::string sub1(msisdn.num);
-       if (sub1.size() > 0)
-               numberList->push_back(sub1);
-
-       LogDebug("return subscriber count [" << numberList->size() << "]");
-       return numberList;
-}
-
-StringListPtr CallService::getEmergencyNumbers()
-{
-       StringListPtr eccNumber = StringListPtr(new StringList());
-       TelSimCardType_t cardType;
-       TelSimEccData_t eccData;
-       int eccCount = 0;
-
-       if (tel_get_sim_type(&cardType) != TAPI_API_SUCCESS) {
-               return eccNumber;
-       }
-
-       if (tel_get_sim_ecc(&eccData, &eccCount) != TAPI_API_SUCCESS) {
-               return eccNumber;
-       }
-
-       LogDebug("eccCount [" << eccCount << "] cardType[" << cardType <<"]");
-
-       if (eccCount > 0) {
-               if (cardType == TAPI_SIM_CARD_TYPE_GSM) {
-                       std::string ecc1 (eccData.EccInfo.szEcc1);
-                       std::string ecc2 (eccData.EccInfo.szEcc2);
-                       std::string ecc3 (eccData.EccInfo.szEcc3);
-                       std::string ecc4 (eccData.EccInfo.szEcc4);
-                       std::string ecc5 (eccData.EccInfo.szEcc5);
-
-                       if (ecc1.size() > 0)
-                               eccNumber->push_back(ecc1);
-                       if (ecc2.size() > 0)
-                               eccNumber->push_back(ecc2);
-                       if (ecc3.size() > 0)
-                               eccNumber->push_back(ecc3);
-                       if (ecc4.size() > 0)
-                               eccNumber->push_back(ecc4);
-                       if (ecc5.size() > 0)
-                               eccNumber->push_back(ecc5);
-               } else if (cardType == TAPI_SIM_CARD_TYPE_USIM) {
-                       for (int cnt = 0; cnt < eccCount; cnt++) {
-                               std::string ecc (eccData.UeccInfo[cnt].szEcc);
-                               if (ecc.size() > 0)
-                                       eccNumber->push_back(ecc);
-                       }
-               }
-       }
-
-       LogDebug("return ecc count [" << eccNumber->size() << "]");
-       return eccNumber;
-}
-
-void CallService::OnRequestReceived(const EventLaunchDialerPtr& event)
-{
-       try {
-               event->switchToManualAnswer();
-
-               std::string remoteParty(STR_TEL_URI);
-               remoteParty.append(event->getRemoteParty());
-               remoteParty.append(event->getExtension());
-
-               service_h service;
-               service_create(&service);
-
-               service_set_operation(service, SERVICE_OPERATION_DEFAULT);
-               service_set_package(service, event->getAppId().c_str());
-
-               service_set_uri(service, remoteParty.c_str());
-
-               if (service == NULL) {
-                       ThrowMsg(WrtDeviceApis::Commons::UnknownException, "Unknown exception");
-               }
-
-               int result = service_send_launch_request (service, NULL, NULL);
-
-               if (result != SERVICE_ERROR_NONE) {
-                       switch (result){
-                       case SERVICE_ERROR_INVALID_PARAMETER:
-                               LogDebug("service_send_launch_request returns SERVICE_ERROR_INVALID_PARAMETER");
-                               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
-                               break;
-                       case SERVICE_ERROR_OUT_OF_MEMORY:
-                               LogDebug("service_send_launch_request returns SERVICE_ERROR_OUT_OF_MEMORY");
-                               event->setExceptionCode(ExceptionCodes::PlatformException);
-                               break;
-                       case SERVICE_ERROR_APP_NOT_FOUND:
-                               LogDebug("service_send_launch_request returns SERVICE_ERROR_APP_NOT_FOUND");
-                               event->setExceptionCode(ExceptionCodes::NotFoundException);
-                               break;
-                       default:
-                               LogDebug("service_send_launch_request returns UNKNOWN ERROR!!!");
-                               event->setExceptionCode(ExceptionCodes::UnknownException);
-                               break;
-                       }
-               } else {
-                       LogDebug("service_send_launch_request successful");
-               }
-
-               EventRequestReceiver<EventLaunchDialer>::ManualAnswer(event);
-               service_destroy(service);
-       } catch (const PlatformException& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setExceptionCode(ExceptionCodes::PlatformException);
-               EventRequestReceiver<EventLaunchDialer>::ManualAnswer(event);
-       }
-}
-
-void CallService::OnRequestReceived(const EventSendUSSDPtr& event)
-{
-       try {
-               event->switchToManualAnswer();
-               if (m_lockSendUSSD == false) {
-                       m_lockSendUSSD = true;
-                       m_EventSendUSSDPtr = event;
-               } else {
-                       event->setExceptionCode(ExceptionCodes::PlatformException);
-                       EventRequestReceiver<EventSendUSSD>::ManualAnswer(event);
-               }
-
-               registerCallEvent();
-
-               int reqId = 0;
-               TelSsUssdMsgInfo_t ussdInfo;
-
-               std::string cmd(m_EventSendUSSDPtr->getCommand());
-
-               ussdInfo.UssdStringLength = (int)cmd.size();
-               if (ussdInfo.UssdStringLength >= TAPI_SS_USSD_DATA_SIZE_MAX) {
-                       ussdInfo.UssdStringLength = TAPI_SS_USSD_DATA_SIZE_MAX - 1;
-               }
-               cmd.copy(ussdInfo.szUssdString, (size_t)(ussdInfo.UssdStringLength), 0);
-
-               int ret = tel_send_ss_ussd_request(&ussdInfo, &reqId);
-
-               if (ret != TAPI_API_SUCCESS) {
-                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Platform exception");
-               }
-
-       } catch (const PlatformException& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               m_EventSendUSSDPtr->setExceptionCode(ExceptionCodes::PlatformException);
-               EventRequestReceiver<EventSendUSSD>::ManualAnswer(m_EventSendUSSDPtr);
-               m_lockSendUSSD = false;
-       }
-}
-
-void CallService::changedEvent(void *data)
-{
-       TelTapiEvent_t *tapiEvent = (TelTapiEvent_t *)data;
-
-       switch (tapiEvent->EventClass) {
-       case TAPI_EVENT_CLASS_SS:
-       {
-               switch(tapiEvent->EventType) {
-               case TAPI_EVENT_SS_USSD_CNF:
-               {
-                       TelSsUssdMsgIndInfo_t ussdRecord;
-                       std::string result("");
-
-                       if (tapiEvent->pData != NULL) {
-                               memcpy(&ussdRecord, (TelSsUssdMsgIndInfo_t *)tapiEvent->pData, sizeof(TelSsUssdMsgInfo_t));
-                               result.append(ussdRecord.UssdInfo.szUssdString, ussdRecord.UssdInfo.UssdStringLength);
-                               m_EventSendUSSDPtr->setResult(result);
-                       } else {
-                               m_EventSendUSSDPtr->setExceptionCode(ExceptionCodes::PlatformException);
-                       }
-
-                       deregisterCallEvent();
-                       EventRequestReceiver<EventSendUSSD>::ManualAnswer(m_EventSendUSSDPtr);
-                       m_lockSendUSSD = false;
-               }
-               break;
-               default :
-                       break;
-               }
-       }
-       break;
-       default :
-               break;
-       }
-}
-
-}
-}
-}
-
diff --git a/src/platform/Tizen/Call/CallService.h b/src/platform/Tizen/Call/CallService.h
deleted file mode 100755 (executable)
index 899fb18..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#ifndef TIZENAPIS_PLATFORM_CALLSERVICE_H_
-#define TIZENAPIS_PLATFORM_CALLSERVICE_H_
-
-#include <map>
-#include <vector>
-#include <dpl/shared_ptr.h>
-#include <dpl/noncopyable.h>
-#include <TapiCommon.h>
-#include <API/Call/ICallService.h>
-#include <API/Call/CallFactory.h>
-#include <API/Call/EventLaunchDialer.h>
-#include <API/Call/EventSendUSSD.h>
-#include <app.h>
-
-namespace TizenApis {
-namespace Platform {
-namespace Call {
-
-typedef std::vector<unsigned int> handleList;
-typedef DPL::SharedPtr<handleList> handleListPtr;
-
-class CallService : public Api::Call::ICallService
-{
-public:
-       CallService();
-       ~CallService();
-
-       void registerCallEvent();
-       void deregisterCallEvent();
-
-       /**
-        * Asynchronously launches the native phone application for this call service with a pre-filled remote ID.
-        * The user still needs to press the call button to make the call.
-        */
-       void launchDialer(const Api::Call::EventLaunchDialerPtr& event);
-
-       /**
-        * Send a USSD string to the network.
-        */
-       void sendUSSD(const Api::Call::EventSendUSSDPtr& event);
-
-       /**
-        * Get voicemail numbers.
-        * @return A list of voicemail numbers.
-        */
-       Api::Call::StringListPtr getVoicemailNumbers();
-
-       /**
-        * Get subscriber numbers.
-        * @return A list of subscriber numbers.
-        */
-       Api::Call::StringListPtr getSubscriberNumbers();
-
-       /**
-        * Get emergency numbers.
-        * @return A list of emergency numbers.
-        */
-       Api::Call::StringListPtr getEmergencyNumbers();
-
-       void changedEvent(void *data);
-
-       void launchDialerManualAnswer(service_h request, service_h reply, service_result_e result);
-
-protected:
-       void OnRequestReceived(const Api::Call::EventLaunchDialerPtr& event);
-       void OnRequestReceived(const Api::Call::EventSendUSSDPtr& event);
-
-private:
-       handleListPtr m_handles;
-       Api::Call::EventSendUSSDPtr m_EventSendUSSDPtr;
-       bool m_lockSendUSSD;
-};
-
-}
-}
-}
-
-#endif
index ce5e904..0917e96 100755 (executable)
@@ -1,5 +1,4 @@
 get_current_path()
-pkg_search_module(account REQUIRED accounts-svc)
 pkg_search_module(tapi REQUIRED tapi)
 pkg_search_module(contacts-service REQUIRED contacts-service)
 pkg_search_module(capicall REQUIRED capi-telephony-call)
@@ -10,7 +9,6 @@ pkg_search_module(libpcrecpp REQUIRED libpcrecpp)
 
 
 set(INCLUDES_PLATFORM_IMPLEMENTATION_CALL
-  ${account_INCLUDE_DIRS}
   ${tapi_INCLUDE_DIRS}
   ${contacts-service_INCLUDE_DIRS}
   ${capicall_INCLUDE_DIRS}
@@ -22,7 +20,6 @@ set(INCLUDES_PLATFORM_IMPLEMENTATION_CALL
 )
 
 set(LIBS_PLATFORM_IMPLEMENTATION_CALL
-  ${account_LIBRARIES}
   ${tapi_LIBRARIES}
   ${contacts-service_LIBRARIES}
   ${capicall_LIBRARIES}
@@ -39,6 +36,5 @@ set(SRCS_PLATFORM_IMPLEMENTATION_CALL
   ${CURRENT_PATH}/CallHistoryFilter.cpp
   ${CURRENT_PATH}/CallHistoryQuery.c
   ${CURRENT_PATH}/CallManager.cpp
-  ${CURRENT_PATH}/CallService.cpp
   PARENT_SCOPE
 )
index ab66928..4ce59e3 100755 (executable)
@@ -34,6 +34,7 @@
 #include <API/Contact/IAddressBook.h>
 #include <API/Contact/IContact.h>
 #include "AddressBook.h"
+#include "Contact.h"
 #include "ContactWrapper.h"
 #include "ContactSearchEngine.h"
 #include "ContactFilterValidator.h"
@@ -50,7 +51,8 @@ using namespace std;
 
 AddressBook::AddressBook(IAddressBook::AddressBookType changeType) :
                IAddressBook(changeType),
-               m_name("TEST_ADDRESS_BOOK")
+               m_name("TEST_ADDRESS_BOOK"),
+               m_watchIdAcc(0)
 {
     LogDebug("entered");
 }
@@ -59,96 +61,91 @@ AddressBook::~AddressBook()
 {
 }
 
-ContactPtr AddressBook::get(const std::string &contactId)
+void AddressBook::OnRequestReceived(const EventAddressBookGetPtr &event)
 {
        LogDebug("entered");
 
-       return internalGetById(contactId);
-}
+       Try     {
+               if(!event->getIdIsSet())
+                       ThrowMsg(InvalidArgumentException, "Invalid contact id");
 
-void AddressBook::add(const ContactPtr &contact)
-{
-       LogDebug("entered");
-       if(!contact)
-               ThrowMsg(InvalidArgumentException, "Contact argument is wrong");
+               string contactId = event->getId();
 
-       internalAddContact(contact);
+               ContactPtr contact = internalGetById(contactId);
 
-       string id = contact->getId();
-       if(id != "")
-       {
-               ContactPtr insertedContact = internalGetById(id);
-               contact->copy(insertedContact);
-       }
+               event->setContact(contact);
+               event->setResult(true);
 
-       //m_latestVersion = get_contact_version();
-}
+       } Catch (NotFoundException) {
+               LogError("Contact doesn't exist : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::NotFoundException);
+               event->setResult(false);
 
-void AddressBook::update(const ContactPtr &contact)
-{
-       LogDebug("entered");
-       if(!contact)
-               ThrowMsg(InvalidArgumentException, "Contact argument is wrong");
+       } Catch (PlatformException) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
 
-       internalAddContact(contact);
-       //m_latestVersion = get_contact_version();
+       } Catch (InvalidArgumentException) {
+               LogError("Invalid Arguments : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               event->setResult(false);
+
+       } Catch(Exception) {
+               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::UnknownException);
+               event->setResult(false);
+       }
 }
 
-void AddressBook::remove(const string &id)
+void AddressBook::OnRequestReceived(const EventAddressBookAddPtr &event)
 {
        LogDebug("entered");
-       int contactId;
 
-       try {
-               istringstream iss(id);
-               iss >> contactId;
-       } catch (...) {
-               ThrowMsg(InvalidArgumentException, "Id changeType is wrong.");
-       }
+       ContactPtr contact(NULL);
 
        Try {
-               internalDeleteContactById(contactId);
-       } Catch (NotFoundException) {
-               LogError("Contact (id:" << contactId << ") does not exist.");
-               ThrowMsg(NotFoundException, "Contact (id:" << contactId << ") does not exist.");
-       } Catch (PlatformException) {
-               LogError("Error during deleting contact. " << _rethrown_exception.GetMessage());
-               ThrowMsg(PlatformException, "Error during deleting contact.");
-       }
-       //m_latestVersion = get_contact_version();
-}
+               if(!event->getContactIsSet())
+                       ThrowMsg(InvalidArgumentException, "Contacts were not set.");
 
-long AddressBook::addChangeListener(const EventAddressBookChangeListenerEmitterPtr &emitter)
-{
-       DPL::Mutex::ScopedLock lock(&m_addressBookEmittersMutex);
+               contact = event->getContact();
+               if(!contact)
+                       ThrowMsg(InvalidArgumentException, "No contacts.");
 
-       if(m_addressBookEmitters.size() == 0)
-       {
-               m_latestVersion = get_contact_version();
-               contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
-                               contactsSvcContactChangedCallback, reinterpret_cast<void *>(this));
-               contacts_svc_subscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_CHANGE,
-                               refresh_addressbook_list, reinterpret_cast<void *>(this));
+       } Catch(InvalidArgumentException) {
+               LogError("Invalid arguments for adding contacts : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               return;
        }
 
-       m_addressBookEmitters.attach(emitter);
-
-    return static_cast<long>(emitter->getId());
-}
-
-void AddressBook::removeChangeListener(const long watchId)
-{
-       DPL::Mutex::ScopedLock lock(&m_addressBookEmittersMutex);
-       m_addressBookEmitters.detach(watchId);
-
-       if(m_addressBookEmitters.size() == 0)
+       Try
        {
-               m_latestVersion = 0;
-               contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
-                               contactsSvcContactChangedCallback);
-               contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_CHANGE,
-                               refresh_addressbook_list);
+               internalAddContact(contact);
+
+               string id = contact->getId();
+               if(id != "")
+               {
+                       ContactPtr insertedContact = internalGetById(id);
+                       contact->copy(insertedContact);
+               }
+       }
+       Catch (PlatformException) {
+               LogError("Error during adding contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
+       Catch (Exception) {
+               LogError("Error during adding contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::UnknownException);
+               return;
        }
+       //m_latestVersion = get_contact_version();
+
+       event->setResult(true);
+       event->setExceptionCode(ExceptionCodes::None);
 }
 
 void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event)
@@ -185,7 +182,7 @@ void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event)
 
                        internalAddContact(contact);
                }
-               contacts_svc_end_trans(true);
+               ret = contacts_svc_end_trans(true);
                if (ret < 0) {
                        LogError("error code " << ret);
                        ThrowMsg(PlatformException, "Error during executing contacts_svc_end_trans()");
@@ -218,6 +215,61 @@ void AddressBook::OnRequestReceived(const EventAddressBookAddBatchPtr &event)
                event->setExceptionCode(ExceptionCodes::PlatformException);
                return;
        }
+       Catch (Exception) {
+               contacts_svc_end_trans(false);
+               LogError("Error during adding contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
+       //m_latestVersion = get_contact_version();
+
+       event->setResult(true);
+       event->setExceptionCode(ExceptionCodes::None);
+}
+
+void AddressBook::OnRequestReceived(const EventAddressBookUpdatePtr &event)
+{
+       ContactPtr contact(NULL);
+
+       Try {
+               if(!event->getContactIsSet())
+                       ThrowMsg(InvalidArgumentException, "Contacts were not set.");
+
+               contact = event->getContact();
+               if(!contact)
+                       ThrowMsg(InvalidArgumentException, "No contacts.");
+
+       } Catch(InvalidArgumentException) {
+               LogError("Invalid arguments for adding contacts : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               return;
+       }
+
+       Try
+       {
+               internalAddContact(contact);
+       }
+       Catch (NotFoundException)
+       {
+               LogError("Contact doesn't exist : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::NotFoundException);
+               return;
+       }
+       Catch (PlatformException) {
+               LogError("Error during adding contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
+       Catch (Exception) {
+               LogError("Error during adding contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
        //m_latestVersion = get_contact_version();
 
        event->setResult(true);
@@ -279,12 +331,73 @@ void AddressBook::OnRequestReceived(const EventAddressBookUpdateBatchPtr &event)
                event->setExceptionCode(ExceptionCodes::PlatformException);
                return;
        }
+       Catch (Exception) {
+               LogError("Error during updating contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
        //m_latestVersion = get_contact_version();
 
        event->setResult(true);
        event->setExceptionCode(ExceptionCodes::None);
 }
 
+void AddressBook::OnRequestReceived(const EventAddressBookRemovePtr &event)
+{
+       LogDebug("entered");
+       int contactId;
+
+       Try
+       {
+               if(!event->getContactIdIsSet())
+                       ThrowMsg(InvalidArgumentException, "Contacts were not set.");
+
+               string contactIdStr = event->getContactId();
+
+               if(!validate("^[0-9]+$", contactIdStr, VALIDATE_MATCH_CASELESS))
+                       ThrowMsg(InvalidArgumentException, "Id is wrong (" << contactIdStr << ")" );
+
+               try {
+                       istringstream iss(contactIdStr);
+                       iss >> contactId;
+               } catch (...) {
+                       ThrowMsg(InvalidArgumentException, "Id is wrong (" << contactIdStr << ")" );
+               }
+
+               internalDeleteContactById(contactId);
+       }
+       Catch (InvalidArgumentException)
+       {
+               LogError("Invalid contact id : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               return;
+       }
+       Catch (NotFoundException)
+       {
+               LogError("Contact doesn't exist : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::NotFoundException);
+               return;
+       }
+       Catch (PlatformException) {
+               LogError("Error during updating contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
+       Catch (Exception) {
+               LogError("Error during updating contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
+       //m_latestVersion = get_contact_version();
+
+       event->setResult(true);
+       event->setExceptionCode(ExceptionCodes::None);
+}
 
 void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event)
 {
@@ -319,11 +432,14 @@ void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event)
 
                        int contactId;
 
+                       if(!validate("^[0-9]+$", contactIdStr, VALIDATE_MATCH_CASELESS))
+                               ThrowMsg(InvalidArgumentException, "Id is wrong (" << contactIdStr << ")" );
+
                        try {
                                istringstream iss(contactIdStr);
                                iss >> contactId;
                        } catch (...) {
-                               ThrowMsg(InvalidArgumentException, "Id (" << contactIdStr << ") changeType is wrong.");
+                               ThrowMsg(InvalidArgumentException, "Id is wrong (" << contactIdStr << ")" );
                        }
 
                        internalDeleteContactById(contactId);
@@ -357,6 +473,13 @@ void AddressBook::OnRequestReceived(const EventAddressBookRemoveBatchPtr &event)
                event->setExceptionCode(ExceptionCodes::PlatformException);
                return;
        }
+       Catch (Exception) {
+               contacts_svc_end_trans(false);
+               LogError("Error during updating contact : " << _rethrown_exception.GetMessage());
+               event->setResult(false);
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               return;
+       }
        //m_latestVersion = get_contact_version();
 
        event->setResult(true);
@@ -373,7 +496,6 @@ void AddressBook::OnRequestReceived(const EventAddressBookFindPtr &event)
                {
                        FilterPtr filter = event->getFilter();
 
-                       // FIXME validator have to be placed at JS binding.
                        FilterValidatorPtr validator = ContactFilterValidatorFactory::getContactFilterValidator();
                        bool success = filter->validate(validator);
 
@@ -415,9 +537,120 @@ void AddressBook::OnRequestReceived(const EventAddressBookFindPtr &event)
                LogError("Invalid Arguments : " << _rethrown_exception.GetMessage());
                event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
                event->setResult(false);
+
+       } Catch (Exception) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
        }
 }
 
+void AddressBook::OnRequestReceived(const EventAddressBookAddChangeListenerPtr &event)
+{
+       LogDebug("entered");
+
+       Try     {
+               if(!event->getEmitterIsSet())
+                       ThrowMsg(InvalidArgumentException, "Invalid arguments.");
+
+               EventAddressBookChangeListenerEmitterPtr emitter = event->getEmitter();
+               if(emitter == NULL)
+                       ThrowMsg(InvalidArgumentException, "Invalid arguments.");
+
+               DPL::Mutex::ScopedLock lock(&m_addressBookEmittersMutex);
+
+               if(m_addressBookEmitters.size() == 0)
+               {
+                       m_latestVersion = get_contact_version();
+                       contacts_svc_subscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
+                                       contactsSvcContactChangedCallback, reinterpret_cast<void *>(this));
+                       contacts_svc_subscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_CHANGE,
+                                       refresh_addressbook_list, reinterpret_cast<void *>(this));
+               }
+
+               m_addressBookEmitters.attach(emitter);
+
+               long id = ++m_watchIdAcc;
+               m_watchIdMap[id] = emitter->getId();
+
+           event->setId(id);
+               event->setResult(true);
+
+       } Catch (NotFoundException) {
+               LogError("Contact doesn't exist : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::NotFoundException);
+               event->setResult(false);
+
+       } Catch (PlatformException) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
+
+       } Catch (InvalidArgumentException) {
+               LogError("Invalid Arguments : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               event->setResult(false);
+
+       } Catch (Exception) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
+       }
+}
+
+void AddressBook::OnRequestReceived(const EventAddressBookRemoveChangeListenerPtr &event)
+{
+       LogDebug("entered");
+
+       Try     {
+               if(!event->getIdIsSet())
+                       ThrowMsg(InvalidArgumentException, "Invalid arguments.");
+
+               long id = event->getId();
+               if(m_watchIdMap.find(id) == m_watchIdMap.end())
+                       ThrowMsg(NotFoundException, "No watchId : " << id);
+
+               DPL::Mutex::ScopedLock lock(&m_addressBookEmittersMutex);
+               bool success = m_addressBookEmitters.detach(m_watchIdMap[id]);
+               if(!success)
+                       ThrowMsg(NotFoundException, "No watchId : " << id);
+
+               m_watchIdMap.erase(id);
+
+               if(m_addressBookEmitters.size() == 0)
+               {
+                       m_latestVersion = 0;
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_CONTACT_CHANGE,
+                                       contactsSvcContactChangedCallback);
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_ADDRESSBOOK_CHANGE,
+                                       refresh_addressbook_list);
+               }
+
+               event->setResult(true);
+
+       } Catch (NotFoundException) {
+               LogError("WatchId doesn't exist : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::NotFoundException);
+               event->setResult(false);
+
+       } Catch (PlatformException) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
+
+       } Catch (InvalidArgumentException) {
+               LogError("Invalid Arguments : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::InvalidArgumentException);
+               event->setResult(false);
+
+       } Catch (Exception) {
+               LogError("Error during deleting contact : " << _rethrown_exception.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               event->setResult(false);
+       }
+}
+
+
 void AddressBook::internalAddContact(const ContactPtr &newContact)
 {
        LogDebug("entered");
@@ -428,12 +661,26 @@ void AddressBook::internalAddContact(const ContactPtr &newContact)
        if (newContact->getPhotoURIIsSet())
        {
                string realpath = DownloadManager::getInstance()->getRealPath(newContact->getPhotoURI());
-               newContact->setPhotoURI(realpath);
+               if(realpath.length() <= MAXPATHLEN)
+                       newContact->setPhotoURI(realpath);
        }
 
+       DPL::SharedPtr<TizenApis::Platform::Contact::Contact> newContactT =
+                       DPL::StaticPointerCast<TizenApis::Platform::Contact::Contact>(newContact);
+
        ContactWrapperPtr contactWrapper(new ContactWrapper(m_bookType));
-       contactWrapper->setAbstractContact(newContact, false);
-       CTSstruct* contact = contactWrapper->getPlatformContact();
+
+       CTSstruct* contact = newContactT->getCTSStruct();
+       if(contact == NULL)
+       {
+               contactWrapper->setAbstractContact(newContact, false);
+               contact = contactWrapper->getPlatformContact();
+       }
+       else
+       {
+               contactWrapper->convertAbstractToPlatform(newContact, contact, false);
+       }
+
        if (!contact)
        {
                LogError("Error during converting contact object");
@@ -568,10 +815,16 @@ void AddressBook::contactsSvcContactChangedCallback()
                                        contacts_svc_get_contact(changeId, &contact);
 
                                        ContactWrapperPtr contactWrapper(new ContactWrapper(m_bookType));
-                                       contactWrapper->setPlatformContact(contact);
+                                       contactWrapper->setPlatformContact(contact, false);
                                        ContactPtr absContact = contactWrapper->getAbstractContact();
                                        if(absContact != NULL)
                                                addedContacts->push_back(absContact);
+
+                                       if(contact != NULL)
+                                       {
+                                               contacts_svc_struct_free(contact);
+                                               contact = NULL;
+                                       }
                                }
 
                                if(changeType == CTS_OPERATION_UPDATED)
@@ -580,10 +833,16 @@ void AddressBook::contactsSvcContactChangedCallback()
                                        contacts_svc_get_contact(changeId, &contact);
 
                                        ContactWrapperPtr contactWrapper(new ContactWrapper(m_bookType));
-                                       contactWrapper->setPlatformContact(contact);
+                                       contactWrapper->setPlatformContact(contact, false);
                                        ContactPtr absContact = contactWrapper->getAbstractContact();
                                        if(absContact != NULL)
                                                updatedContacts->push_back(absContact);
+
+                                       if(contact != NULL)
+                                       {
+                                               contacts_svc_struct_free(contact);
+                                               contact = NULL;
+                                       }
                                }
 
                                if(changeType == CTS_OPERATION_DELETED)
@@ -592,13 +851,19 @@ void AddressBook::contactsSvcContactChangedCallback()
                                        contacts_svc_get_contact(changeId, &contact);
 
                                        ContactWrapperPtr contactWrapper(new ContactWrapper(m_bookType));
-                                       contactWrapper->setPlatformContact(contact);
+                                       contactWrapper->setPlatformContact(contact, false);
                                        ContactPtr absContact = contactWrapper->getAbstractContact();
                                        if(absContact != NULL)
                                        {
                                                if(absContact->getIdIsSet())
                                                        removedContactIds->push_back(absContact->getId());
                                        }
+
+                                       if(contact != NULL)
+                                       {
+                                               contacts_svc_struct_free(contact);
+                                               contact = NULL;
+                                       }
                                }
 
                                contacts_svc_value_free(row_info);
index 314703e..3eb2751 100755 (executable)
@@ -54,19 +54,17 @@ public:
        virtual bool        getReadOnly() const { return m_readOnly; }
        virtual void        setReadOnly(const bool &value) { m_readOnly = value; }
 
-       virtual TizenApis::Api::Contact::ContactPtr get(const std::string &contactId);
-       virtual void add(const TizenApis::Api::Contact::ContactPtr &contact);
-       virtual void update(const TizenApis::Api::Contact::ContactPtr &contact);
-       virtual void remove(const std::string &id);
-
-       virtual long addChangeListener(const TizenApis::Api::Contact::EventAddressBookChangeListenerEmitterPtr &emitter);
-       virtual void removeChangeListener(const long watchId);
-
 protected:
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookGetPtr &event);
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddPtr &event);
        virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddBatchPtr &event);
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookUpdatePtr &event);
        virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookUpdateBatchPtr &event);
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemovePtr &event);
        virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemoveBatchPtr &event);
        virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookFindPtr &event);
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookAddChangeListenerPtr &event);
+       virtual void OnRequestReceived(const TizenApis::Api::Contact::EventAddressBookRemoveChangeListenerPtr &event);
 
 private:
        int m_latestVersion;
@@ -81,6 +79,10 @@ private:
        AddressBookChangedEmitter       m_addressBookEmitters;
        DPL::Mutex      m_addressBookEmittersMutex;
 
+       typedef std::map<long, TizenApis::Api::Contact::EventAddressBookChangeListenerEmitter::IdType> WatchIdMap;
+       WatchIdMap m_watchIdMap;
+       long m_watchIdAcc;
+
 public:
        static void contactsSvcContactChangedCallback(void *data);
 
index bcb69fd..c13c4b1 100755 (executable)
@@ -37,23 +37,17 @@ using namespace TizenApis::Api::Contact;
 using namespace WrtDeviceApis::Commons;
 using namespace std;
 
-Contact::Contact() : IContact()
+Contact::Contact()
+       : IContact()
+       , m_cts(NULL)
 {
        LogDebug("entered");
 }
 
-Contact::Contact(const string &vObjectStr, const string &format)
-       : IContact(vObjectStr, format)
-{
-       LogDebug("entered");
-       ContactPtr iContact = convertFromString(vObjectStr, format);
-       DPL::SharedPtr<Contact> contact = DPL::DynamicPointerCast<Contact>(iContact);
-
-       *this = *contact;
-}
-
 Contact::~Contact()
 {
+       if (m_cts != NULL)
+               contacts_svc_struct_free(m_cts);
 }
 
 string Contact::convertToString(const string &format)
@@ -61,17 +55,16 @@ string Contact::convertToString(const string &format)
        LogDebug("entered");
        char *vcard_stream = NULL;
 
+       if(format != "VCARD_21" && format != "VCARD_30")
+               ThrowMsg(ConversionException, "format must be one of 'VCARD_21' or 'VCARD_30'");
+
        if(format != "VCARD_30")
                ThrowMsg(UnsupportedException, "Only support vCard 3.0.");
 
-       Contact *pContact = new Contact();
-       *pContact = *this;
-       ContactPtr contact(pContact);
-
        ContactWrapperPtr contactWrapper(new ContactWrapper(TizenApis::Api::Contact::IAddressBook::PhoneBook));
        Try {
-//             contactWrapper->setAbstractContact(DPL::StaticPointerCast<IContact>(SharedFromThis()), true);
-               contactWrapper->setAbstractContact(contact, true);
+               ContactPtr thisObj = SharedFromThis();
+               contactWrapper->setAbstractContact(thisObj, true);
        } Catch (PlatformException) {
                ThrowMsg(PlatformException, "Fail to extract contact to platform object.");
        }
@@ -86,27 +79,33 @@ string Contact::convertToString(const string &format)
        return result;
 }
 
-ContactPtr Contact::convertFromString(const std::string &vObjectStr, const std::string &format)
+void Contact::setContactFromString(const std::string &vObjectStr, const std::string &format)
 {
        LogDebug("entered");
        const char *vcard_stream = vObjectStr.c_str();
        CTSstruct* cts;
 
+       if(format != "VCARD_21" && format != "VCARD_30")
+               ThrowMsg(ConversionException, "format must be one of 'VCARD_21' or 'VCARD_30'");
+
        if(format != "VCARD_30")
                ThrowMsg(UnsupportedException, "Only support vCard 3.0.");
 
        int ret = contacts_svc_get_contact_from_vcard(vcard_stream, &cts);
-       if(CTS_SUCCESS != ret)
+       if(CTS_ERR_ARG_INVALID == ret)
+               ThrowMsg(InvalidArgumentException, "Invalid vCard string.");
+       else if(CTS_SUCCESS != ret)
                ThrowMsg(PlatformException, "Fail to convert contact from vCard.");
 
        ContactWrapperPtr contactWrapper(new ContactWrapper(TizenApis::Api::Contact::IAddressBook::PhoneBook));
        Try {
-               contactWrapper->setPlatformContact(cts);
+               ContactPtr thisObj = SharedFromThis();
+               contactWrapper->convertPlatformToAbstract(cts, thisObj, true);
        } Catch (PlatformException) {
                ThrowMsg(PlatformException, "Fail to extract contact from platform object.");
        }
 
-       return contactWrapper->getAbstractContact();
+       m_cts = cts;
 }
 
 } // Contact
index efbe7b9..ad89449 100755 (executable)
 
 #include <string>
 #include <vector>
+#include <contacts-svc.h>
 #include <API/Contact/IContact.h>
 
 namespace TizenApis {
 namespace Platform {
 namespace Contact {
 
-class Contact :
-       public TizenApis::Api::Contact::IContact
-//     public DPL::EnableSharedFromThis<Contact>
+class Contact : public TizenApis::Api::Contact::IContact
 {
 public:
        Contact();
-       Contact(const std::string &vObjectStr, const std::string &format);
        virtual ~Contact();
 
        virtual std::string convertToString(const std::string &format);
 
-       static TizenApis::Api::Contact::ContactPtr convertFromString(const std::string &vObjectStr, const std::string &format);
+       virtual void setContactFromString(const std::string &vObjectStr, const std::string &format);
+
+       CTSstruct* getCTSStruct() const { return m_cts; };
+
+private:
+       CTSstruct* m_cts;
 };
 
 } // Contact
index f070495..7f4ef33 100755 (executable)
@@ -24,6 +24,7 @@
 #include "query-svc/query-service.h"
 #include "time.h"
 
+#include <sstream>
 #include <iomanip>
 #include <Commons/Exception.h>
 #include "Contact.h"
@@ -148,6 +149,9 @@ void ContactSearchEngine::setAttributeOfInterest(StringArrayPtr attr)
                {
                        if(query_set_attribute(m_contact_query_service, static_cast<contact_attribute_e>(it->second)) == QUERY_SUCCESS)
                                m_attributesOfInterest->push_back(it->first);
+
+                       if(static_cast<contact_attribute_e>(it->second) == contact_attribute_e::EVENT_DATE)
+                               query_set_attribute(m_contact_query_service, contact_attribute_e::EVENT_TYPE);
                }
        }
 }
@@ -414,15 +418,109 @@ void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag,
        }
        else
        {
-               condition_e cond;
-               if(matchFlag == MATCH_EXACTLY)
+               if(matchValue->isType(PrimitiveType_String))
+               {
+                       condition_e cond;
+                       string valueStr;
+
+                       if(matchFlag == MATCH_EXACTLY)
+                       {
+                               cond = EQUAL;
+                               valueStr = matchValue->getString();
+                       }
+                       else if (matchFlag == MATCH_FULLSTRING)
+                       {
+                               cond = LIKE;
+                               valueStr = matchValue->getString();
+                       }
+                       else if (matchFlag == MATCH_CONTAINS)
+                       {
+                               cond = LIKE;
+                               valueStr = "%"+matchValue->getString()+"%";
+                       }
+                       else if (matchFlag == MATCH_STARTSWITH)
+                       {
+                               cond = LIKE;
+                               valueStr = matchValue->getString()+"%";
+                       }
+                       else if (matchFlag == MATCH_ENDSWITH)
+                       {
+                               cond = LIKE;
+                               valueStr = "%"+matchValue->getString();
+                       }
+                       else
+                               cond = EQUAL;
+
+                       query_set_condition(m_contact_query_service, attr, cond, valueStr.c_str());
+               }
+               else if(matchValue->isType(PrimitiveType_Boolean))
+               {
+                       condition_e cond;
+                       string valueStr;
+
                        cond = EQUAL;
-               else if (matchFlag == MATCH_STARTSWITH || matchFlag == MATCH_ENDSWITH)
-                       cond = LIKE;
-               else
+                       if(matchValue->getBool())
+                               valueStr = "TRUE";
+                       else
+                               valueStr = "FALSE";
+
+                       query_set_condition(m_contact_query_service, attr, cond, valueStr.c_str());
+               }
+               else if(matchValue->isType(PrimitiveType_Time))
+               {
+                       condition_e cond;
+                       string valueStr;
+
+                       query_set_condition_append(m_contact_query_service, LEFT_BRACKET);
+
                        cond = EQUAL;
+                       valueStr = toDateDbStr(matchValue->getDateTm());
+                       query_set_condition(m_contact_query_service, attr, cond, valueStr.c_str());
+
+                       query_set_condition_append(m_contact_query_service, AND);
+
+                       if(attrName == "birthday")
+                               query_set_condition(m_contact_query_service, EVENT_TYPE, EQUAL, "BIRTHDAY");
+                       else
+                               query_set_condition(m_contact_query_service, EVENT_TYPE, EQUAL, "ANNIVERSARY");
 
-               visitAttributeEach(attr, matchValue, cond);
+                       query_set_condition_append(m_contact_query_service, RIGHT_BRACKET);
+               }
+               else
+               {
+                       condition_e cond;
+                       string valueStr;
+
+                       if(matchFlag == MATCH_EXACTLY)
+                       {
+                               cond = EQUAL;
+                               valueStr = matchValue->getString();
+                       }
+                       else if (matchFlag == MATCH_FULLSTRING)
+                       {
+                               cond = LIKE;
+                               valueStr = matchValue->getString();
+                       }
+                       else if (matchFlag == MATCH_CONTAINS)
+                       {
+                               cond = LIKE;
+                               valueStr = "%"+matchValue->getString()+"%";
+                       }
+                       else if (matchFlag == MATCH_STARTSWITH)
+                       {
+                               cond = LIKE;
+                               valueStr = matchValue->getString()+"%";
+                       }
+                       else if (matchFlag == MATCH_ENDSWITH)
+                       {
+                               cond = LIKE;
+                               valueStr = "%"+matchValue->getString();
+                       }
+                       else
+                               cond = EQUAL;
+
+                       query_set_condition(m_contact_query_service, attr, cond, valueStr.c_str());
+               }
        }
 }
 
@@ -435,48 +533,45 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV
        string initialValueStr;
        string endValueStr;
 
-       if(initialValue->isType(PrimitiveType_Time))
-       {
-               tm date = initialValue->getDateTm();
-               initialValueStr = toDateDbStr(date);
-       }
-       else
-       {
-               initialValueStr = initialValue->toString();
-       }
+       bool initialValueExists = !initialValue->isNullOrUndefined();
+       bool endValueExists = !endValue->isNullOrUndefined();
 
-       if(endValue->isType(PrimitiveType_Time))
+       if(initialValueExists)
        {
-               tm date = endValue->getDateTm();
-               endValueStr = toDateDbStr(date);
+               if(initialValue->isType(PrimitiveType_Time))
+                       initialValueStr = toDateDbStr(initialValue->getDateTm());
+               else
+                       initialValueStr = initialValue->toString();
        }
-       else
+
+       if(endValueExists)
        {
-               endValueStr = endValue->toString();
+               if(endValue->isType(PrimitiveType_Time))
+                       endValueStr = toDateDbStr(endValue->getDateTm());
+               else
+                       endValueStr = endValue->toString();
        }
 
        attr = getPlatformAttr(attrName);
        query_set_condition_append(m_contact_query_service, LEFT_BRACKET);
-       query_set_condition(m_contact_query_service, attr, GREATER_THAN_OR_EQUAL, ("\"" + initialValueStr + "\"").c_str());
-       query_set_condition_append(m_contact_query_service, AND);
-       query_set_condition(m_contact_query_service, attr, LESS_THAN_OR_EQUAL, ("\"" + endValueStr + "\"").c_str());
-       query_set_condition_append(m_contact_query_service, RIGHT_BRACKET);
-}
 
-void ContactSearchEngine::visitAttributeEach(contact_attribute_e attr, AnyPtr& matchValue, condition_e flag)
-{
-       string valueStr;
-       if(matchValue->isType(PrimitiveType_Time))
-       {
-               tm date = matchValue->getDateTm();
-               valueStr = toDateDbStr(date);
-       }
+       if(attrName == "birthday")
+               query_set_condition(m_contact_query_service, EVENT_TYPE, EQUAL, "BIRTHDAY");
        else
-       {
-               valueStr = matchValue->toString();
-       }
+               query_set_condition(m_contact_query_service, EVENT_TYPE, EQUAL, "ANNIVERSARY");
+
+       query_set_condition_append(m_contact_query_service, AND);
+
+       if(initialValueExists)
+               query_set_condition(m_contact_query_service, attr, GREATER_THAN_OR_EQUAL, initialValueStr.c_str());
 
-       query_set_condition(m_contact_query_service, attr, flag, valueStr.c_str());
+       if(initialValueExists && endValueExists)
+               query_set_condition_append(m_contact_query_service, AND);
+
+       if(endValueExists)
+               query_set_condition(m_contact_query_service, attr, LESS_THAN_OR_EQUAL, endValueStr.c_str());
+
+       query_set_condition_append(m_contact_query_service, RIGHT_BRACKET);
 }
 
 void ContactSearchEngine::visitAttributeID(AnyArrayPtr &ids)
@@ -894,6 +989,7 @@ string ContactSearchEngine::toDateDbStr(const tm &date) const
 tm ContactSearchEngine::toDateTmFromDateDbStr(const char* arg) const
 {
        tm date;
+       memset(&date, 0, sizeof(tm));
 
        if(arg == NULL) {
                ThrowMsg(InvalidArgumentException, "Invalid Date type");
@@ -905,7 +1001,7 @@ tm ContactSearchEngine::toDateTmFromDateDbStr(const char* arg) const
 
        date.tm_year = (dateDb / 10000) - 1900;
        date.tm_mon = ((dateDb - ((date.tm_year + 1900) * 10000)) / 100) - 1;
-       date.tm_mday = (dateDb - ((date.tm_year + 1900) * 10000) - date.tm_mon * 100);
+       date.tm_mday = (dateDb - ((date.tm_year + 1900) * 10000) - ((date.tm_mon+1) * 100));
 
        return date;
 }
index f231324..08f2353 100755 (executable)
@@ -80,7 +80,6 @@ private:
        ADVANCED_HANDLE m_contact_query_service;
        TizenApis::Api::Contact::StringArrayPtr m_attributesOfInterest;
 
-       void visitAttributeEach(contact_attribute_e attr, TizenApis::Api::Tizen::AnyPtr& value, condition_e flag);
        void visitAttributeID(TizenApis::Api::Tizen::AnyArrayPtr &ids);
 
        contact_attribute_e getPlatformAttr(std::string attrName);
index 9487a62..7023781 100755 (executable)
@@ -47,21 +47,10 @@ using namespace std;
 
 ContactWrapper::ContactWrapper(IAddressBook::AddressBookType type) :
                m_abstractContact(NULL),
-               m_platformContact(NULL)
+               m_platformContact(NULL),
+               m_platformContactOwnership(false)
 {
        //platform layer seems to not support different storage types yet
-       /*
-       if ( type == IAddressBook::PhoneBook )
-       {
-       }
-       else if ( type == IAddressBook::SIMBook )
-       {
-       }
-       else
-       {
-               LogError("invalid storage type");
-       }
-       */
 }
 
 ContactWrapper::~ContactWrapper()
@@ -71,10 +60,11 @@ ContactWrapper::~ContactWrapper()
 
 void ContactWrapper::freePlatformObject()
 {
-       if (m_platformContact)
+       if (m_platformContact && m_platformContactOwnership)
        {
                contacts_svc_struct_free(m_platformContact);
                m_platformContact = NULL;
+               m_platformContactOwnership = false;
        }
 }
 
@@ -99,11 +89,38 @@ CTSstruct* ContactWrapper::getPlatformContact() const
        return m_platformContact;
 }
 
-void ContactWrapper::setPlatformContact(CTSstruct* contact)
+void ContactWrapper::setPlatformContact(CTSstruct* contact, bool isConvertingVCard)
 {
        freePlatformObject();
+       freeAbstractObject();
+
        m_platformContact = contact;
-       convertToAbstractObject();
+       m_platformContactOwnership = false;
+       convertToAbstractObject(isConvertingVCard);
+}
+
+bool ContactWrapper::convertAbstractToPlatform(const ContactPtr &abstract, CTSstruct* platform, bool isConvertingVCard)
+{
+       freePlatformObject();
+       freeAbstractObject();
+
+       m_abstractContact = abstract;
+       m_platformContact = platform;
+       m_platformContactOwnership = false;
+
+       return convertToPlatformObject(isConvertingVCard);
+}
+
+bool ContactWrapper::convertPlatformToAbstract(CTSstruct* platform, ContactPtr &abstract, bool isConvertingVCard)
+{
+       freeAbstractObject();
+       freePlatformObject();
+
+       m_platformContact = platform;
+       m_platformContactOwnership = false;
+       m_abstractContact = abstract;
+
+       return convertToAbstractObject(isConvertingVCard);
 }
 
 bool ContactWrapper::convertToPlatformObject(bool isConvertingVCard)
@@ -128,6 +145,7 @@ bool ContactWrapper::convertToPlatformObject(bool isConvertingVCard)
        {
                LogDebug("creating new contact");
                m_platformContact = contacts_svc_struct_new(CTS_STRUCT_CONTACT);
+               m_platformContactOwnership = true;
        }
 
        if (!m_platformContact)
@@ -183,12 +201,10 @@ bool ContactWrapper::convertToPlatformObject(bool isConvertingVCard)
        return true;
 }
 
-bool ContactWrapper::convertToAbstractObject()
+bool ContactWrapper::convertToAbstractObject(bool isConvertingVCard)
 {
        LogDebug("entered");
 
-       freeAbstractObject();
-
        if (!m_platformContact)
                return false;
 
@@ -197,8 +213,11 @@ bool ContactWrapper::convertToAbstractObject()
        if (CTS_SUCCESS != contacts_svc_struct_get_value(m_platformContact, CTS_CF_BASE_INFO_VALUE, &value))
                return false;
 
-       m_abstractContact = ContactPtr(new Contact());
-       m_abstractContact->setId(contacts_svc_value_get_int(value, CTS_BASE_VAL_ID_INT));
+       if(m_abstractContact == NULL)
+               m_abstractContact = ContactPtr(new Contact());
+
+       if(!isConvertingVCard)
+               m_abstractContact->setId(contacts_svc_value_get_int(value, CTS_BASE_VAL_ID_INT));
 
        const char *charValue;
 
index c87df67..41f4cd0 100755 (executable)
@@ -41,20 +41,24 @@ public:
        virtual ~ContactWrapper();
 
        TizenApis::Api::Contact::ContactPtr getAbstractContact() const;
-       void setAbstractContact(const TizenApis::Api::Contact::ContactPtr &contact, bool is_convert_vCard);
+       void setAbstractContact(const TizenApis::Api::Contact::ContactPtr &contact, bool isConvertingVCard);
 
        CTSstruct* getPlatformContact() const;
        //WARNING: calling this function will cause to store pointer inside private field
        //Structure will be freed by this class when is not needed anymore.
        //User should not modify nor free passed pointer.
-       void setPlatformContact(CTSstruct* contact);
+       void setPlatformContact(CTSstruct* contact, bool isConvertingVCard);
+
+       bool convertAbstractToPlatform(const TizenApis::Api::Contact::ContactPtr &abstract, CTSstruct* platform, bool isConvertingVCard);
+       bool convertPlatformToAbstract(CTSstruct* platform, TizenApis::Api::Contact::ContactPtr &abstract, bool isConvertingVCard);
 
 protected:
-       bool convertToPlatformObject(bool is_convert_vCard);
-       bool convertToAbstractObject();
+       bool convertToPlatformObject(bool isConvertingVCard);
+       bool convertToAbstractObject(bool isConvertingVCard);
 
        TizenApis::Api::Contact::ContactPtr m_abstractContact;
        CTSstruct*        m_platformContact;
+       bool m_platformContactOwnership;
 
 private:
        void freePlatformObject();
index ef315e6..c7c1db1 100755 (executable)
@@ -139,7 +139,7 @@ int _value_to_projection(stmt hstmt, char** projection, int count)
        pos = count;
 
        if((*projection) == NULL)
-               *projection = (char*)g_strdup(_query_column_text(hstmt, pos++));
+               *projection = (char*)g_strdup(_ct_query_column_text(hstmt, pos++));
        else
                pos++;
 
@@ -376,7 +376,7 @@ int _int_value_to_projection(tables_e table, db_datatype datatype, stmt hstmt, c
 
        if((*projection) == NULL)
        {
-               db_value = _query_column_int(hstmt, pos++);
+               db_value = _ct_query_column_int(hstmt, pos++);
                if(table == DATA_TABLE)
                {
                        switch(datatype)
@@ -427,7 +427,7 @@ int _event_value_to_projection(stmt hstmt, char** projection, int count)
 
        if((*projection) == NULL)
        {
-               db_value = _query_column_int(hstmt, pos++);
+               db_value = _ct_query_column_int(hstmt, pos++);
                g_string_append_printf (type_str, "%d", db_value);
 
                *projection = (char*)g_strdup(type_str->str);
@@ -495,16 +495,16 @@ query_error _make_contact_info(advanced_handle_t* q_handle, projection_type type
 
        if(type == ONLY_CONTACT_ID_FIELD)
        {
-               contact_id = _query_column_int(q_handle->hstmt, count++);
+               contact_id = _ct_query_column_int(q_handle->hstmt, count++);
        }else
        {
                if(join_table == ONLY_PERSON || join_table == ONLY_CONTACT)
                {
-                       contact_id = _query_column_int(q_handle->hstmt, count++);
+                       contact_id = _ct_query_column_int(q_handle->hstmt, count++);
                }else
                {
-                       datatype_id = _query_column_int(q_handle->hstmt, count++);
-                       contact_id = _query_column_int(q_handle->hstmt, count++);
+                       datatype_id = _ct_query_column_int(q_handle->hstmt, count++);
+                       contact_id = _ct_query_column_int(q_handle->hstmt, count++);
                }
        }
 
@@ -531,7 +531,7 @@ query_error _make_contact_info(advanced_handle_t* q_handle, projection_type type
                        sprintf(q_handle->result_set[q_handle->pos].contact_info->raw_contact_info->contact_id, "%d", contact_id);
                }
 
-               q_handle->result_set[q_handle->pos].is_occupied = true;
+               q_handle->result_set[q_handle->pos].is_occupied = 1;
                q_handle->old_contact_id = contact_id;
 
                q_handle->mapping_id_to_result_set[q_handle->pos].contact_id = contact_id;
@@ -830,12 +830,12 @@ query_error _make_contact_info(advanced_handle_t* q_handle, projection_type type
                                {
                                        int changed_time = 0;
                                        char tmp_string[64] = {0, };
-                                       changed_time = _query_column_int(q_handle->hstmt, count++);
+                                       changed_time = _ct_query_column_int(q_handle->hstmt, count++);
                                        sprintf(tmp_string, "%d", changed_time);
                                        q_handle->result_set[q_handle->pos].contact_info->raw_contact_info->last_updated_time_stamp = (char*)g_strdup(tmp_string);
                                }else if(strcmp(field_key[FIELD_CONTACT_ACCOUNT_ID], projection) == 0)
                                {
-                                       int db_value = _query_column_int(q_handle->hstmt, count++);
+                                       int db_value = _ct_query_column_int(q_handle->hstmt, count++);
                                        if(db_value != 0)
                                        {
                                                q_handle->result_set[q_handle->pos].contact_info->raw_contact_info->account_id = g_new0(char, 64);
@@ -900,7 +900,7 @@ API ADVANCED_HANDLE query_init(query_error* error_code, query_type_e query_type)
        handle = g_new0(advanced_handle_t, 1);
        ADVANCED_CATCH_SET_ERROR_POINTER((handle != NULL), {}, QUERY_HANDLE_NONE, ("ALLOCATION FAIL"));
 
-       *error_code = _db_init();
+       *error_code = _contact_db_init();
        ADVANCED_CATCH_SET_ERROR_POINTER((*error_code == QUERY_SUCCESS), {}, QUERY_STATEMENT_FAIL, ("DATABASE INIT FAIL"));
 
        handle->pos = -1;
@@ -911,7 +911,7 @@ API ADVANCED_HANDLE query_init(query_error* error_code, query_type_e query_type)
        handle->order = g_string_new ("");
        handle->use_normal_field_key = g_string_new ("");
        handle->use_contact_table_id = g_string_new ("");
-       handle->optimize_condition = true;
+       handle->optimize_condition = 1;
        handle->id_list = g_string_new ("");
 
        ADVANCED_SVC_TRACE("QUERY INIT SUCCESS");
@@ -1097,7 +1097,7 @@ int _make_order_list(advanced_handle_t* q_handle, int count, target_table_e join
        ADVANCED_SVC_TRACE("q_handle->order : %s", q_handle->order->str);
        query = g_string_new ("");
 
-       if(q_handle->limit_iter == true)
+       if(q_handle->limit_iter == 1)
        {
                q_handle->ordering_list = g_new0(ordering_list_t, q_handle->total_result_set_count);
                ADVANCED_CATCH_SET_ERROR((q_handle->ordering_list != NULL), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
@@ -1139,10 +1139,10 @@ int _make_order_list(advanced_handle_t* q_handle, int count, target_table_e join
                q_handle->ordering_list = g_new0(ordering_list_t, q_handle->total_result_set_count);
                ADVANCED_CATCH_SET_ERROR((q_handle->ordering_list != NULL), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
 
-           q_handle->hstmt = _query_prepare(query->str);
+           q_handle->hstmt = _contact_query_prepare(query->str);
                ADVANCED_CATCH_SET_ERROR((q_handle->hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
-               rc = _query_step(q_handle->hstmt);
+               rc = _contact_query_step(q_handle->hstmt);
                ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_ORDERING_FAIL, ("No record in database"));
 
                while(rc == SQLITE_ROW)
@@ -1150,12 +1150,12 @@ int _make_order_list(advanced_handle_t* q_handle, int count, target_table_e join
                        if(q_handle->total_count >= count)
                                break;
 
-                       q_handle->full_ordered_contact_id[q_handle->total_count].contact_id = _query_column_int(q_handle->hstmt, 0);
-                       rc = _query_step(q_handle->hstmt);
+                       q_handle->full_ordered_contact_id[q_handle->total_count].contact_id = _ct_query_column_int(q_handle->hstmt, 0);
+                       rc = _contact_query_step(q_handle->hstmt);
                        q_handle->total_count++;
                }
                q_handle->total_count = count;
-               _query_finalize(q_handle->hstmt);
+               _ct_query_finalize(q_handle->hstmt);
 
                for(j=0; j<q_handle->total_count; j++)
                {
@@ -1231,7 +1231,7 @@ query_error _make_contact_id_list_by_condition_part(advanced_handle_t* q_handle,
                                data_table_alias = table_info->alias;
                }
 
-               if(q_handle->optimize_condition == true)
+               if(q_handle->optimize_condition == 1)
                {
                        if(sub_query->str[0] == '\0')
                        {
@@ -1264,10 +1264,10 @@ query_error _make_contact_id_list_by_condition_part(advanced_handle_t* q_handle,
        if(tmp_query->str[0] != '\0')
                g_string_append_printf (sub_query, " %s", tmp_query->str);
 
-       if(q_handle->optimize_condition && q_handle->condition_list && q_handle->current_alias > ALIAS_A)
+       if((q_handle->optimize_condition == 1) && (q_handle->condition_list && q_handle->current_alias > ALIAS_A))
        {
                GList* tmp_condition = q_handle->condition_list;
-               bool is_first = true;
+               int is_first = 1;
                while(tmp_condition)
                {
                        condition_list_t* condition_info = (condition_list_t*)tmp_condition->data;
@@ -1277,7 +1277,7 @@ query_error _make_contact_id_list_by_condition_part(advanced_handle_t* q_handle,
                                g_string_append_printf(sub_query, " (%s.id in (select id from %s where %s %s ? and %s = %d",
                                        alias_key[data_table_alias], table_key[TABLE_DATA], condition_info->column_name,
                                        condition_info->condition, condition_field_key[FIELD_DATA_DATATYPE_ID], condition_info->datatype);
-                               is_first = false;
+                               is_first = 0;
                        }else
                        {
                                g_string_append_printf(sub_query, " union select id from %s where %s %s ? and %s = %d",
@@ -1300,14 +1300,14 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 {
        GString* condition;
        GString* contact_condition;
-       bool is_first = true;
-       bool use_sub_query = true;
+       int is_first = 1;
+       int use_sub_query = 1;
 
        condition = g_string_new("");
        contact_condition = g_string_new("");
 
        if(q_handle->condition_datatype == DATATYPE_INVALID && q_handle->condition_category == NULL)
-               use_sub_query = false;
+               use_sub_query = 0;
 
        GList* tmp_datatype_list = q_handle->datatype_list;
        while(tmp_datatype_list)
@@ -1320,7 +1320,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
                        g_string_append_printf(condition, " or %s = %d", datatype_info->field, datatype_info->datatype);
 
                tmp_datatype_list = g_list_next(tmp_datatype_list);
-               is_first = false;
+               is_first = 0;
        }
 
        switch(value)
@@ -1331,7 +1331,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 
                        if(strlen(condtion_sub_query) != 0)
                        {
-                               if(use_sub_query == false)
+                               if(use_sub_query == 0)
                                {
                                        g_string_append_printf(query, " where %s", q_handle->use_contact_table_id->str);
                                }else
@@ -1366,7 +1366,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 
                        if(strlen(condtion_sub_query) != 0)
                        {
-                               if(use_sub_query == false)
+                               if(use_sub_query == 0)
                                        g_string_append_printf(query, " where %s", q_handle->use_normal_field_key->str);
                                else
                                        g_string_append_printf(query, " where %s in (%s) and (%s)", field_key[FIELD_DATA_CONTACT_ID], condtion_sub_query, condition->str);
@@ -1387,7 +1387,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 
                        if(strlen(condtion_sub_query) != 0)
                        {
-                               if(use_sub_query == false)
+                               if(use_sub_query == 0)
                                        g_string_append_printf(query, " where %s = ?", field_key[FIELD_PERSON_CONTACT_ID]);
                                else
                                        g_string_append_printf(query, " where %s in (%s)", field_key[FIELD_PERSON_CONTACT_ID], condtion_sub_query);
@@ -1409,7 +1409,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 
                        if(strlen(condtion_sub_query) != 0)
                        {
-                               if(use_sub_query == false)
+                               if(use_sub_query == 0)
                                        g_string_append_printf(query, " %s and", q_handle->use_normal_field_key->str);
                                else
                                        g_string_append_printf(query, " %s in (%s) and", field_key[FIELD_CONTACT_CONTACT_ID], condtion_sub_query);
@@ -1425,7 +1425,7 @@ void _construct_query(target_table_e value, advanced_handle_t* q_handle, GString
 
                        if(strlen(condtion_sub_query) != 0)
                        {
-                               if(use_sub_query == false)
+                               if(use_sub_query == 0)
                                        g_string_append_printf(query, " %s = ? and", field_key[FIELD_PERSON_CONTACT_ID]);
                                else
                                        g_string_append_printf(query, " %s in (%s) and", field_key[FIELD_PERSON_CONTACT_ID], condtion_sub_query);
@@ -1462,10 +1462,10 @@ query_error _query_result_set(advanced_handle_t* q_handle, int rc, int count, pr
                }
                ADVANCED_CATCH_SET_ERROR((error_code == QUERY_SUCCESS), {}, QUERY_ALLOCATE_MEMORY_FAIL, ("ALLOCATION FAIL"));
 
-               rc = _query_step(q_handle->hstmt);
+               rc = _contact_query_step(q_handle->hstmt);
        }
 
-       _query_finalize(q_handle->hstmt);
+       _ct_query_finalize(q_handle->hstmt);
 
 CATCH:
        return error_code;
@@ -1489,8 +1489,8 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
        value = _check_join_case(q_handle);
        ADVANCED_SVC_TRACE("value : %d", value);
 
-       bool table_contact = false;
-       bool reorganize = false;
+       int table_contact = 0;
+       int reorganize = 0;
        int data_field_count = 0;
 
        if(q_handle->query_string == NULL)
@@ -1502,11 +1502,11 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
 
                        loc = strstr(projection_info->field, "contact.");
                        if(loc != NULL)
-                               table_contact = true;
+                               table_contact = 1;
 
                        loc = strstr(projection_info->field, "data.contact_id");
                        if(loc != NULL)
-                               reorganize = true;
+                               reorganize = 1;
 
                        loc = strstr(projection_info->field, "data.");
                        if(loc != NULL)
@@ -1518,7 +1518,7 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
                if(q_handle->query_type == QUERY_TO_PERSON)
                        g_string_append_printf(projection, "%s", field_key[FIELD_PERSON_CONTACT_ID]);
 
-               if((table_contact == true && reorganize == true && data_field_count == 1) || (q_handle->assigned_datatype == 0))
+               if((table_contact == 1 && reorganize == 1 && data_field_count == 1) || (q_handle->assigned_datatype == 0))
                {
                        g_string_append_printf(projection, "%s", field_key[FIELD_CONTACT_CONTACT_ID]);
                        value = ONLY_CONTACT;
@@ -1530,19 +1530,19 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
                }
 
                GList* tmp_projection = q_handle->projection;
-               bool projection_duplicate = false;
+               int projection_duplicate = 0;
                while(tmp_projection)
                {
                        projection_t* projection_info = (projection_t*)tmp_projection->data;
 
                        if(strcmp(projection_info->field, field_key[FIELD_CONTACT_CONTACT_ID]) == 0)
-                               projection_duplicate = true;
+                               projection_duplicate = 1;
 
                        if(strcmp(projection_info->field, field_key[FIELD_DATA_CONTACT_ID]) == 0)
-                               projection_duplicate = true;
+                               projection_duplicate = 1;
 
                        loc = strstr(projection->str, projection_info->field);
-                       if(loc == NULL && projection_duplicate == false)
+                       if(loc == NULL && projection_duplicate == 0)
                        {
                                g_string_append_printf(projection, ", %s", projection_info->field);
 
@@ -1555,7 +1555,7 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
                        }
 
                        tmp_projection = g_list_next(tmp_projection);
-                       projection_duplicate = false;
+                       projection_duplicate = 0;
                }
                g_list_foreach(q_handle->projection, _free_projection_list, NULL);
                g_list_free(q_handle->projection);
@@ -1569,7 +1569,7 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
 
        _construct_query(value, q_handle, query, condtion_sub_query, type);
 
-    q_handle->hstmt = _query_prepare(query->str);
+    q_handle->hstmt = _contact_query_prepare(query->str);
        ADVANCED_CATCH_SET_ERROR((q_handle->hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
        if(strlen(condtion_sub_query) != 0)
@@ -1578,34 +1578,34 @@ int _make_result_contact_list(advanced_handle_t* q_handle, int count, char* cond
                if(q_handle->condition_category != NULL)
                {
                        ADVANCED_SVC_TRACE("q_handle->condition_category : %s", q_handle->condition_category);
-                       _query_bind_text(q_handle->hstmt, i, q_handle->condition_category);
+                       _contact_query_bind_text(q_handle->hstmt, i, q_handle->condition_category);
                }else
                {
                        GList* tmp_condition_val = q_handle->condition_value;
                        while(tmp_condition_val)
                        {
                                condition_val_t* tmp_val = (condition_val_t*)tmp_condition_val->data;
-                               if(tmp_val->indices_filter == false)
+                               if(tmp_val->indices_filter == 0)
                                {
                                ADVANCED_SVC_TRACE("condition_val->value : %s", tmp_val->value);
 
                                primitive_type type = _convert_check_attribute_primitive_type(tmp_val->attribute);
-                               if(tmp_val->x_attribute == true)
+                               if(tmp_val->x_attribute == 1)
                                        type = STRING;
 
                                if(type == INTEGER)
-                                       _query_bind_int(q_handle->hstmt, i++, tmp_val->int_value);
+                                       _contact_query_bind_int(q_handle->hstmt, i++, tmp_val->int_value);
                                else if(type == STRING)
-                                       _query_bind_text(q_handle->hstmt, i++, tmp_val->value);
+                                       _contact_query_bind_text(q_handle->hstmt, i++, tmp_val->value);
                                else if(type == REAL)
-                                       _query_bind_double(q_handle->hstmt, i++, tmp_val->real_value);
+                                       _contact_query_bind_double(q_handle->hstmt, i++, tmp_val->real_value);
                                }
                                tmp_condition_val = g_list_next(tmp_condition_val);
                        }
                }
        }
 
-       rc = _query_step(q_handle->hstmt);
+       rc = _contact_query_step(q_handle->hstmt);
        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
        error_code = _query_result_set(q_handle, rc, count, type, value);
@@ -1616,9 +1616,9 @@ CATCH:
        return error_code;
 }
 
-bool _check_optimized_query(advanced_handle_t* q_handle, target_table_e join_table)
+int _check_optimized_query(advanced_handle_t* q_handle, target_table_e join_table)
 {
-       bool is_optimized_query = false;
+       int is_optimized_query = 0;
 
        if((q_handle->extra_info & CATEGORIES) == 0)
        {
@@ -1628,11 +1628,11 @@ bool _check_optimized_query(advanced_handle_t* q_handle, target_table_e join_tab
                        case ONLY_DATA_FROM_PERSON_QUERY:
                        {
                                if(q_handle->all_datatype_in_query == DATATYPE_NAME)
-                                       is_optimized_query = true;
+                                       is_optimized_query = 1;
                        }
                                break;
                        case ONLY_PERSON:
-                               is_optimized_query = true;
+                               is_optimized_query = 1;
                                break;
                        default:
                                break;
@@ -1702,7 +1702,7 @@ query_error _optimized_query_to_person_with_data(advanced_handle_t* q_handle, in
                g_string_append_printf(query, " %s order by %s", condition->str, field_key[FIELD_DATA_PERSON_ID]);
        }
 
-    q_handle->hstmt = _query_prepare(query->str);
+    q_handle->hstmt = _contact_query_prepare(query->str);
        ADVANCED_CATCH_SET_ERROR((q_handle->hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
        if(q_handle->use_normal_field_key->str[0] != '\0')
@@ -1713,12 +1713,12 @@ query_error _optimized_query_to_person_with_data(advanced_handle_t* q_handle, in
                        condition_val_t* tmp_val = (condition_val_t*)tmp_condition_val->data;
                        ADVANCED_SVC_TRACE("condition_val->value : %s", tmp_val->value);
 
-                       _query_bind_text(q_handle->hstmt, 1, tmp_val->value);
+                       _contact_query_bind_text(q_handle->hstmt, 1, tmp_val->value);
                        tmp_condition_val = g_list_next(tmp_condition_val);
                }
        }
 
-       rc = _query_step(q_handle->hstmt);
+       rc = _contact_query_step(q_handle->hstmt);
        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
        error_code = _query_result_set(q_handle, rc, count, NORMAL_CASE, JOIN_PERSON_DATA);
@@ -1730,7 +1730,7 @@ CATCH:
 
        if(error_code != QUERY_SUCCESS)
        {
-               _query_finalize(q_handle->hstmt);
+               _ct_query_finalize(q_handle->hstmt);
        }
 
        return error_code;
@@ -1754,7 +1754,7 @@ query_error _optimized_query_join_person_data(advanced_handle_t* q_handle, int c
                g_string_append_printf(projection, "%s", field_key[FIELD_PERSON_CONTACT_ID]);
 
                GList* tmp_projection = q_handle->projection;
-               bool projection_duplicate = false;
+               int projection_duplicate = 0;
                while(tmp_projection)
                {
                        projection_t* projection_info = (projection_t*)tmp_projection->data;
@@ -1773,7 +1773,7 @@ query_error _optimized_query_join_person_data(advanced_handle_t* q_handle, int c
                        }
 
                        tmp_projection = g_list_next(tmp_projection);
-                       projection_duplicate = false;
+                       projection_duplicate = 0;
                }
                g_list_foreach(q_handle->projection, _free_projection_list, NULL);
                g_list_free(q_handle->projection);
@@ -1801,7 +1801,7 @@ query_error _optimized_query_join_person_data(advanced_handle_t* q_handle, int c
        else
                g_string_append_printf(query, " %s order by %s", condition->str, field_key[FIELD_PERSON_CONTACT_ID]);
 
-    q_handle->hstmt = _query_prepare(query->str);
+    q_handle->hstmt = _contact_query_prepare(query->str);
        ADVANCED_CATCH_SET_ERROR((q_handle->hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
        if(strlen(q_handle->use_normal_field_key->str) != 0)
@@ -1812,12 +1812,12 @@ query_error _optimized_query_join_person_data(advanced_handle_t* q_handle, int c
                        condition_val_t* tmp_val = (condition_val_t*)tmp_condition_val->data;
                        ADVANCED_SVC_TRACE("condition_val->value : %s", tmp_val->value);
 
-                       _query_bind_text(q_handle->hstmt, 1, tmp_val->value);
+                       _contact_query_bind_text(q_handle->hstmt, 1, tmp_val->value);
                        tmp_condition_val = g_list_next(tmp_condition_val);
                }
        }
 
-       rc = _query_step(q_handle->hstmt);
+       rc = _contact_query_step(q_handle->hstmt);
        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
        error_code = _query_result_set(q_handle, rc, count, NORMAL_CASE, JOIN_PERSON_DATA);
@@ -1829,7 +1829,7 @@ CATCH:
 
        if(error_code != QUERY_SUCCESS)
        {
-               _query_finalize(q_handle->hstmt);
+               _ct_query_finalize(q_handle->hstmt);
        }
 
        return error_code;
@@ -1855,12 +1855,12 @@ query_error _get_categories_list(advanced_handle_t* q_handle, int count, char* c
 
        g_string_append_printf(query, " order by a.%s", relation_field_key[FIELD_GROUP_RELATION_CONTACT_ID]);
 
-    hstmt = _query_prepare(query->str);
+    hstmt = _contact_query_prepare(query->str);
        ADVANCED_CATCH_SET_ERROR((hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("Database prepare fail"));
 
        if(q_handle->condition_category != NULL)
        {
-               _query_bind_text(hstmt, 1, q_handle->condition_category);
+               _contact_query_bind_text(hstmt, 1, q_handle->condition_category);
        }else if(strlen(condition_query) != 0)
        {
                GList* tmp_condition_val = q_handle->condition_value;
@@ -1869,23 +1869,23 @@ query_error _get_categories_list(advanced_handle_t* q_handle, int count, char* c
                {
                        condition_val_t* tmp_val = (condition_val_t*)tmp_condition_val->data;
 
-                       if(tmp_val->indices_filter == false)
+                       if(tmp_val->indices_filter == 0)
                        {
                        primitive_type type = _convert_check_attribute_primitive_type(tmp_val->attribute);
-                       if(tmp_val->x_attribute == true)
+                       if(tmp_val->x_attribute == 1)
                                type = STRING;
 
                        if(type == INTEGER)
-                               _query_bind_int(hstmt, i++, tmp_val->int_value);
+                               _contact_query_bind_int(hstmt, i++, tmp_val->int_value);
                        else if(type == STRING)
-                               _query_bind_text(hstmt, i++, tmp_val->value);
+                               _contact_query_bind_text(hstmt, i++, tmp_val->value);
                        else if(type == REAL)
-                               _query_bind_double(hstmt, i++, tmp_val->real_value);
+                               _contact_query_bind_double(hstmt, i++, tmp_val->real_value);
                        }
                        tmp_condition_val = g_list_next(tmp_condition_val);
                }
        }
-       rc = _query_step(hstmt);
+       rc = _contact_query_step(hstmt);
        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
        while(rc == SQLITE_ROW)
@@ -1893,21 +1893,21 @@ query_error _get_categories_list(advanced_handle_t* q_handle, int count, char* c
                if(pos > count)
                        break;
 
-               q_handle->category[pos].contact_id = _query_column_int(hstmt, 0);
-               q_handle->category[pos].group_id = _query_column_int(hstmt, 1);
-               q_handle->category[pos].name = g_strdup(_query_column_text(hstmt, 2));
+               q_handle->category[pos].contact_id = _ct_query_column_int(hstmt, 0);
+               q_handle->category[pos].group_id = _ct_query_column_int(hstmt, 1);
+               q_handle->category[pos].name = g_strdup(_ct_query_column_text(hstmt, 2));
 
                ADVANCED_SVC_TRACE("q_handle->category[%d].contact_id : %d", pos, q_handle->category[pos].contact_id);
 
                if(q_handle->category[pos].contact_id == q_handle->category[pos - 1].contact_id)
-                       q_handle->category[pos].sibling = true;
+                       q_handle->category[pos].sibling = 1;
 
                pos++;
 
-               rc = _query_step(hstmt);
+               rc = _contact_query_step(hstmt);
        }
        q_handle->category_total_count = pos;
-       _query_finalize(hstmt);
+       _ct_query_finalize(hstmt);
 
 CATCH:
        g_string_free(query, TRUE);
@@ -1917,13 +1917,13 @@ CATCH:
 query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* query, target_table_e join_table, projection_type type, char* sub_query)
 {
        GString* condition;
-       bool is_first = true;
+       int is_first = 1;
        query_error error_code = QUERY_SUCCESS;
        condition = g_string_new ("");
-       bool is_sub_query = false;
+       int is_sub_query = 0;
 
        if(sub_query[0] != '\0')
-               is_sub_query = true;
+               is_sub_query = 1;
 
        if(is_sub_query)
        {
@@ -1944,13 +1944,13 @@ query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* quer
        if(join_table == ONLY_DATA || join_table == ONLY_DATA_FROM_PERSON_QUERY)
        {
                GList* tmp_datatype_list = q_handle->datatype_list;
-               is_first = true;
+               is_first = 1;
                while(tmp_datatype_list)
                {
                        datatype_t* datatype_info = (datatype_t*)tmp_datatype_list->data;
                        if(is_first)
                        {
-                               if(q_handle->use_normal_field_key->str[0] != '\0' && is_sub_query == false)
+                               if(q_handle->use_normal_field_key->str[0] != '\0' && is_sub_query == 0)
                                {
                                        g_string_append_printf(condition, "%s and %s = %d", q_handle->use_normal_field_key->str, datatype_info->field, datatype_info->datatype);
                                }else
@@ -1961,7 +1961,7 @@ query_error _construct_optimize_query(advanced_handle_t* q_handle, GString* quer
                        }
 
                        tmp_datatype_list = g_list_next(tmp_datatype_list);
-                       is_first = false;
+                       is_first = 0;
                }
        }
 
@@ -2032,7 +2032,7 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
        int count = 0;
        projection_type type = NORMAL_CASE;
        int i = 1;
-       bool is_optimized_query = false;
+       int is_optimized_query = 0;
        advanced_handle_t* q_handle = (advanced_handle_t*)handle;
 
        if(q_handle->result_set)
@@ -2045,7 +2045,7 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
                        {
                                q_handle->return_array_pos++;
                                ADVANCED_CATCH_SET_ERROR((q_handle->return_array_pos < q_handle->total_result_set_count), {}, QUERY_NO_RECORD, ("no record"));
-                               ADVANCED_CATCH_SET_ERROR((q_handle->result_set[q_handle->return_array_pos].is_occupied == true), {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR((q_handle->result_set[q_handle->return_array_pos].is_occupied == 1), {}, QUERY_NO_RECORD, ("no record"));
                        }else
                        {
                                q_handle->pos++;
@@ -2056,7 +2056,7 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
                {
                        q_handle->return_array_pos++;
                        ADVANCED_CATCH_SET_ERROR((q_handle->return_array_pos < q_handle->total_result_set_count), {}, QUERY_NO_RECORD, ("no record"));
-                       ADVANCED_CATCH_SET_ERROR((q_handle->result_set[q_handle->return_array_pos].is_occupied == true), {}, QUERY_NO_RECORD, ("no record"));
+                       ADVANCED_CATCH_SET_ERROR((q_handle->result_set[q_handle->return_array_pos].is_occupied == 1), {}, QUERY_NO_RECORD, ("no record"));
                }
        }else
        {
@@ -2075,10 +2075,10 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
 
                is_optimized_query = _check_optimized_query(q_handle, join_table);
 
-               if(is_optimized_query == true)
+               if(is_optimized_query == 1)
                {
                        ADVANCED_SVC_TRACE("!!!!!! EXECUTE OPTIMIZED QUERY !!!!!!");
-                       q_handle->is_optimized_query = true;
+                       q_handle->is_optimized_query = 1;
                        projection = g_string_new("");
 
                        if(q_handle->query_string == NULL)
@@ -2125,7 +2125,7 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
                        error_code = _construct_optimize_query(q_handle, query, join_table, type, sub_query->str);
                        ADVANCED_CATCH_SET_ERROR((error_code == QUERY_SUCCESS), {}, error_code, ("CONSTRUCT QUERY FAIL"));
 
-                   q_handle->hstmt = _query_prepare(query->str);
+                   q_handle->hstmt = _contact_query_prepare(query->str);
                        ADVANCED_CATCH_SET_ERROR((q_handle->hstmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
                        if(q_handle->use_normal_field_key->str[0] != '\0')
@@ -2134,26 +2134,26 @@ API query_error query_get_result_contact(ADVANCED_HANDLE handle)
                                while(tmp_condition_val)
                                {
                                        condition_val_t* tmp_val = (condition_val_t*)tmp_condition_val->data;
-                                       if(tmp_val->indices_filter == false)
+                                       if(tmp_val->indices_filter == 0)
                                        {
                                        ADVANCED_SVC_TRACE("condition_val->value : %s", tmp_val->value);
                                        primitive_type type = _convert_check_attribute_primitive_type(tmp_val->attribute);
-                                       if(tmp_val->x_attribute == true)
+                                       if(tmp_val->x_attribute == 1)
                                                type = STRING;
 
                                        if(type == INTEGER)
-                                               _query_bind_int(q_handle->hstmt, i++, tmp_val->int_value);
+                                               _contact_query_bind_int(q_handle->hstmt, i++, tmp_val->int_value);
                                        else if(type == STRING)
-                                               _query_bind_text(q_handle->hstmt, i++, tmp_val->value);
+                                               _contact_query_bind_text(q_handle->hstmt, i++, tmp_val->value);
                                        else if(type == REAL)
-                                               _query_bind_double(q_handle->hstmt, i++, tmp_val->real_value);
+                                               _contact_query_bind_double(q_handle->hstmt, i++, tmp_val->real_value);
                                        }
 
                                        tmp_condition_val = g_list_next(tmp_condition_val);
                                }
                        }
 
-                       rc = _query_step(q_handle->hstmt);
+                       rc = _contact_query_step(q_handle->hstmt);
                        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
                        error_code = _query_result_set(q_handle, rc, count, type, join_table);
@@ -2217,7 +2217,7 @@ API query_error query_finalize(ADVANCED_HANDLE handle)
        _free_handle_info(q_handle);
        q_handle = NULL;
 
-       error_code = _db_finish();
+       error_code = _contact_db_finish();
 
        return error_code;
 }
@@ -2300,7 +2300,7 @@ query_error _set_exists_condition(ADVANCED_HANDLE handle, contact_attribute_e at
                q_handle->condition_list = g_list_append(q_handle->condition_list, condition_info);
        }else
        {
-               q_handle->optimize_condition = false;
+               q_handle->optimize_condition = 0;
                g_string_append_printf(q_handle->use_contact_table_id, "(%s is not null)", field_key[FIELD_CONTACT_CONTACT_ID]);
                g_string_append_printf(q_handle->use_normal_field_key, "(%s is not null)", normal_column_name);
                g_string_append_printf(q_handle->condition_text, "(%s.%s is not null)", alias_key[tmp_current_alias], column_name);
@@ -2320,7 +2320,7 @@ API query_error query_set_condition(ADVANCED_HANDLE handle, contact_attribute_e
        char* normal_column_name = NULL;
        char* condition = NULL;
        char* table = NULL;
-       bool is_person_attr = false;
+       int is_person_attr = 0;
        condition_table_t* table_info = NULL;
        alias_key_e tmp_current_alias = ALIAS_INVALID;
 
@@ -2373,7 +2373,7 @@ API query_error query_set_condition(ADVANCED_HANDLE handle, contact_attribute_e
        if(q_handle->query_type == QUERY_TO_PERSON)
                is_person_attr = _convert_person_attribute_to_mimetype_id(attribute);
 
-       if(is_person_attr == false)
+       if(is_person_attr == 0)
        {
                datatype = _convert_attribute_to_mimetype_id(attribute);
                db_datatype_id = _convert_datatype_to_db_type(datatype);
@@ -2443,7 +2443,7 @@ API query_error query_set_condition(ADVANCED_HANDLE handle, contact_attribute_e
 
        }else
        {
-               q_handle->optimize_condition = false;
+               q_handle->optimize_condition = 0;
                g_string_append_printf(q_handle->use_contact_table_id, "(%s %s ?)", field_key[FIELD_CONTACT_CONTACT_ID], condition);
 
                g_string_append_printf(q_handle->use_normal_field_key, "(%s %s ?)", normal_column_name, condition);
@@ -2503,10 +2503,10 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
        {
                case DATATYPE_INVALID:
                        if(q_handle->query_type == QUERY_TO_CONTACT)
-                               q_handle->result_set[q_handle->return_array_pos].contact_info->get_raw_contact_info = true;
+                               q_handle->result_set[q_handle->return_array_pos].contact_info->get_raw_contact_info = 1;
                        else
-                               q_handle->result_set[q_handle->return_array_pos].contact_info->get_person_info = true;
-                       ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_NEXT_ROW, ("NOT MULTIPLE VALUE"));
+                               q_handle->result_set[q_handle->return_array_pos].contact_info->get_person_info = 1;
+                       ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_NEXT_ROW, ("NOT MULTIPLE VALUE"));
                        break;
                case DATATYPE_NUMBER:
                {
@@ -2529,7 +2529,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2554,7 +2554,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2579,7 +2579,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2603,7 +2603,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2633,7 +2633,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2662,7 +2662,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2688,13 +2688,13 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
                case DATATYPE_NAME :
-                       q_handle->result_set[q_handle->return_array_pos].contact_info->get_name = true;
-                       ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_NEXT_ROW, ("NOT MULTIPLE VALUE"));
+                       q_handle->result_set[q_handle->return_array_pos].contact_info->get_name = 1;
+                       ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_NEXT_ROW, ("NOT MULTIPLE VALUE"));
                        break;
                case DATATYPE_CATEGORY :
                {
@@ -2705,7 +2705,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                                if(q_handle->next_count != 0)
                                {
                                        ADVANCED_CATCH_SET_ERROR(((q_handle->category_pos + q_handle->next_count) < q_handle->category_total_count), {}, QUERY_NO_RECORD, ("no record"));
-                                       ADVANCED_CATCH_SET_ERROR((q_handle->category[q_handle->category_pos + q_handle->next_count].sibling != false), {}, QUERY_NO_RECORD, ("no record"));
+                                       ADVANCED_CATCH_SET_ERROR((q_handle->category[q_handle->category_pos + q_handle->next_count].sibling != 0), {}, QUERY_NO_RECORD, ("no record"));
                                        q_handle->category_pos = q_handle->category_pos + q_handle->next_count;
                                        q_handle->next_count++;
                                        return QUERY_SUCCESS;
@@ -2745,7 +2745,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                                }
                        }
                        q_handle->next_count = -1;
-                       ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                       ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                }
                        break;
                case DATATYPE_X_ATTRIBUTE :
@@ -2777,7 +2777,7 @@ API query_error fetch_next_row(ADVANCED_HANDLE handle)
                        }
                        else
                        {
-                               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+                               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
                        }
                }
                        break;
@@ -2800,14 +2800,14 @@ query_error _invalid_datatype_fetch_next_row(advanced_handle_t* handle, predefin
        {
                if(handle->query_type == QUERY_TO_CONTACT)
                {
-                       ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_raw_contact_info == false), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
+                       ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_raw_contact_info == 0), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
                }else if(handle->query_type == QUERY_TO_PERSON)
                {
-                       ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_person_info == false), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
+                       ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_person_info == 0), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
                }
        }else if(datatype == DATATYPE_NAME)
        {
-               ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_name == false), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
+               ADVANCED_RETURN_VAL((handle->result_set[handle->return_array_pos].contact_info->get_name == 0), {}, QUERY_NO_NEXT_ROW, ("NO ROW"));
        }
 
        return error_code;
@@ -3192,7 +3192,7 @@ API query_error query_set_condition_append(ADVANCED_HANDLE handle, condition_typ
        char* type_string = NULL;
 
        if(type == AND)
-               q_handle->optimize_condition = false;
+               q_handle->optimize_condition = 0;
 
        type_string = _convert_condition_type_to_string(type);
        g_string_append_printf (q_handle->condition_text, " %s ", type_string);
@@ -3263,7 +3263,7 @@ API query_error query_set_x_condition(ADVANCED_HANDLE handle, int cts_custom_typ
        char* condition = NULL;
        char* table = NULL;
        condition_table_t* table_info = NULL;
-       bool new_custom_type = false;
+       int new_custom_type = 0;
        alias_key_e tmp_current_alias = ALIAS_INVALID;
 
        if(attr == EXISTS)
@@ -3293,10 +3293,10 @@ API query_error query_set_x_condition(ADVANCED_HANDLE handle, int cts_custom_typ
 
                        if(tmp_info->datatype != cts_custom_type_index)
                        {
-                               new_custom_type = true;
+                               new_custom_type = 1;
                        }else
                        {
-                               new_custom_type = false;
+                               new_custom_type = 0;
                                tmp_current_alias = tmp_info->current_alias;
                                break;
                        }
@@ -3338,7 +3338,7 @@ API query_error query_set_x_condition(ADVANCED_HANDLE handle, int cts_custom_typ
        condition_val_t* condition_txt = NULL;
        condition_txt = g_new0(condition_val_t, 1);
        condition_txt->value = g_strdup(value);
-       condition_txt->x_attribute = true;
+       condition_txt->x_attribute = 1;
        q_handle->condition_value = g_list_append(q_handle->condition_value, condition_txt);
 
        q_handle->condition_datatype = q_handle->condition_datatype | DATATYPE_X_ATTRIBUTE;
@@ -3370,7 +3370,7 @@ query_error query_get_next_limit_result_set(ADVANCED_HANDLE handle, int window_s
        q_handle->start_pos = _free_for_limit_iter(q_handle);
        ADVANCED_SVC_TRACE("q_handle->start_pos : %d", q_handle->start_pos);
 
-       q_handle->limit_iter = true;
+       q_handle->limit_iter = 1;
        q_handle->total_result_set_count = 0;
        q_handle->pos = -1;
        q_handle->old_contact_id = 0;
@@ -3421,7 +3421,7 @@ API query_error query_next_custom_type(ADVANCED_HANDLE handle)
        }
        else
        {
-               ADVANCED_CATCH_SET_ERROR(false, {}, QUERY_NO_RECORD, ("no record"));
+               ADVANCED_CATCH_SET_ERROR(0, {}, QUERY_NO_RECORD, ("no record"));
        }
        ADVANCED_SVC_TRACE("error_code : %d", error_code);
 
@@ -3506,7 +3506,7 @@ API query_error query_set_condition_with_indices_end(ADVANCED_HANDLE handle)
        table_info->table = g_strdup(table);
        q_handle->condition_table_list = g_list_append(q_handle->condition_table_list, table_info);
 
-       q_handle->optimize_condition = false;
+       q_handle->optimize_condition = 0;
        g_string_append_printf(q_handle->use_contact_table_id, "(%s in %s)", field_key[FIELD_CONTACT_CONTACT_ID], q_handle->id_list->str);
        g_string_append_printf(q_handle->use_normal_field_key, "(%s in %s)", normal_column_name, q_handle->id_list->str);
 
@@ -3516,7 +3516,7 @@ API query_error query_set_condition_with_indices_end(ADVANCED_HANDLE handle)
        condition_txt = g_new0(condition_val_t, 1);
 
        condition_txt->attribute = CONTACT_ID;
-       condition_txt->indices_filter = true;
+       condition_txt->indices_filter = 1;
 
        q_handle->condition_value = g_list_append(q_handle->condition_value, condition_txt);
 
@@ -3529,9 +3529,9 @@ API query_error query_set_condition_with_indices(ADVANCED_HANDLE handle, const c
        advanced_handle_t* q_handle = (advanced_handle_t*)handle;
        query_error error_code = QUERY_SUCCESS;
 
-       if(q_handle->is_first_id_in_list == false)
+       if(q_handle->is_first_id_in_list == 0)
        {
-               q_handle->is_first_id_in_list = true;
+               q_handle->is_first_id_in_list = 1;
                g_string_append_printf(q_handle->id_list, "%s", contact_index);
        }else
        {
@@ -3549,23 +3549,23 @@ API int get_contact_version()
        int ver = 0;
        query_error error_code = QUERY_SUCCESS;
 
-       error_code = _db_init();
+       error_code = _contact_db_init();
        ADVANCED_CATCH_SET_ERROR((error_code == QUERY_SUCCESS), {}, QUERY_STATEMENT_FAIL, ("DATABASE INIT FAIL"));
 
        sprintf(query, "select max(ver) from cts_version");
 
-    pStmt = _query_prepare(query);
+       pStmt = _contact_query_prepare(query);
        ADVANCED_CATCH_SET_ERROR((pStmt != NULL), {}, QUERY_STATEMENT_FAIL, ("database prepare fail"));
 
-       rc = _query_step(pStmt);
+       rc = _contact_query_step(pStmt);
        ADVANCED_CATCH_SET_ERROR((rc == SQLITE_ROW), {}, QUERY_NO_RECORD, ("No record in database"));
 
-       ver = _query_column_int(pStmt, 0);
+       ver = _ct_query_column_int(pStmt, 0);
        ADVANCED_SVC_TRACE("get_contact_version :: ver : %d ", ver);
 
-CATCH:
-       _query_finalize(pStmt);
-       _db_finish();
+       CATCH:
+       _ct_query_finalize(pStmt);
+       _contact_db_finish();
 
        return ver;
 }
index 1b6915a..ca8c6db 100755 (executable)
@@ -462,14 +462,14 @@ typedef struct
        event_info_t* event_info;
        x_info_t* x_info;
 
-       bool get_name;
-       bool get_raw_contact_info;
-       bool get_person_info;
+       int get_name;
+       int get_raw_contact_info;
+       int get_person_info;
 }contact_t;
 
 typedef struct
 {
-       bool is_occupied;
+       int is_occupied;
        contact_t* contact_info;
 }result_t;
 
@@ -500,8 +500,8 @@ typedef struct
        int int_value;
        double real_value;
        char* value;
-       bool x_attribute;
-       bool indices_filter;
+       int x_attribute;
+       int indices_filter;
 }condition_val_t;
 
 typedef struct
@@ -529,7 +529,7 @@ typedef struct
        int group_id;
        int contact_id;
        char* name;
-       bool sibling;
+       int sibling;
 }categories_info;
 
 typedef enum
@@ -553,7 +553,7 @@ typedef struct
 
 // result set
        int pos;                                //array index of ordering list
-       bool is_optimized_query;
+       int is_optimized_query;
 
 // query
        predefine_datatype      assigned_datatype;
@@ -590,7 +590,7 @@ typedef struct
        GList* condition_value;
        alias_key_e current_alias;
        predefine_datatype condition_datatype;
-       bool optimize_condition;
+       int optimize_condition;
        GList* condition_list;
        GList* condition_table_list;
        char* condition_category;
@@ -609,7 +609,7 @@ typedef struct
 // set limit
        int start_pos;
        int window_size;
-       bool limit_iter;
+       int limit_iter;
 
 // the others
        int total_result_set_count;
@@ -624,7 +624,7 @@ typedef struct
 
 // indices
        GString* id_list;
-       bool is_first_id_in_list;
+       int is_first_id_in_list;
 }advanced_handle_t;
 
 #ifdef __cplusplus
index ca5fea4..3703031 100755 (executable)
@@ -43,7 +43,7 @@ _get_clock()
        return curtime;
 }
 
-bool
+void
 _print_time(clock_t begin, clock_t finish, const char* function_name)
 {
        double totaltime = 0.0;
@@ -55,11 +55,9 @@ _print_time(clock_t begin, clock_t finish, const char* function_name)
 //     PERFORMANCE_TRACE("finish time  [%ld us] ", finish);
        PERFORMANCE_TRACE("total time   [%f s] ", totaltime);
        PERFORMANCE_TRACE("......................................................................... ");
-
-       return true;
 }
 
-query_error _db_init()
+query_error _contact_db_init()
 {
        int rc = 0;
        query_error error_code = QUERY_SUCCESS;
@@ -74,7 +72,7 @@ query_error _db_init()
        return error_code;
 }
 
-query_error _db_finish()
+query_error _contact_db_finish()
 {
        int rc = 0;
        query_error error_code = QUERY_SUCCESS;
@@ -91,7 +89,7 @@ query_error _db_finish()
        return error_code;
 }
 
-query_error _exec_query(char* query)
+query_error _contact_exec_query(char* query)
 {
        int rc = -1;
        char* pszErrorMsg = NULL;
@@ -120,7 +118,7 @@ query_error _trans_begin(void)
 
        if(transaction_count == 0)
        {
-               rc = _exec_query("BEGIN IMMEDIATE TRANSACTION");
+               rc = _contact_exec_query("BEGIN IMMEDIATE TRANSACTION");
                if(SQLITE_OK != rc)
                {
                        ADVANCED_SVC_TRACE("contact_util_query_exec failed(%d).\n", rc);
@@ -133,17 +131,17 @@ query_error _trans_begin(void)
        return error_code;
 }
 
-query_error _trans_end(bool is_success)
+query_error _trans_end(int is_success)
 {
        int     rc = -1;
        query_error             error_code = QUERY_SUCCESS;
 
        if(transaction_count == 1)
        {
-               if(is_success == true)
-                       rc = _exec_query("COMMIT TRANSACTION");
+               if(is_success == 1)
+                       rc = _contact_exec_query("COMMIT TRANSACTION");
                else
-                       rc = _exec_query("ROLLBACK TRANSACTION");
+                       rc = _contact_exec_query("ROLLBACK TRANSACTION");
 
                if(SQLITE_OK != rc)
                {
@@ -163,12 +161,12 @@ query_error _trans_end(bool is_success)
 }
 
 
-int _query_step(stmt pStmt)
+int _contact_query_step(stmt pStmt)
 {
        return sqlite3_step(pStmt);
 }
 
-void _contact_query_finalize(stmt pStmt)
+void _ct_query_finalize(stmt pStmt)
 {
        int rc = -1;
 
@@ -181,41 +179,27 @@ void _contact_query_finalize(stmt pStmt)
        }
 }
 
-int _contact_query_column_int(stmt pStmt, int pos)
+int _ct_query_column_int(stmt pStmt, int pos)
 {
        return (int)sqlite3_column_int(pStmt, pos);
 }
 
-char* _contact_query_column_text(stmt pStmt, int pos)
+char* _ct_query_column_text(stmt pStmt, int pos)
 {
        return (char *)sqlite3_column_text(pStmt, pos);
 }
 
-void _query_finalize(stmt pStmt)
-{
-       int rc = -1;
-
-       if(!pStmt)
-         return;
-
-       rc = sqlite3_finalize(pStmt);
-       if(rc != SQLITE_OK)
-       {
-
-       }
-}
-
-int _query_bind_double(stmt pStmt, int pos, double num)
+int _contact_query_bind_double(stmt pStmt, int pos, double num)
 {
    return sqlite3_bind_double(pStmt, pos, num);
 }
 
-int _query_bind_int(stmt pStmt, int pos, int num)
+int _contact_query_bind_int(stmt pStmt, int pos, int num)
 {
    return sqlite3_bind_int(pStmt, pos, num);
 }
 
-int _query_bind_text(stmt pStmt, int pos, char* str)
+int _contact_query_bind_text(stmt pStmt, int pos, char* str)
 {
        int len = 0;
        if(str != NULL)
@@ -226,28 +210,18 @@ int _query_bind_text(stmt pStmt, int pos, char* str)
        return -1;
 }
 
-void _query_stmt_reset(stmt stmt)
+void _contact_query_stmt_reset(stmt stmt)
 {
    sqlite3_reset(stmt);
    sqlite3_clear_bindings(stmt);
 }
 
-int _query_column_int(stmt pStmt, int pos)
-{
-   return sqlite3_column_int(pStmt, pos);
-}
-
-double _query_column_double(stmt pStmt, int pos)
+double _contact_query_column_double(stmt pStmt, int pos)
 {
    return sqlite3_column_double(pStmt, pos);
 }
 
-char* _query_column_text(stmt pStmt, int pos)
-{
-   return (char *)sqlite3_column_text(pStmt, pos);
-}
-
-stmt _query_prepare(char *query)
+stmt _contact_query_prepare(char *query)
 {
        int rc = -1;
        stmt pStmt = NULL;
@@ -265,9 +239,9 @@ stmt _query_prepare(char *query)
        return pStmt;
 }
 
-bool _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute)
+int _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute)
 {
-       bool is_person_attr = false;
+       int is_person_attr = 0;
 
        switch(attribute)
        {
@@ -276,10 +250,10 @@ bool _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute)
                case NAME_LAST:
                case NAME_PREFIX:
                case NAME_PHONETIC:
-                       is_person_attr = true;
+                       is_person_attr = 1;
                        break;
                default:
-                       is_person_attr = false;
+                       is_person_attr = 0;
        }
        ADVANCED_SVC_TRACE("is_person_attr : %d", is_person_attr);
 
@@ -1766,18 +1740,18 @@ query_error _normalize_str(const char* src, char* dest, int dest_size)
        result = g_new0(UChar, (dest_size + 1));
 
        u_strFromUTF8(tmp_result, dest_size, NULL, src, -1, &status);
-       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == false), {}, QUERY_NORMALIZATION_ERROR, ("u_strFromUTF8 FAIL(%s)", u_errorName(status)));
+       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strFromUTF8 FAIL(%s)", u_errorName(status)));
 
        u_strToLower(tmp_result, dest_size, tmp_result, -1, NULL, &status);
-       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == false), {}, QUERY_NORMALIZATION_ERROR, ("u_strToLower FAIL(%s)", u_errorName(status)));
+       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strToLower FAIL(%s)", u_errorName(status)));
 
        ADVANCED_SVC_TRACE("src : %s", src);
 
        size = unorm_normalize(tmp_result, -1, UNORM_NFD, 0, (UChar *)result, dest_size, &status);
-       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == false), {}, QUERY_NORMALIZATION_ERROR, ("unorm_normalize FAIL(%s)", u_errorName(status)));
+       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("unorm_normalize FAIL(%s)", u_errorName(status)));
 
        u_strToUTF8(dest, dest_size, &size, result, -1, &status);
-       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == false), {}, QUERY_NORMALIZATION_ERROR, ("u_strToUTF8 FAIL(%s)", u_errorName(status)));
+       ADVANCED_CATCH_SET_ERROR((U_FAILURE(status) == 0), {}, QUERY_NORMALIZATION_ERROR, ("u_strToUTF8 FAIL(%s)", u_errorName(status)));
 
        ADVANCED_SVC_TRACE("dest : %s", (char *)dest);
 
@@ -1941,9 +1915,14 @@ int _convert_type_string_to_int(contact_attribute_e attribute, const char* value
                        for(i = 1; i < URL_TYPE_MAX; i++)
                        {
                                if(strcmp(url_type_str[i], value) == 0)
+                               {
                                        integer_value = URL_HOME;
-                               else
+                                       break;
+                               }else
+                               {
                                        integer_value = URL_WORK;
+                                       break;
+                               }
                        }
                }
                        break;
@@ -1986,9 +1965,14 @@ int _convert_type_string_to_int(contact_attribute_e attribute, const char* value
                        for(i = 0; i < EVENT_TYPE_MAX; i++)
                        {
                                if(strcmp(event_type_str[i], value) == 0)
+                               {
                                        integer_value = EVENT_BIRTHDAY;
-                               else
+                                       break;
+                               }else
+                               {
                                        integer_value = EVENT_ANNIVERSARY;
+                                       break;
+                               }
                        }
                }
                        break;
index 871ab6f..4eddacf 100755 (executable)
@@ -337,45 +337,39 @@ static char* condition_type_key[CONDITION_TYPE_MAX] =
 
 clock_t _get_clock();
 
-bool _print_time(clock_t begin, clock_t finish, const char* function_name);
+void _print_time(clock_t begin, clock_t finish, const char* function_name);
 
-query_error _db_init();
+query_error _contact_db_init();
 
-query_error _db_finish();
+query_error _contact_db_finish();
 
 query_error _trans_begin(void);
 
-query_error _trans_end(bool is_success);
+query_error _trans_end(int is_success);
 
-query_error _exec_query(char* query);
+query_error _contact_exec_query(char* query);
 
-int _query_step(stmt pStmt);
+int _contact_query_step(stmt pStmt);
 
-void _contact_query_finalize(stmt pStmt);
+void _ct_query_finalize(stmt pStmt);
 
-int _contact_query_column_int(stmt pStmt, int pos);
+int _ct_query_column_int(stmt pStmt, int pos);
 
-char* _contact_query_column_text(stmt pStmt, int pos);
+char* _ct_query_column_text(stmt pStmt, int pos);
 
-void _query_finalize(stmt pStmt);
+int _contact_query_bind_int(stmt pStmt, int pos, int num);
 
-int _query_bind_int(stmt pStmt, int pos, int num);
+int _contact_query_bind_double(stmt pStmt, int pos, double num);
 
-int _query_bind_double(stmt pStmt, int pos, double num);
+int _contact_query_bind_text(stmt pStmt, int pos, char* str);
 
-int _query_bind_text(stmt pStmt, int pos, char* str);
+void _contact_query_stmt_reset(stmt stmt);
 
-void _query_stmt_reset(stmt stmt);
+double _contact_query_column_double(stmt pStmt, int pos);
 
-int _query_column_int(stmt pStmt, int pos);
+stmt _contact_query_prepare(char *query);
 
-double _query_column_double(stmt pStmt, int pos);
-
-char* _query_column_text(stmt pStmt, int pos);
-
-stmt _query_prepare(char *query);
-
-bool _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute);
+int _convert_person_attribute_to_mimetype_id(contact_attribute_e attribute);
 
 predefine_datatype _convert_attribute_to_mimetype_id(contact_attribute_e attribute);
 
diff --git a/src/platform/Tizen/Filesystem/Command.cpp b/src/platform/Tizen/Filesystem/Command.cpp
deleted file mode 100755 (executable)
index 7c5a1b4..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "Command.h"
-#include <cstdlib>
-#include <Commons/Exception.h>
-
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-void Command::execute()
-{
-    int result = system(prepare().c_str());
-    if (-1 != result) {
-        if (0 != WIFEXITED(result)) {
-            if (0 != WEXITSTATUS(result)) {
-                ThrowMsg(Commons::PlatformException, "Command failed.");
-            }
-        } else {
-            ThrowMsg(Commons::PlatformException,
-                     "Command terminated abnormally.");
-        }
-    } else {
-        ThrowMsg(Commons::PlatformException, "Couldn't launch command.");
-    }
-}
-}
-}
-}
diff --git a/src/platform/Tizen/Filesystem/Command.h b/src/platform/Tizen/Filesystem/Command.h
deleted file mode 100755 (executable)
index 088a0fc..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_FILESYSTEM_COMMAND_H_
-#define TIZENAPIS_FILESYSTEM_COMMAND_H_
-
-#include <string>
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-class Command
-{
-  public:
-    virtual ~Command()
-    {
-    }
-    void execute();
-
-  protected:
-    /**
-     * Returns command converted into string that has to be safe to be executed
-     * using system() function (@see man 3p system).
-     * @attention Underlying command has to be passed by absolute path.
-     *            E.g. use '/bin/cp' instead of just 'cp'.
-     * @attention Do not chain a few commands as one.
-     *            This is wrong: 'cmd1 && cmd2; cmd3'.
-     * @return Command string - please ensure that the command is safe to run.
-     */
-    virtual std::string prepare() = 0;
-};
-}
-}
-}
-
-#endif // TIZENAPIS_FILESYSTEM_COMMAND_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Filesystem/CopyCommand.cpp b/src/platform/Tizen/Filesystem/CopyCommand.cpp
deleted file mode 100755 (executable)
index f97733e..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "CopyCommand.h"
-#include <sstream>
-
-namespace {
-const char* COMMAND_NAME = "/bin/cp";
-const char* COMMAND_SWITCH_RECURSIVE = "-r";
-const char* COMMAND_SWITCH_FORCE = "-f";
-}
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-CopyCommand::CopyCommand(const Api::Filesystem::IPathPtr& src,
-        const Api::Filesystem::IPathPtr& dest) :
-    m_src(src),
-    m_dest(dest),
-    m_recursive(false),
-    m_force(false)
-{
-}
-
-void CopyCommand::setRecursive(bool recursive)
-{
-    m_recursive = recursive;
-}
-
-void CopyCommand::setForce(bool force)
-{
-    m_force = force;
-}
-
-std::string CopyCommand::prepare()
-{
-    std::ostringstream oss;
-    oss << COMMAND_NAME;
-
-    if (m_recursive) {
-        oss << " " << COMMAND_SWITCH_RECURSIVE;
-    }
-
-    if (m_force) {
-        oss << " " << COMMAND_SWITCH_FORCE;
-    }
-
-    oss << " \"" << m_src->getFullPath().c_str() << "\"";
-    oss << " \"" << m_dest->getFullPath().c_str() << "\"";
-
-    return oss.str();
-}
-}
-}
-}
diff --git a/src/platform/Tizen/Filesystem/CopyCommand.h b/src/platform/Tizen/Filesystem/CopyCommand.h
deleted file mode 100755 (executable)
index de6527b..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_FILESYSTEM_COPYCOMMAND_H_
-#define TIZENAPIS_FILESYSTEM_COPYCOMMAND_H_
-
-#include "Command.h"
-#include <API/Filesystem/IPath.h>
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-class CopyCommand : public Command
-{
-  public:
-    CopyCommand(const Api::Filesystem::IPathPtr& src,
-            const Api::Filesystem::IPathPtr& dest);
-    void setRecursive(bool recursive);
-    void setForce(bool force);
-
-  protected:
-    std::string prepare();
-
-  private:
-    Api::Filesystem::IPathPtr m_src;
-    Api::Filesystem::IPathPtr m_dest;
-    bool m_recursive;
-    bool m_force;
-};
-}
-}
-}
-
-#endif // TIZENAPIS_FILESYSTEM_COPYCOMMAND_H_
\ No newline at end of file
index c830e02..58dcfa7 100755 (executable)
 #include <API/Filesystem/PathUtils.h>
 #include <API/Filesystem/StorageProperties.h>
 #include "Node.h"
-#include "System.h"
-#include "CopyCommand.h"
-#include "MoveCommand.h"
-#include "RemoveCommand.h"
 #include "Utils.h"
 #include <app.h>
 
@@ -295,6 +291,49 @@ void Manager::find(const Api::Filesystem::IPathPtr& path,
     }
 }
 
+void Manager::copyElement(
+        const std::string &src, const std::string &dest, bool recursive) const
+{
+    LogDebug("Copying src: " << src << " to: " << dest);
+
+    //element is a file:
+    if (EINA_TRUE != ecore_file_is_dir(src.c_str())) {
+        if (EINA_TRUE != ecore_file_cp(src.c_str(), dest.c_str())) {
+            ThrowMsg(Commons::PlatformException, "Failed to copy file");
+        }
+        return;
+    }
+    //element is a directory -> create it:
+    if (EINA_TRUE != ecore_file_mkdir(dest.c_str())) {
+        LogDebug("Failed to create destination directory");
+        ThrowMsg(Commons::PlatformException, "Failed to copy directory");
+    }
+    //copy all elements of directory:
+    if (recursive) {
+        Eina_List* list = ecore_file_ls(src.c_str());
+        void* data;
+        EINA_LIST_FREE(list, data)
+        {
+            Try
+            {
+                copyElement((src + '/' + static_cast<char*>(data)).c_str(),
+                            (dest + '/' + static_cast<char*>(data)).c_str());
+            }
+            Catch(Commons::PlatformException)
+            {
+                //remove rest of the list
+                EINA_LIST_FREE(list, data)
+                {
+                    free(data);
+                }
+                ReThrowMsg(Commons::PlatformException, "Failed to copy element");
+            }
+            free(data);
+        }
+    }
+
+}
+
 bool Manager::access(const IPathPtr& path,
         int accessType) const
 {
@@ -324,10 +363,11 @@ long Manager::addStorageStateChangeListener(
 void Manager::removeStorageStateChangeListener(EventStorageStateChangedEmitter::IdType id)
 {
        watcherList::iterator itWatcher = Manager::m_watchers.begin();
-
+       bool found = false;
        for (;itWatcher != Manager::m_watchers.end();) {
                if (id == (*itWatcher)->getEmitter()->getId()) {
                        itWatcher = Manager::m_watchers.erase(itWatcher);
+                       found = true;
                        continue;
                }
                ++itWatcher;
@@ -339,6 +379,11 @@ void Manager::removeStorageStateChangeListener(EventStorageStateChangedEmitter::
                        storage_unset_state_changed_cb(itRoot->second);
                }
        }
+
+       if (found == false) {
+//             LogDebug("no exist" << id);
+               ThrowMsg(Commons::NotFoundException, "The " << id << "is not exist");
+       }
 }
 
 bool Manager::matchFilters(const std::string& name,
@@ -376,8 +421,10 @@ void Manager::OnRequestReceived(const EventResolvePtr& event)
         event->setResult(Node::resolve(event->getPath()));
     }
     catch (const Commons::PlatformException& ex) {
+        LogError("Exception: " << ex.GetMessage());
         event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
     }
+
 }
 
 void Manager::OnRequestReceived(const EventGetStoragePtr& event)
@@ -448,7 +495,8 @@ void Manager::OnRequestReceived(const EventCopyPtr& event)
 {
     Try {
         INodePtr srcNode = Node::resolve(event->getSource());
-        if ((srcNode->getMode() & PERM_READ) == 0) {
+               LogDebug(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
+        if ((srcNode->getMode() & PM_USER_READ/*PERM_READ*/) == 0) {
             ThrowMsg(Commons::SecurityException,
                      "Not enough permissions to read source node.");
         }
@@ -489,21 +537,48 @@ void Manager::OnRequestReceived(const EventCopyPtr& event)
             ThrowMsg(Commons::PlatformException,
                      "No access to platform destination node.");
         }
-
-        if (((event->getOptions() & OPT_OVERWRITE) == 0) && (status == 0)) {
-            ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
+               
+        if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
+            dest->append("/" + src->getName());
+            realDest = dest->getFullPath();
+            memset(&info, 0, sizeof(struct stat));
+            status = lstat(realDest.c_str(), &info);
+            if ((status != 0) && (errno != ENOENT)) {
+                ThrowMsg(Commons::PlatformException,
+                            "No access to platform destination node.");
+            }
         }
 
-        if (event->getOptions() & OPT_OVERWRITE) {
-            DPL::ScopedPtr<RemoveCommand> remove(new RemoveCommand(dest));
-            remove->setRecursive(true);
-            remove->setForce(true);
-            System::run(remove.Get());
-        }
+        if (0 == status) {
+            //no owerwrite flag setted -> exception
+            if ((event->getOptions() & OPT_OVERWRITE) == 0) {
+                ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
+            }
 
-        DPL::ScopedPtr<CopyCommand> copy(new CopyCommand(src, dest));
-        copy->setRecursive(true);
-        System::run(copy.Get());
+            if (event->checkCancelled()) {
+                //file is not copied yet, so we can cancel it now.
+                event->setCancelAllowed(true);
+                return;
+            }
+
+            //destination exist. Need to be removed
+            Try {
+                INodePtr node = Node::resolve(dest);
+                node->remove(event->getOptions());
+            }
+            Catch(Commons::PlatformException) {
+                LogError("Exception: " << _rethrown_exception.GetMessage());
+                event->setExceptionCode(
+                    Commons::ExceptionCodes::PlatformException);
+            }
+            Catch(Commons::SecurityException) {
+                event->setExceptionCode(
+                    Commons::ExceptionCodes::SecurityException);
+            }
+        }
+        //Destination is not exist. Start copy now.
+               LogDebug(dest->getFullPath().c_str());
+        copyElement(realSrc, realDest);
 
         event->setResult(Node::resolve(dest));
     }
@@ -513,19 +588,24 @@ void Manager::OnRequestReceived(const EventCopyPtr& event)
     Catch(Commons::SecurityException) {
         event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
     }
+    //file is copied already so we don't allow cancelling anymore.
+    event->setCancelAllowed(false);
 }
 
 void Manager::OnRequestReceived(const EventMovePtr& event)
 {
     try {
-        INodePtr srcNode = Node::resolve(event->getSource());
-        if ((srcNode->getMode() & PERM_WRITE) == 0) {
+        IPathPtr src = event->getSource();
+        IPathPtr dest = event->getDestination();
+
+        INodePtr srcNode = Node::resolve(src);
+               LogDebug(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_WRITE);
+        if ((srcNode->getMode() & PM_USER_WRITE/*PERM_WRITE*/) == 0)
+        {
             ThrowMsg(Commons::SecurityException,
                      "Not enough permissions to move source node.");
         }
 
-        IPathPtr src = event->getSource();
-        IPathPtr dest = event->getDestination();
         if (!dest->isAbsolute()) {
             dest = src->getPath() + *dest;
         }
@@ -549,40 +629,103 @@ void Manager::OnRequestReceived(const EventMovePtr& event)
                      "Destination's parent node is not directory.");
         }
 
-        std::string realSrc = src->getFullPath();
-        std::string realDest = dest->getFullPath();
-
         errno = 0;
         struct stat info;
-        memset(&info, 0, sizeof(struct stat));
-        int status = lstat(realDest.c_str(), &info);
+        memset(&info, 0, sizeof(info));
+        int status = lstat(dest->getFullPath().c_str(), &info);
         if ((status != 0) && (errno != ENOENT)) {
             ThrowMsg(Commons::PlatformException,
                      "No access to platform destination node.");
         }
 
-        if (((event->getOptions() & OPT_OVERWRITE) == 0) && (status == 0)) {
+        LogDebug(dest->getFullPath().c_str());
+               
+        if (S_ISDIR(info.st_mode) && srcNode->getType() == NT_FILE) {
+                       dest->append("/" + src->getName());
+                       memset(&info, 0, sizeof(info));
+                       status = lstat(dest->getFullPath().c_str(), &info);
+                       if ((status != 0) && (errno != ENOENT)) {
+                   ThrowMsg(Commons::PlatformException,
+                           "No access to platform destination node.");
+                       }
+        } 
+
+               if (status == 0 && 0 == (event->getOptions() & OPT_OVERWRITE)) {
             ThrowMsg(Commons::PlatformException, "Overwrite is not set.");
         }
 
-        if (event->getOptions() & OPT_OVERWRITE) {
-            DPL::ScopedPtr<RemoveCommand> remove(new RemoveCommand(dest));
-            remove->setRecursive(true);
-            remove->setForce(true);
-            System::run(remove.Get());
+        if (event->checkCancelled()) {
+            //file is not moved yet, so we can cancel it now.
+            event->setCancelAllowed(true);
+            return;
         }
 
-        DPL::ScopedPtr<MoveCommand> move(new MoveCommand(src, dest));
-        System::run(move.Get());
+        errno = 0;
+       
+        LogDebug(dest->getFullPath().c_str());
+               
+        if (0 != ::rename(src->getFullPath().c_str(), dest->getFullPath().c_str()))
+        {
+            int error = errno;
+            switch (error)
+            {
+            case EXDEV:
+                {
+                                       LogDebug(std::hex << srcNode->getMode() << " " << std::hex << PM_USER_READ);
+                    if ((srcNode->getMode() & PM_USER_READ /*PERM_READ*/) == 0)
+                    {
+                        ThrowMsg(Commons::SecurityException,
+                                 "Not enough permissions to move source node.");
+                    }
+                    if (0 == status) {
+                        //destination exist. Need to be removed
+                        Try {
+                            INodePtr node = Node::resolve(dest);
+                            node->remove(event->getOptions());
+                        }
+                        Catch(Commons::PlatformException) {
+                            LogError("Exception while removing dest directory");
+                            event->setExceptionCode(
+                                Commons::ExceptionCodes::PlatformException);
+                        }
+                        Catch(Commons::SecurityException) {
+                            event->setExceptionCode(
+                                Commons::ExceptionCodes::SecurityException);
+                        }
+                    }
+
+                    copyElement(src->getFullPath(),
+                                dest->getFullPath());
+                    //remove source files
+                    Try {
+                        INodePtr node = Node::resolve(event->getSource());
+                        node->remove(event->getOptions());
+                    }
+                    Catch(Commons::Exception) {
+                        LogError("Exception: "
+                                 << _rethrown_exception.GetMessage());
+                    }
+                    break;
+                }
+            default:
+                               // needtofix
+                ThrowMsg(Commons::PlatformException,
+                         "Error on rename: " /*<< DPL::GetErrnoString(error)*/);
+                break;
+            }
+        }
 
         event->setResult(Node::resolve(dest));
     }
     catch (const Commons::PlatformException& ex) {
+        LogError("Exception: " << ex.GetMessage());
         event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
     }
     catch (const Commons::SecurityException& ex) {
+        LogError("Exception: " << ex.GetMessage());
         event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
     }
+    event->setCancelAllowed(false);
 }
 
 void Manager::OnRequestReceived(const EventCreatePtr& event)
@@ -596,15 +739,21 @@ void Manager::OnRequestReceived(const EventCreatePtr& event)
 
 void Manager::OnRequestReceived(const EventRemovePtr& event)
 {
-    Try {
-        INodePtr node = Node::resolve(event->getPath());
-        node->remove(event->getOptions());
-    }
-    Catch(Commons::PlatformException) {
-        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-    }
-    Catch(Commons::SecurityException) {
-        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    if (!event->checkCancelled()) {
+        Try {
+            INodePtr node = Node::resolve(event->getPath());
+            node->remove(event->getOptions());
+        }
+        Catch(Commons::PlatformException) {
+            LogError("Exception: " << _rethrown_exception.GetMessage());
+            event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+        }
+        Catch(Commons::SecurityException) {
+            event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+        }
+        event->setCancelAllowed(false);
+    } else {
+        event->setCancelAllowed(true);
     }
 }
 
@@ -616,8 +765,10 @@ void Manager::OnRequestReceived(const EventFindPtr& event)
         event->setResult(result);
     }
     catch (const Commons::Exception& ex) {
+        LogError("Exception: " << ex.GetMessage());
         event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
     }
+    event->setCancelAllowed(true);
 }
 
 void Manager::addLocalStorage(std::string label, std::vector<Api::Filesystem::StoragePropertiesPtr> &storageList)
@@ -760,4 +911,4 @@ void Manager::Watcher::StorageStateHasChanged(int storage, storage_state_e state
 
 }
 }
-}
\ No newline at end of file
+}
index dc670a6..3986046 100755 (executable)
@@ -167,6 +167,10 @@ public :
     static bool init();
     static void setupLocation(std::string location, const char* path);
 
+    void copyElement(const std::string &src,
+                     const std::string &dest,
+                     bool recursive = true) const;
+
   private:
     static RootList m_rootlist;
     static SubRootList m_subrootlist;
diff --git a/src/platform/Tizen/Filesystem/MoveCommand.cpp b/src/platform/Tizen/Filesystem/MoveCommand.cpp
deleted file mode 100755 (executable)
index 1d950b3..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "MoveCommand.h"
-#include <sstream>
-
-namespace {
-const char* COMMAND_NAME = "/bin/mv";
-const char* COMMAND_SWITCH_FORCE = "-f";
-}
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-MoveCommand::MoveCommand(const Api::Filesystem::IPathPtr& src,
-        const Api::Filesystem::IPathPtr& dest) :
-    m_src(src),
-    m_dest(dest),
-    m_force(false)
-{
-}
-
-void MoveCommand::setForce(bool force)
-{
-    m_force = force;
-}
-
-std::string MoveCommand::prepare()
-{
-    std::ostringstream oss;
-    oss << COMMAND_NAME;
-
-    if (m_force) {
-        oss << " " << COMMAND_SWITCH_FORCE;
-    }
-
-    oss << " \"" << m_src->getFullPath().c_str() << "\"";
-    oss << " \"" << m_dest->getFullPath().c_str() << "\"";
-
-    return oss.str();
-}
-}
-}
-}
diff --git a/src/platform/Tizen/Filesystem/MoveCommand.h b/src/platform/Tizen/Filesystem/MoveCommand.h
deleted file mode 100755 (executable)
index a50e282..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_FILESYSTEM_MOVECOMMAND_H_
-#define TIZENAPIS_FILESYSTEM_MOVECOMMAND_H_
-
-#include "Command.h"
-#include <API/Filesystem/IPath.h>
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-class MoveCommand : public Command
-{
-  public:
-    MoveCommand(const Api::Filesystem::IPathPtr& src,
-            const Api::Filesystem::IPathPtr& dest);
-    void setForce(bool force);
-
-  protected:
-    std::string prepare();
-
-  private:
-    Api::Filesystem::IPathPtr m_src;
-    Api::Filesystem::IPathPtr m_dest;
-    bool m_force;
-};
-}
-}
-}
-
-#endif // TIZENAPIS_FILESYSTEM_MOVECOMMAND_H_
\ No newline at end of file
index 5f8d1a9..59bb92d 100755 (executable)
@@ -38,25 +38,50 @@ using namespace TizenApis::Api::Filesystem;
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 
+
 namespace TizenApis {
 namespace Platform {
 namespace Filesystem {
+
+#define MAX_NODE_LENGTH 256
+
 Api::Filesystem::INodePtr Node::resolve(const Api::Filesystem::IPathPtr& path)
 {
     struct stat info;
+       struct stat syminfo;
+       char symlink[MAX_NODE_LENGTH];
+       
     if (lstat(path->getFullPath().c_str(), &info) != 0) {
         LogError("File: " << path->getFullPath().c_str());
         ThrowMsg(Commons::PlatformException,
                  "Node does not exist or access denied.");
     }
 
-    if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode)) {
+    if (!S_ISDIR(info.st_mode) & !S_ISREG(info.st_mode) && !S_ISLNK(info.st_mode)) {
         ThrowMsg(Commons::PlatformException,
                  "Platform node is of unsupported type.");
     }
 
     NodeType type = S_ISDIR(info.st_mode) ? NT_DIRECTORY : NT_FILE;
+
+    if (S_ISLNK(info.st_mode)) {
+        memset(symlink, 0, MAX_NODE_LENGTH);
+        if (readlink(path->getFullPath().c_str(), symlink, MAX_NODE_LENGTH -1) < 0) {
+            ThrowMsg(Commons::PlatformException, "read symbolic link error");
+        }
+        LogDebug(symlink);
+
+        if (lstat(symlink, &syminfo) != 0) {
+            LogError("File: " << symlink);
+            ThrowMsg(Commons::PlatformException, "read symbolic link error");
+        }
+               
+        type = S_ISDIR(syminfo.st_mode) ? NT_DIRECTORY : NT_FILE;
+        LogDebug(type);
+    }
+
     NodePtr result(new Node(path, type));
+
     return DPL::StaticPointerCast<INode>(result);
 }
 
@@ -151,6 +176,7 @@ NodeList Node::getChildNodes(const NodeFilterPtr& filter) const
         }
         Try {
             INodePtr node = Node::resolve(*m_path + entry->d_name);
+            node->setPermissions(getPermissions()); // inherit access rights
             if (NodeFilterMatcher::match(node, filter)) {
                 result.push_back(node);
             }
@@ -172,6 +198,7 @@ NodeList Node::getChildNodes(const NodeFilterPtr& filter) const
 
 void Node::getChildNodes(const EventListNodesPtr& event)
 {
+    LogDebug("ENTER");
     EventRequestReceiver<EventListNodes>::PostRequest(event);
 }
 
@@ -236,6 +263,7 @@ IStreamPtr Node::open(int mode)
 
 void Node::open(const EventOpenPtr& event)
 {
+    LogDebug("ENTER");
     EventRequestReceiver<EventOpen>::PostRequest(event);
 }
 
@@ -307,6 +335,7 @@ int Node::getMode() const
 
 void Node::read(const EventReadTextPtr& event)
 {
+    LogDebug("ENTER");
     EventRequestReceiver<EventReadText>::PostRequest(event);
 }
 
@@ -340,6 +369,7 @@ struct stat Node::stat(const IPathPtr& path)
     if (::stat(path->getFullPath().c_str(),
                 &result) != 0)
     {
+        LogError("File: " << path->getFullPath().c_str());
         ThrowMsg(Commons::PlatformException, "Node does not exist or no access");
     }
     return result;
@@ -354,14 +384,16 @@ Node::Node(const IPathPtr& path,
 }
 
 Node* Node::createAsFile(const IPathPtr& path,
-        int options)
+        int /* options */)
 {
+    LogDebug("ENTER");
     createAsFileInternal(path);
     return new Node(path, NT_FILE);
 }
 
 void Node::createAsFileInternal(const IPathPtr& path)
 {
+    LogDebug("ENTER");
     FILE* file = std::fopen(path->getFullPath().c_str(), "wb");
     if (!file) {
         ThrowMsg(Commons::PlatformException,
@@ -439,6 +471,7 @@ void Node::removeAsDirectory(const IPathPtr& path,
                 }
                 Catch(Commons::PlatformException) {
                 }
+                // TODO: Not sure if above exception should be swallowed.
             }
         }
         closedir(dir);
@@ -472,17 +505,24 @@ void Node::OnRequestReceived(const EventListNodesPtr& event)
 
 void Node::OnRequestReceived(const EventOpenPtr& event)
 {
-    try {
-        IStreamPtr result = open(event->getMode());
-        event->setResult(result);
-    }
-    catch (const Commons::PlatformException& ex) {
-        LogError("Exception: " << ex.GetMessage());
-        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-    }
-    catch (const Commons::SecurityException& ex) {
-        LogError("Exception: " << ex.GetMessage());
-        event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+    if (!event->checkCancelled()) {
+        try {
+            IStreamPtr result = open(event->getMode());
+            event->setResult(result);
+        }
+        catch (const Commons::PlatformException& ex) {
+            LogError("Exception: " << ex.GetMessage());
+            event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+        }
+        catch (const Commons::SecurityException& ex) {
+            LogError("Exception: " << ex.GetMessage());
+            event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
+        }
+        //event can be cancelled before executing this code.
+        //when it comes here we doesn't allow it anymore
+        event->setCancelAllowed(false);
+    } else {
+        event->setCancelAllowed(true);
     }
 }
 
@@ -490,6 +530,7 @@ void Node::OnRequestReceived(const EventReadTextPtr& event)
 {
     Try {
         event->setResult(readText());
+        LogDebug("LEAVIN GRACEFULLY");
     }
     Catch(Commons::PlatformException) {
         event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
@@ -497,6 +538,9 @@ void Node::OnRequestReceived(const EventReadTextPtr& event)
     Catch(Commons::SecurityException) {
         event->setExceptionCode(Commons::ExceptionCodes::SecurityException);
     }
+    //this function doesn't change state of the platform,
+    //so we can allow to cancel it and discard results.
+    event->setCancelAllowed(true);
 }
 
 std::string Node::readText()
@@ -513,15 +557,18 @@ std::string Node::readText()
     DPL::SharedPtr<Stream> stream(new Stream(SharedFromThis(), AM_READ));
     while (!stream->isEof()) {
         result << stream->getLine();
+        if(!stream->isEof())
+            result << '\n';
     }
     stream->close();
     return result.str();
 }
 
-std::string Node::toUri(int widgetId) const
+std::string Node::toUri(int /*widgetId*/) const
 {
+    // TODO I believe moving this feature to WrtWrapper would make more sense.
     return "file://" + m_path->getFullPath();
 }
 }
 }
-}
\ No newline at end of file
+}
diff --git a/src/platform/Tizen/Filesystem/RemoveCommand.cpp b/src/platform/Tizen/Filesystem/RemoveCommand.cpp
deleted file mode 100755 (executable)
index 172d2bb..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#include "RemoveCommand.h"
-#include <sstream>
-
-namespace {
-const char* COMMAND_NAME = "/bin/rm";
-const char* COMMAND_SWITCH_RECURSIVE = "-r";
-const char* COMMAND_SWITCH_FORCE = "-f";
-}
-
-namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-RemoveCommand::RemoveCommand(const Api::Filesystem::IPathPtr& path) :
-    m_path(path),
-    m_recursive(false),
-    m_force(false)
-{
-}
-
-void RemoveCommand::setRecursive(bool recursive)
-{
-    m_recursive = recursive;
-}
-
-void RemoveCommand::setForce(bool force)
-{
-    m_force = force;
-}
-
-std::string RemoveCommand::prepare()
-{
-    std::ostringstream oss;
-    oss << COMMAND_NAME;
-
-    if (m_recursive) {
-        oss << " " << COMMAND_SWITCH_RECURSIVE;
-    }
-
-    if (m_force) {
-        oss << " " << COMMAND_SWITCH_FORCE;
-    }
-
-    oss << " \"" << m_path->getFullPath().c_str() << "\"";
-
-    return oss.str();
-}
-}
-}
-}
index 5fd8036..7c3ada6 100755 (executable)
@@ -175,10 +175,7 @@ std::string Stream::getLine()
     checkForReading();
 
     std::string result;
-    if (!std::getline(m_stream, result)) {
-        ThrowMsg(Commons::PlatformException,
-                 "Error while reading from the stream.");
-    }
+    std::getline(m_stream, result);
 
     return result;
 }
index 2bdbf8e..16417dc 100755 (executable)
@@ -1,17 +1,20 @@
 get_current_path()
 
 pkg_search_module(capiappfw REQUIRED capi-appfw-application)
-pkg_search_module(pcrecpp REQUIRED libpcrecpp)
+pkg_search_module(pcrecpp REQUIRED libpcrecpp
+ecore REQUIRED ecore-1)
 
 set(INCLUDES_PLATFORM_IMPLEMENTATION_FILESYSTEM
   ${capiappfw_INCLUDE_DIRS}
   ${pcrecpp_INCLUDE_DIRS}
+  ${ecore_INCLUDE_DIRS}
   PARENT_SCOPE
 )
 
 set(LIBS_PLATFORM_IMPLEMENTATION_FILESYSTEM
   ${capiappfw_LIBRARIES}
   ${pcrecpp_LIBRARIES}
+  ${ecore_LIBRARIES}
   PARENT_SCOPE
 )
 
@@ -20,12 +23,7 @@ set(SRCS_PLATFORM_IMPLEMENTATION_FILESYSTEM
   ${CURRENT_PATH}/Node.cpp
   ${CURRENT_PATH}/Path.cpp
   ${CURRENT_PATH}/Stream.cpp
-  ${CURRENT_PATH}/System.cpp
   ${CURRENT_PATH}/NodeFilterMatcher.cpp
-  ${CURRENT_PATH}/Command.cpp
-  ${CURRENT_PATH}/CopyCommand.cpp
-  ${CURRENT_PATH}/MoveCommand.cpp
-  ${CURRENT_PATH}/RemoveCommand.cpp
   ${CURRENT_PATH}/Utils.cpp
   PARENT_SCOPE
 )
diff --git a/src/platform/Tizen/Geocoder/Geocoder.cpp b/src/platform/Tizen/Geocoder/Geocoder.cpp
deleted file mode 100644 (file)
index d7d0434..0000000
+++ /dev/null
@@ -1,284 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @author      Sangtai.kim (sangtai.kim@samsung.com)
- */
-
-#include "Geocoder.h"
-#include <cassert>
-#include <API/Geocoder/EventGeocoder.h>
-#include <Commons/Exception.h>
-
-using namespace TizenApis::Tizen1_0::Api::Geocoder;
-using namespace DPL;
-
-namespace TizenApis {
-namespace Tizen1_0{
-namespace Platform {
-namespace Geocoder {
-
-namespace{
-       bool geocoder_get_position_cb(double latitude, double longitude, void* eventPtr){
-               LogDebug("<<< latitude:" << latitude << ", " << longitude);
-
-               if(eventPtr != NULL){
-                       Api::Geocoder::EventGeocoder* event = (Api::Geocoder::EventGeocoder*)eventPtr;
-                       event->setLatitude(latitude);
-                       event->setLongitude(longitude);
-               }
-
-               LogDebug(">>>");
-               return true;
-       }
-}
-
-Geocoder::Geocoder() :
-       m_initialized(false), m_geocoder_handle(NULL) {
-    LogDebug("Enter");
-}
-
-Geocoder::~Geocoder() {
-       LogDebug("<<<");
-
-       int retVal = GEOCODER_ERROR_NONE;
-       if(m_geocoder_handle != NULL){
-               retVal = geocoder_destroy(m_geocoder_handle);
-       }
-
-       if (retVal != GEOCODER_ERROR_NONE){
-               LogError("Geocoder destruction failed");
-       }else{
-               LogDebug("Geocoder destroyed");
-       }
-
-       LogDebug(">>>");
-}
-
-void Geocoder::getAddressFromPosition(const Api::Geocoder::EventGeocoderPtr& event) {
-       LogDebug("<<<");
-
-       LogDebug("event->getLatitude():" << event->getLatitude());
-       LogDebug("event->getLongitude():" << event->getLongitude());
-
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventGeocoder>::PostRequest(event);
-
-       LogDebug(">>>");
-}
-
-void Geocoder::printEventData(const Api::Geocoder::EventGeocoderPtr& event) {
-    LogDebug("country:"                 << event->getCountry());
-    LogDebug("region:"                  << event->getRegion());
-    LogDebug("county:"                  << event->getCounty());
-    LogDebug("city:"                    << event->getCity());
-    LogDebug("street:"                  << event->getStreet());
-    LogDebug("streetNumber:"            << event->getStreetNumber());
-    LogDebug("premises:"                << event->getPremises());
-    LogDebug("additionalInformation:"   << event->getAdditionalInformation());
-    LogDebug("postalCode:"              << event->getPostalCode());
-}
-
-void Geocoder::getPositionFromAddress(const Api::Geocoder::EventGeocoderPtr& event) {
-       LogDebug("<<<");
-
-       printEventData(event);
-
-       if (m_initialized == false) {
-               initialize();
-       }
-
-       EventRequestReceiver<EventGeocoder>::PostRequest(event);
-
-       LogDebug(">>>");
-}
-
-void Geocoder::checkAndSetErrorCodeToEvent(int geocoderRetValue, const Api::Geocoder::EventGeocoderPtr& event) {
-       switch (geocoderRetValue) {
-       case GEOCODER_ERROR_INVALID_PARAMETER:
-               LogDebug("GEOCODER_ERROR_INVALID_PARAMETER");
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException);
-               break;
-       case GEOCODER_ERROR_NETWORK_FAILED:
-               LogDebug("GEOCODER_ERROR_NETWORK_FAILED");
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformException);
-               break;
-       case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE:
-               LogDebug("GEOCODER_ERROR_SERVICE_NOT_AVAILABLE");
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformWrongStateException);
-               break;
-       default:
-               LogDebug("UNKNOWN ERROR");
-               event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
-       }
-       return;
-}
-
-void Geocoder::getPositionFromPlatform(const Api::Geocoder::EventGeocoderPtr& event) {
-       LogInfo("<<<");
-       printEventData(event);
-
-       double latitude = 0;
-       double longitude = 0;
-
-       int result = GEOCODER_ERROR_NONE;
-
-       std::string strAddress = event->getAddressString();
-       LogDebug("c_str Address:[" << strAddress.c_str() << "]");
-
-       result = geocoder_foreach_positions_from_address_sync(m_geocoder_handle, strAddress.c_str(), geocoder_get_position_cb, event.Get() );
-       LogDebug("after geocoder_foreach_positions_from_address_sync" );
-
-       latitude = 10.12;
-       longitude = -12.12;
-
-       if (result != GEOCODER_ERROR_NONE) {
-               checkAndSetErrorCodeToEvent(result, event);
-       }
-
-       printEventData(event);
-
-       LogInfo(">>>");
-}
-
-void Geocoder::getAddressFromPlatform(const Api::Geocoder::EventGeocoderPtr& event)
-{
-       LogDebug("<<<");
-
-               char *country_code      = NULL;
-               char *state             = NULL;
-               char *district          = NULL;
-               char *city              = NULL;
-               char *street            = NULL;
-               char *postal_code       = NULL;
-               char *building_number   = NULL;
-
-               double latitude         = event->getLatitude();
-               double longitude        = event->getLongitude();
-
-               printf("[%s][%d] latitude:%f, longitude:%f\n", __FILE__, __LINE__, latitude, longitude);
-               LogDebug("latitude:" << latitude << ", longitude:" << longitude);
-
-               int result = geocoder_get_address_from_position_sync(m_geocoder_handle,
-                                   latitude, longitude,
-                                   &building_number,
-                                   &postal_code,
-                                   &street,
-                                   &city,
-                                   &district,
-                                   &state,
-                                   &country_code);
-
-    if(result != GEOCODER_ERROR_NONE){
-        checkAndSetErrorCodeToEvent(result, event);
-        return;
-               }
-
-               LogDebug("after geocoder_get_address_from_position_sync result:" << result);
-               LogDebug("country_code111:[" << country_code << "]");
-               LogDebug("state:[" << state << "]");
-               LogDebug("district:[" << district << "]");
-               LogDebug("city:[" << city << "]");
-               LogDebug("street:[" << street << "]");
-               LogDebug("postal_code:[" << postal_code << "]");
-               LogDebug("building_number:[" << building_number << "]");
-
-       if (country_code != NULL) {
-               event->setCountry(country_code);
-       }
-
-       if (state != NULL) {
-               event->setRegion(state);
-       }
-
-       if (district != NULL) {
-               event->setCounty(district);
-       }
-
-       if (city != NULL) {
-               event->setCity(city);
-       }
-
-       if (street != NULL) {
-               event->setStreet(street);
-       }
-
-       if (postal_code != NULL) {
-               event->setPostalCode(postal_code);
-       }
-
-       if (building_number != NULL) {
-               event->setPremises(building_number);
-       }
-
-               free(country_code);
-               free(state);
-               free(district);
-               free(city);
-               free(street);
-               free(postal_code);
-               free(building_number);
-
-               LogDebug(">>>");
-}
-
-void Geocoder::OnRequestReceived(const Api::Geocoder::EventGeocoderPtr& event)
-{
-       LogDebug("<<<");
-
-       if(event->getEventType() == EventGeocoder::GEOCODER_EVENT_GET_POSITION){
-               getPositionFromPlatform(event);
-       }else if(event->getEventType() == EventGeocoder::GEOCODER_EVENT_GET_ADDRESS){
-               getAddressFromPlatform(event);
-       }else{
-               LogError("[ERROR] UNKNOWN EVENT TYPE");
-               //return error;
-       }
-
-       LogDebug(">>>");
-}
-
-void Geocoder::initialize() {
-       LogDebug("<<<");
-
-       int retVal = GEOCODER_ERROR_NONE;
-
-       if (!m_initialized) {
-               DPL::Mutex::ScopedLock lock(&m_initializationMutex);
-               if (!m_initialized) {
-                       retVal = geocoder_create(&m_geocoder_handle);
-                       if(retVal != GEOCODER_ERROR_NONE){
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't init geocoder module.");
-                       }
-
-                       m_initialized = true;
-               }
-       }
-
-       LogDebug(">>>");
-}
-
-}      //namespace Geocoder
-}      //namespace Platform
-}
-}      //namespace TizenApis
diff --git a/src/platform/Tizen/Geocoder/Geocoder.h b/src/platform/Tizen/Geocoder/Geocoder.h
deleted file mode 100644 (file)
index 197a746..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @author
- * @version     0.1
- * @brief
- */
-
-#ifndef WRTPLUGINS_PLATFORM_GEOLOCATION_H_
-#define WRTPLUGINS_PLATFORM_GEOLOCATION_H_
-
-#include <map>
-#include <API/Geocoder/IGeocoder.h>
-#include <API/Geocoder/GeocoderFactory.h>
-#include <API/Geocoder/EventGeocoder.h>
-#include <dpl/shared_ptr.h>
-#include <dpl/noncopyable.h>
-
-#include <location/geocoder.h>
-
-#include <Commons/Emitters.h>
-
-
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Platform {
-namespace Geocoder {
-
-class Geocoder: public Api::Geocoder::IGeocoder {
-
-    friend class Api::Geocoder::GeocoderFactory;
-
-public:
-       virtual ~Geocoder();
-
-       virtual void getAddressFromPosition(const Api::Geocoder::EventGeocoderPtr& event);
-       virtual void getPositionFromAddress(const Api::Geocoder::EventGeocoderPtr& event);
-
-protected:
-       Geocoder();
-       virtual void OnRequestReceived(const Api::Geocoder::EventGeocoderPtr& event);
-
-private:
-       void getAddressFromPlatform(const Api::Geocoder::EventGeocoderPtr& event);
-       void getPositionFromPlatform(const Api::Geocoder::EventGeocoderPtr& event);
-
-       void printEventData(const Api::Geocoder::EventGeocoderPtr& event);
-       void checkAndSetErrorCodeToEvent(int geocoderRetValue, const Api::Geocoder::EventGeocoderPtr& event);
-
-       void initialize();
-
-       DPL::Mutex m_initializationMutex;
-       bool m_initialized;
-
-       geocoder_h m_geocoder_handle;
-};
-
-}
-}
-}
-}
-
-#endif /* WRTPLUGINS_PLATFORM_GEOLOCATION_H_ */
diff --git a/src/platform/Tizen/Geocoder/config.cmake b/src/platform/Tizen/Geocoder/config.cmake
deleted file mode 100644 (file)
index cba89d7..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-get_current_path()
-
-pkg_search_module(capi-location-geocoder REQUIRED capi-location-geocoder)
-#pkg_search_module(glib REQUIRED glib-2.0)
-
-set(INCLUDES_PLATFORM_IMPLEMENTATION_GEOCODER
-  ${capi-location-geocoder_INCLUDE_DIRS}
-  ${glib_INCLUDE_DIRS}
-  PARENT_SCOPE
-)
-
-set(LIBS_PLATFORM_IMPLEMENTATION_GEOCODER
-  ${capi-location-geocoder_LIBRARIES}
-  ${glib_LIBRARIES}
-  PARENT_SCOPE
-)
-
-set(SRCS_PLATFORM_IMPLEMENTATION_GEOCODER
-  ${CURRENT_PATH}/Geocoder.cpp
-  PARENT_SCOPE
-)
index 353960d..309d044 100755 (executable)
@@ -38,7 +38,7 @@ static PropertyStructArray mediaProperties =
        {"type",                                PrimitiveType_String},
        {"mimeType",                    PrimitiveType_String},
        {"title",                               PrimitiveType_String},
-       {"fileURI",                             PrimitiveType_String},
+       {"itemURI",                             PrimitiveType_String},
        {"thumbnailURIs",               PrimitiveType_String},
        {"description",                 PrimitiveType_String},  
        {"rating",                              PrimitiveType_Int},     
@@ -60,23 +60,20 @@ static PropertyStructArray mediaProperties =
 
 FilterValidatorPtr MediaFilterValidatorFactory::getMediaFilterValidator(QueryType value)
 {
-       static FilterValidatorPtr theFolderInstance;
-       static FilterValidatorPtr theMediaInstance;
+       static FilterValidatorPtr theValidatorInstance;
 
     if(value == QUERY_FOLDER)
     {  
        LogDebug("create validator of folder");
-               theFolderInstance = FilterValidatorPtr(new FilterValidator(folderProperties));
-           return theFolderInstance;
+               theValidatorInstance = FilterValidatorPtr(new FilterValidator(folderProperties));
        }
        else if(value == QUERY_MEDIA)
        {
        LogDebug("create validator of media item");
-               theMediaInstance = FilterValidatorPtr(new FilterValidator(mediaProperties));
-               return theMediaInstance;
+               theValidatorInstance = FilterValidatorPtr(new FilterValidator(mediaProperties));
        }
           
-   
+   return theValidatorInstance;
 }
 
 } // Media
index 39f4c1c..741769c 100755 (executable)
@@ -50,19 +50,7 @@ typedef enum
        MEDIA_RATING,
 
 }media_attribute_e;
-/*
-map<string, int> MediaSearchVisitor::attrEnumMap = {
-               {"id",                          media_attribute_e::CONTACT_ID},
-               {"title",                       media_attribute_e::MEDIA_TITLE},
-               {"filePath",            media_attribute_e::MEDIA_FILEPATH},
-               {"thumbnailPath",       media_attribute_e::MEDIA_THUMBNAILPATH},                
-               {"createdDate",         media_attribute_e::MEDIA_CREATEDDATE},
-               {"modifiedDate",        media_attribute_e::MEDIA_MODIFIEDDATE},         
-               {"description",         media_attribute_e::MEDIA_DESCRIPTION},          
-               {"rating",                      media_attribute_e::MEDIA_RATING},       
 
-};
-*/
 map<string, string> MediaSearchVisitor::attrFolderEnumMap = {
                {"id",                          "id"},
                {"folderURI",           "folder_path"},
@@ -118,6 +106,9 @@ void MediaSearchVisitor::visitInComposite(FilterType& type, int depth)
                m_query.append(STR_OR);
        else if(type == INTERSECTION_FILTER)
                m_query.append(STR_AND);
+       else{
+               ThrowMsg(PlatformException, "Filter Type is wrong.");
+       }
 }
 
 void MediaSearchVisitor::visitPostComposite(FilterType& type, int depth)
@@ -141,7 +132,7 @@ string MediaSearchVisitor::getPlatformAttr(string attrName)
                }
                else
                {
-                       ThrowMsg(UnsupportedException, "Attribute(" << attrName << ") is not supported.");
+                       ThrowMsg(PlatformException, "Attribute(" << attrName << ") is not supported.");
                }
        }
        else if(queryType == QUERY_MEDIA)
@@ -154,7 +145,7 @@ string MediaSearchVisitor::getPlatformAttr(string attrName)
                }
                else
                {
-                       ThrowMsg(UnsupportedException, "Attribute(" << attrName << ") is not supported.");
+                       ThrowMsg(PlatformException, "Attribute(" << attrName << ") is not supported.");
                }
 
        }
@@ -167,18 +158,21 @@ void MediaSearchVisitor::visitAttribute(string& attrName, MatchFlag& matchFlag,
        string attrPlatform = getPlatformAttr(attrName);
        if(matchValue == NULL)
        {
-               return ;
+               ThrowMsg(PlatformException, "matchValue is not valid data.");
        }       
 
        m_query.append(convertAttribute(attrPlatform, matchValue, matchFlag));
 }
 
-string MediaSearchVisitor::toDateDbStr(const tm &date) const
+string MediaSearchVisitor::toDateDbStr(tm &date) const
 {
+       time_t time;
+       time = mktime(&date);
        stringstream ss;
-       ss << setfill('0') << setiosflags(ios::right) << setw(4) << (date.tm_year + 1900);
-       ss << setfill('0') << setiosflags(ios::right) << setw(2) << (date.tm_mon + 1);
-       ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_mday;
+       ss << time;
+//     ss << setfill('0') << setiosflags(ios::right) << setw(4) << (date.tm_year + 1900);
+//     ss << setfill('0') << setiosflags(ios::right) << setw(2) << (date.tm_mon + 1);
+//     ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_mday;
 
        return ss.str();
 }
@@ -189,7 +183,6 @@ string MediaSearchVisitor::convertAttribute(string &attrName, AnyPtr& matchValue
        string operatorStr;
        string conditionStr;
 
-
        condition_e cond;
        string matchValueStr;
 
@@ -197,11 +190,14 @@ string MediaSearchVisitor::convertAttribute(string &attrName, AnyPtr& matchValue
        {
                if(matchValue->toString().compare("IMAGE")==0)
                        matchValueStr = "1";
-               if(matchValue->toString().compare("VIDEO")==0)
+               else if(matchValue->toString().compare("VIDEO")==0)
                        matchValueStr = "2";
-               if(matchValue->toString().compare("AUDIO")==0)
+               else if(matchValue->toString().compare("AUDIO")==0)
                        matchValueStr = "3";                    
-               //Todo. another case throw the exeption.
+               else
+               {
+                       ThrowMsg(PlatformException, "mediaType(" << matchValue->toString() << ") is not supported.");
+               }
        }
        else
        {
@@ -262,6 +258,7 @@ void MediaSearchVisitor::visitAttributeRange(string& attrName,AnyPtr& initialVal
        string initialValueStr;
        string endValueStr;
 
+       string attrPlatform = getPlatformAttr(attrName);
 
        if(!initialValue->isNullOrUndefined()) 
        {
@@ -292,15 +289,19 @@ void MediaSearchVisitor::visitAttributeRange(string& attrName,AnyPtr& initialVal
 
        if (!initialValue->isNullOrUndefined() && endValue->isNullOrUndefined()) 
        {
-               str = STR_LEFT_BRACKET + attrName + STR_GREATER_THAN + STR_EQUAL + STR_S_QUOTATION + initialValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
+               str = STR_LEFT_BRACKET + attrPlatform + STR_GREATER_THAN + STR_EQUAL + 
+                               STR_S_QUOTATION + initialValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
        }
        else if(initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) 
        {
-               str = STR_LEFT_BRACKET + attrName + STR_LESS_THAN + STR_S_QUOTATION + endValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
+               str = STR_LEFT_BRACKET + attrPlatform + STR_LESS_THAN + STR_S_QUOTATION + 
+                               endValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
        } 
        else if (!initialValue->isNullOrUndefined() && !endValue->isNullOrUndefined()) 
        {
-               str = STR_LEFT_BRACKET + attrName + STR_GREATER_THAN + STR_EQUAL + STR_S_QUOTATION + initialValueStr + STR_S_QUOTATION + STR_AND + attrName + STR_LESS_THAN + STR_S_QUOTATION + endValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
+               str = STR_LEFT_BRACKET + attrPlatform + STR_GREATER_THAN + STR_EQUAL + STR_S_QUOTATION + 
+                               initialValueStr + STR_S_QUOTATION + STR_AND + attrPlatform + STR_LESS_THAN + STR_S_QUOTATION + 
+                               endValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
        }
 
        m_query.append(str);
index 1ac5656..bf6ca86 100755 (executable)
@@ -82,7 +82,7 @@ public:
        void setQueryType(QueryType value);
        
 private:
-       string toDateDbStr(const tm &date) const;
+       string toDateDbStr(tm &date) const;
        string convertAttribute(string &attrname, AnyPtr& matchValue, MatchFlag& matchFlag);
                
 private:
index 3795c4f..6ad07c9 100644 (file)
@@ -24,8 +24,7 @@
 
 #include <mm_file.h>
 #include <mm_error.h>
-
-
+#include <time.h>
 
 using namespace TizenApis::Api::Mediacontent;
 using namespace WrtDeviceApis::Commons;
@@ -36,7 +35,7 @@ const string SELECT_FOLDER_QUERY =
        "select folder_uuid, path, title, storage_type,modified_date from (select folder_uuid, path, folder_name as title, storage_type,modified_date from visual_folder where valid=1 union select folder_uuid, path, folder_name as title, storage_type,modified_date from audio_folder) where 1  ";
 
 const string VIEW_MEDIA_QUERY_WITH_FOLDER =
-       "select visual_uuid, folder_uuid, content_type, display_name, path, thumbnail_path,created_date, released_date, modified_date, description,rating, album, artist, last_played_time, played_count,longitude, latitude, width, height, orientation, genre, author, duration,size from \
+       "select visual_uuid as media_uuid, folder_uuid, content_type, display_name, path, thumbnail_path,created_date, released_date, modified_date, description,rating, album, artist, last_played_time, played_count,longitude, latitude, width, height, orientation, genre, author, duration,size from \
        (select visual_uuid,folder_uuid, content_type, display_name, path, thumbnail_path,null as created_date, released_date, modified_date, description,rating, album, artist, last_played_time, null as played_count,longitude, latitude, width, height, orientation,null as genre, null as author, duration,size from visual_media join \
                (select * from \
                        (select visual_uuid as meta_uuid, longitude, latitude, description, width, height, datetaken as released_date, orientation,null as album, null as artist, null as last_played_time,null as duration from image_meta \
@@ -44,7 +43,7 @@ const string VIEW_MEDIA_QUERY_WITH_FOLDER =
                        select visual_uuid as meta_uuid, longitude, latitude, description, width, height, datetaken as released_date, null as orientation, album, artist, last_played_time,duration from video_meta)) \
        on visual_uuid=meta_uuid \
        union all \
-               select audio_uuid, folder_uuid as folder_uuid, content_type, title as display_name, path, thumbnail_path, added_time, year, modified_date, description, favourite, album, artist, last_played_time, played_count, null as longitude, null as latitude, null as width, null as height, null as orientation, genre, author, duration, size from audio_media) where 1 ";
+               select audio_uuid, folder_uuid as folder_uuid, content_type, title as display_name, path, thumbnail_path, added_time, year, modified_date, description, rating, album, artist, last_played_time, played_count, null as longitude, null as latitude, null as width, null as height, null as orientation, genre, author, duration, size from audio_media) where 1 ";
 
 const string SELECT_MEDIA_ID_WITH_FOLDER = 
        "select item_id from item_view where folder_uuid=";
@@ -56,40 +55,51 @@ namespace TizenApis {
 namespace Platform {
 namespace Mediacontent{
 
+int Mediacontent::db_connnect_count = 0;
+sqlite3* Mediacontent::hDBCt = NULL;
+
 Mediacontent::Mediacontent()
 {
-    LogDebug("entered");
+    LogDebug("entered" + Mediacontent::db_connnect_count);
 
-//     int ret;
-
-       db_connnect_count++;
-
-       db_util_open(MEDIA_DB_PATH, &hDBCt, 0);
-       LogDebug("hDBCt:" << hDBCt);            
+       if(Mediacontent::db_connnect_count == 0)
+       {
+               if( SQLITE_OK != db_util_open(MEDIA_DB_PATH, &Mediacontent::hDBCt, 0))
+               {
+                       return;
+               }
+       }
+       Mediacontent::db_connnect_count++;              
 }
 
 Mediacontent::~Mediacontent()
 {
     LogDebug("entered");
        int ret;
-       db_connnect_count--;
-       if(db_connnect_count == 0)
+       Mediacontent::db_connnect_count--;
+       if(Mediacontent::db_connnect_count < 1)
        {
-               ret = db_util_close(hDBCt);
+               ret = db_util_close(Mediacontent::hDBCt);
                if(ret != SQLITE_OK)
+               {
                        ret = -1;
+                       LogDebug("DB disconnection is failed");
+               }
                else
-                       hDBCt = NULL;
+               {
+                       Mediacontent::hDBCt = NULL;
+                       LogDebug("DB connection is ok");
+               }
+               Mediacontent::db_connnect_count = 0;
        }
 }
 
 tm Mediacontent::toDateTm(time_t date)
 {
        tm tm_date;
-       
-       tm_date.tm_year = (date / 10000) - 1900;
-       tm_date.tm_mon = ((date - ((tm_date.tm_year + 1900) * 10000)) / 100) - 1;
-       tm_date.tm_mday = (date - ((tm_date.tm_year + 1900) * 10000) - tm_date.tm_mon * 100);
+
+       localtime_r(&date, &tm_date);
 
        return tm_date;
 }      
@@ -184,25 +194,26 @@ void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
 
        //set condition
        MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
-       
-       if(eFolder->getFilterIsSet())
-       {
-               FilterPtr filter = eFolder->getFilter();
-/*
-               FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_FOLDER);
-               bool success = filter->validate(validator);
 
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-*/
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
+       try{
+               if(eFolder->getFilterIsSet())
+               {
+                       FilterPtr filter = eFolder->getFilter();
+
+                       IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
 
-               visitor->setQueryType(MediaSearchVisitor::QUERY_FOLDER);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
+                       visitor->setQueryType(MediaSearchVisitor::QUERY_FOLDER);
+                       filter->travel(IVisitor);
+                       condition = visitor->getResult();
 
-               query.append(" and ");
-               query.append(condition);
+                       query.append(" and ");
+                       query.append(condition);
+               }
+       }
+       catch(const Exception &ex){
+        LogError("Exception: " << ex.DumpToString());
+        eFolder->setResult(false);
+        return;
        }
 
        if(eFolder->getSortModesIsSet()) 
@@ -229,17 +240,17 @@ void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
 
                query.append(limitOffset);
        }
+
        LogDebug("execute condition [" << condition << "]");
        LogDebug("execute projection [" << projection << "]");
        LogDebug("execute sortMode [" << sortMode << "]");
        LogDebug("execute limitOffset [" << limitOffset << "]");        
-       LogDebug("execute query [" << query << "]");    
 
        try
        {
                sqlite3_stmt* pStmt = NULL;
                folder_s media_folder;
-               sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), strlen((char *)(query.c_str())), &pStmt, NULL);
+               sqlite3_prepare_v2(Mediacontent::hDBCt, (char *)(query.c_str()), strlen((char *)(query.c_str())), &pStmt, NULL);
                while( sqlite3_step(pStmt) == SQLITE_ROW)
                {
                        media_folder.folder_uuid = (char *)sqlite3_column_text(pStmt, 0);
@@ -262,7 +273,7 @@ void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
                LogError("Exception: " << ex.DumpToString());
                eFolder->setResult(false);
        }
-       eFolder->setCancelAllowed(true);
+       LogDebug("dykim:end");
 }
 
 
@@ -278,26 +289,27 @@ void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
        string query(VIEW_MEDIA_QUERY_WITH_FOLDER);
 
        MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
-       
-       if(eMedia->getFilterIsSet())
-       {
-               FilterPtr filter = eMedia->getFilter();
 
-               // FIXME validator have to be placed at JS binding.
-/*             FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
-               bool success = filter->validate(validator);
+       try
+       {
+               if(eMedia->getFilterIsSet())
+               {
+                       FilterPtr filter = eMedia->getFilter();
 
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
-*/
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
+                       IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
 
-               visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
-               query.append(" and ");
-               query.append(condition);                
+                       visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
+                       filter->travel(IVisitor);
+                       condition = visitor->getResult();
+                       query.append(" and ");
+                       query.append(condition);                
+               }
        }
+       catch(const Exception &ex){
+        LogError("Exception: " << ex.DumpToString());
+        eMedia->setResult(false);
+        return;
+       }               
 
        if(eMedia->getSortModesIsSet()) 
        {
@@ -326,8 +338,6 @@ void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
        LogDebug("execute projection [" << projection << "]");
        LogDebug("execute sortMode [" << sortMode << "]");
        LogDebug("execute limitOffset [" << limitOffset << "]");        
-       LogDebug("execute query [" << query << "]");
-       
 
        int ret;
        
@@ -335,7 +345,7 @@ void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
        {
                sqlite3_stmt* pStmt = NULL;
                int content_type;
-               ret = sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
+               ret = sqlite3_prepare_v2(Mediacontent::hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
 
                while( sqlite3_step(pStmt) == SQLITE_ROW)
                {
@@ -373,7 +383,6 @@ void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
         LogError("Exception: " << ex.DumpToString());
         eMedia->setResult(false);
     }
-    eMedia->setCancelAllowed(true);
 }
 
 void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
@@ -386,30 +395,41 @@ void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
        string condition;
        
        string query(VIEW_MEDIA_QUERY_WITH_FOLDER);
-       std::stringstream folderStream;
-       folderStream <<" and folder_uuid='" << eBrowse->getFolderID() <<"' ";
-       query.append(folderStream.str());
+
+       if(eBrowse->getFolderIdIsSet())
+       {
+               std::stringstream folderStream;
+               folderStream <<" and folder_uuid='" << eBrowse->getFolderID() <<"' ";
+               query.append(folderStream.str());
+       }               
 
        MediaSearchVisitorPtr visitor(new MediaSearchVisitor());
 
-       if(eBrowse->getFilterIsSet())
-       {
-               FilterPtr filter = eBrowse->getFilter();
+       try{
+               if(eBrowse->getFilterIsSet())
+               {
+                       FilterPtr filter = eBrowse->getFilter();
 
-               // FIXME validator have to be placed at JS binding.
-               FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
-               bool success = filter->validate(validator);
+                       // FIXME validator have to be placed at JS binding.
+                       FilterValidatorPtr validator = MediaFilterValidatorFactory::getMediaFilterValidator(MediaFilterValidatorFactory::QUERY_MEDIA);
+                       bool success = filter->validate(validator);
 
-               if(!success)
-                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
+                       if(!success)
+                               ThrowMsg(PlatformException, "Invalid attirbutes.");
 
-               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
+                       IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
 
-               visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
-               filter->travel(IVisitor);
-               condition = visitor->getResult();
-               query.append(" and ");
-               query.append(condition);                
+                       visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
+                       filter->travel(IVisitor);
+                       condition = visitor->getResult();
+                       query.append(" and ");
+                       query.append(condition);                
+               }
+       }
+       catch(const Exception &ex){
+        LogError("Exception: " << ex.DumpToString());
+        eBrowse->setResult(false);
+        return;
        }
 
        if(eBrowse->getSortModesIsSet()) 
@@ -446,11 +466,9 @@ void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
        {
                sqlite3_stmt* pStmt = NULL;
                int content_type;
-               ret = sqlite3_prepare_v2(hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
-
+               ret = sqlite3_prepare_v2(Mediacontent::hDBCt, (char *)(query.c_str()), query.length(), &pStmt, NULL);
                while( sqlite3_step(pStmt) == SQLITE_ROW)
                {
-
                        content_type = sqlite3_column_int(pStmt, 2);    
 
                        if(content_type == MEDIA_TYPE_IMAGE)
@@ -471,9 +489,7 @@ void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
                                MediacontentAudio *newVAudio(new MediacontentAudio());
                                readAudioFromDB(pStmt,newVAudio);
                                eBrowse->addMedia(newVAudio);
-
                        }
-
                }
                sqlite3_finalize(pStmt);
                eBrowse->setResult(true);
@@ -484,9 +500,6 @@ void Mediacontent::OnRequestReceived(const IEventBrowseFolderPtr &eBrowse)
         LogError("Exception: " << ex.DumpToString());
         eBrowse->setResult(false);
     }
-
-    eBrowse->setCancelAllowed(true);
-
 }
 
 bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
@@ -499,12 +512,10 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                
        if(type.compare("IMAGE")==0)
        {
-               LogDebug("Image11");
                MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
                if(imagePtr != NULL)
                {
                        string query;   
-                       LogDebug("Image22");
                        if(imagePtr->getIsChangedFavorite())
                        {
                                query.append("update visual_media set rating=");
@@ -516,12 +527,14 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                                query.append("'");
                                LogDebug("QUERY : " << query);
 
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
+                               err = sqlite3_exec(Mediacontent::hDBCt, query.c_str(), NULL, NULL, &errMsg);
                                if (SQLITE_OK != err)
                                {                                       
                                        if(errMsg)
                                        {
+                                               LogDebug("DB opertations is failed:" << errMsg);
                                                sqlite3_free(errMsg);
+                                               ThrowMsg(PlatformException, "DB opertations is failed");
                                        }       
                                }
                        }
@@ -530,7 +543,6 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
        }
        if(type.compare("VIDEO")==0)
        {
-               LogDebug("Video11");
                MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
                if(videoPtr != NULL)
                {
@@ -540,12 +552,14 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                                std::stringstream offsetStream;
                                offsetStream << "update visual_media set rating=" << videoPtr->getFavorite() << " where visual_uuid=" << "'" << videoPtr->getMediaUUID() << "'";
                                query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
+                               err = sqlite3_exec(Mediacontent::hDBCt, query.c_str(), NULL, NULL, &errMsg);
                                if (SQLITE_OK != err)
                                {                                       
                                        if(errMsg)
                                        {
+                                               LogDebug("DB opertations is failed:" << errMsg);
                                                sqlite3_free(errMsg);
+                                               ThrowMsg(PlatformException, "DB opertations is failed");
                                        }
                                }
                        }
@@ -554,12 +568,14 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                                std::stringstream offsetStream;
                                offsetStream << "update video_meta set last_played_time=" << videoPtr->getVideoPlayedTime() << " where visual_uuid=" << "'" << videoPtr->getMediaUUID() << "'";
                                query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
+                               err = sqlite3_exec(Mediacontent::hDBCt, query.c_str(), NULL, NULL, &errMsg);
                                if (SQLITE_OK != err)
                                {                                       
                                        if(errMsg)
                                        {
+                                               LogDebug("DB opertations is failed:" << errMsg);
                                                sqlite3_free(errMsg);
+                                               ThrowMsg(PlatformException, "DB opertations is failed");
                                        }
                                }                                               
                        }
@@ -568,7 +584,6 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
        }
        if(type.compare("AUDIO")==0)
        {
-               LogDebug("Audio11");
                MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
                if(audioPtr != NULL)
                {
@@ -578,13 +593,14 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                                std::stringstream offsetStream;
                                offsetStream << "update audio_media set rating=" << audioPtr->getFavorite() << " where audio_uuid=" << "'" << audioPtr->getMediaUUID() << "'";
                                query = offsetStream.str();
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
+                               err = sqlite3_exec(Mediacontent::hDBCt, query.c_str(), NULL, NULL, &errMsg);
                                if (SQLITE_OK != err)
                                {                                       
                                        if(errMsg)
                                        {
+                                               LogDebug("DB opertations is failed:" << errMsg);
                                                sqlite3_free(errMsg);
-                                               //throw error
+                                               ThrowMsg(PlatformException, "DB opertations is failed");
                                        }
                                        
                                }                                       
@@ -594,13 +610,14 @@ bool Mediacontent::updateMediaToDB(MediacontentMediaPtr mediaPtr)
                                std::stringstream offsetStream;
                                offsetStream << "update audio_media set last_played_time=" <<audioPtr->getAudioPlayedTime()<< ",played_count="<<audioPtr->getAudioPlayCount()<<" where audio_uuid=" << "'" << audioPtr->getMediaUUID() << "'";
                                query = offsetStream.str();                     
-                               err = sqlite3_exec(hDBCt, query.c_str(), NULL, NULL, &errMsg);
+                               err = sqlite3_exec(Mediacontent::hDBCt, query.c_str(), NULL, NULL, &errMsg);
                                if (SQLITE_OK != err)
                                {                                       
                                        if(errMsg)
                                        {
+                                               LogDebug("DB opertations is failed:" << errMsg);
                                                sqlite3_free(errMsg);
-                                               //throw error
+                                               ThrowMsg(PlatformException, "DB opertations is failed");
                                        }
                                }                                               
                        }
@@ -631,7 +648,6 @@ void Mediacontent::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
         LogError("Exception: " << ex.DumpToString());
         eMedia->setResult(false);
     }
-    eMedia->setCancelAllowed(true);
 }
 
 
@@ -639,31 +655,59 @@ void Mediacontent::OnRequestReceived(const IEventUpdateMediaItemsPtr &eItems)
 {
        LogDebug("OnRequestReceived::IEventUpdateMediaItemsPtr entered");
 
+       char *ErrMsg = NULL;
        try
        {
                MediacontentMediaListPtr mediaListPtr = eItems->getMediaItems();
         if (mediaListPtr->empty()) 
                {
-            ThrowMsg(NullPointerException, "Item vector parameter is empty");
+            ThrowMsg(PlatformException, "Item vector parameter is empty");
         }
 
+               if(SQLITE_OK != sqlite3_exec(Mediacontent::hDBCt, "BEGIN IMMEDIATE;", NULL, NULL, &ErrMsg)) 
+               {
+                       LogError("Error:failed to begin transaction: error=" << ErrMsg);
+                       sqlite3_free(ErrMsg);
+                       ThrowMsg(PlatformException,"Error:failed to begin transaction\n");
+               }
+               sqlite3_free(ErrMsg);
+               
         for(unsigned int i=0; i<mediaListPtr->size(); i++)
         {
+                       if (eItems->checkCancelled()) 
+                       {
+                eItems->setCancelAllowed(true);
+                eItems->setResult(true);
+                               if (SQLITE_OK != sqlite3_exec(Mediacontent::hDBCt, "ROLLBACK;", NULL, NULL, &ErrMsg)) 
+                               {
+                                       LogError("Error:failed to rollback transaction: error=" << ErrMsg);
+                                       sqlite3_free(ErrMsg);
+                                       ThrowMsg(PlatformException,"Error:failed to rollback transaction\n");
+                               }    
+                               sqlite3_free(ErrMsg);
+                return;
+            }
                        MediacontentMediaPtr mediaPtr = mediaListPtr->at(i);
                        if(!updateMediaToDB(mediaPtr))
                        {
-                               ThrowMsg(NullPointerException, "DB operation is failed");
+                               ThrowMsg(PlatformException, "DB operation is failed");
                        }
                }
                eItems->setResult(true);
+               if (SQLITE_OK != sqlite3_exec(Mediacontent::hDBCt, "COMMIT;", NULL, NULL, &ErrMsg)) 
+               {
+                       LogError("Error:failed to end transaction: error=" << ErrMsg);
+                       sqlite3_free(ErrMsg);
+                       ThrowMsg(PlatformException,"Error:failed to end transaction\n");
+               }
+               sqlite3_free(ErrMsg);
         }
         catch (const Exception &ex)
         {
                 LogError("Exception: " << ex.DumpToString());
                 eItems->setResult(false);
         }
-        eItems->setCancelAllowed(true);
-
+        eItems->setCancelAllowed(false);
 }
 
 void Mediacontent::readImageFromDB(sqlite3_stmt* pStmt, MediacontentImage* newImage)
@@ -795,7 +839,6 @@ void Mediacontent::readVideoFromDB(sqlite3_stmt* pStmt, MediacontentVideo* newVi
        
                newVideo->setVideoDuration(sqlite3_column_int(pStmt,22));
                newVideo->setSize(sqlite3_column_double(pStmt,23));
-
        }               
 
 }
@@ -825,8 +868,13 @@ void Mediacontent::readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAu
                if( tmp != NULL)
                        newAudio->setThumbnailPath(tmp);
 
+
                newAudio->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
-               newAudio->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
+
+               tm tm_date;
+               memset(&tm_date,0x00,sizeof(tm_date));
+               tm_date.tm_year = sqlite3_column_int(pStmt,7);
+               newAudio->setReleasedDate(tm_date);
                newAudio->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
 
                tmp = (char*)sqlite3_column_text(pStmt,9);
@@ -863,7 +911,7 @@ void Mediacontent::readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAu
                queryExtraAudio.append("'");
                sqlite3_stmt* pStmt1 = NULL;
                //"select copyright,bitrate,track_num,size from audio_media where audio_id=";
-               if(sqlite3_prepare_v2(hDBCt, (char *)(queryExtraAudio.c_str()), strlen((char *)(queryExtraAudio.c_str())), &pStmt1, NULL) == SQLITE_OK)
+               if(sqlite3_prepare_v2(Mediacontent::hDBCt, (char *)(queryExtraAudio.c_str()), strlen((char *)(queryExtraAudio.c_str())), &pStmt1, NULL) == SQLITE_OK)
                {
                        while( sqlite3_step(pStmt1) == SQLITE_ROW)
                        {
index 5ba3006..321b7d2 100644 (file)
@@ -79,8 +79,10 @@ class Mediacontent : public Api::Mediacontent::IMediacontent
        string makeQuerySortMode(SortModeArrayPtr attr);
 
        private:
-       sqlite3 *hDBCt;
-       int db_connnect_count;
+       static sqlite3 *hDBCt;
+       static int db_connnect_count;
+
+
 
 };
 
index 1ec4a6c..288a328 100755 (executable)
@@ -72,6 +72,23 @@ Attachment::Attachment(emf_attachment_info_t* att)
     }
 }
 
+Attachment::Attachment(emf_attachment_data_t* att)
+{
+       LogDebug("entered");
+
+       m_attachShortName = std::string(att->attachment_name);
+       m_isDownloaded = att->save_status;
+       m_attachmentID = att->attachment_id;    
+       //m_mimeType = std::string(att->attachment_mime_type);
+       LogDebug(" showname = " << m_attachShortName << " isDownloaded = " << m_isDownloaded << " attachmentID = " << m_attachmentID << "Mime= " << m_mimeType);
+       LogDebug("save name is = " << att->attachment_path);
+
+       if ( att->attachment_path)
+       {
+               init( att->attachment_path, false);
+       }
+}
+
 /*
 Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, 
        const Api::Filesystem::INode& inode):
index fc18974..d7fac23 100755 (executable)
@@ -27,7 +27,7 @@
 #include <string>
 #include <dpl/shared_ptr.h>
 #include <API/Messaging/IAttachment.h>
-#include <emf-types.h>
+#include <email-types.h>
 
 namespace TizenApis {
 namespace Platform {
@@ -40,6 +40,7 @@ class Attachment : public Api::Messaging::IAttachment
     explicit Attachment();
     explicit Attachment(const std::string& fullPath, bool isVirtualPath);
     explicit Attachment(emf_attachment_info_t* att);
+    explicit Attachment(emf_attachment_data_t* att);
 
    // explicit Attachment( const TizenApis::Api::Filesystem::IPathPtr&, TizenApis::Api::Filesystem::NodeType);
 #if 0
index e33b361..a6644c6 100755 (executable)
@@ -87,6 +87,11 @@ void BinarySms::updateIsRead()
     //#warning "TODO"
 }
 
+void BinarySms::updateMessage()
+{
+    //#warning "TODO"
+}
+
 void BinarySms::addMessageToDraft()
 {
     //#warning "TODO"
index b8d0214..eeb5aa0 100755 (executable)
@@ -59,6 +59,8 @@ class BinarySms :
 
     virtual void updateIsRead();       
 
+    virtual void updateMessage();              
+
     virtual void addMessageToDraft();
 
     virtual int send();
index 3606138..5771459 100755 (executable)
@@ -20,7 +20,7 @@
 #include <Commons/Exception.h>
 #include "MsgServiceHandleMgr.h"
 #include <API/Messaging/IMessaging.h>
-#include <Emf_Mapi_Message.h>
+#include <email-api-mail.h>
 #include <time.h>
 
 
@@ -52,14 +52,18 @@ Conversation::Conversation(unsigned int threadId, Api::Messaging::MessageType ms
 Conversation::Conversation(std::string threadId, Api::Messaging::MessageType msgType)
 {
        LogDebug("Enter");
-       
+       bool result = FALSE;
        std::istringstream stream(threadId);
        
        LogDebug("threadId : " << threadId);
        
        unsigned int number = 0;
        stream >> number;
-       makeConversationFromMsgId(number, msgType);
+       result = makeConversationFromMsgId(number, msgType);
+       if(result == FALSE)
+       {
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException,     "fail to make conversation");
+       }
 }
 
 Conversation::Conversation(unsigned int threadIndex)
@@ -411,7 +415,7 @@ bool Conversation::makeConversationFromMsgId(unsigned int threadId, Api::Messagi
        int conversationId = 0; 
        int index = 0;
        m_result = false;
-       
+
        if (msg_get_thread_view_list(handle, NULL, &threadViewList) != MSG_SUCCESS)
        {
                LogDebug("get thread view fail");
@@ -420,6 +424,11 @@ bool Conversation::makeConversationFromMsgId(unsigned int threadId, Api::Messagi
        }
 
        conversationId = Api::Messaging::IMessaging::getInstance().getConversationId(threadId, msgType);
+       if(conversationId < MSG_SUCCESS)
+       {
+               LogDebug("get thread view fail");
+               return m_result;
+       }               
        
        for(index = 0; index < threadViewList.nCount; index++)
        {
@@ -441,18 +450,14 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
        
        emf_mail_list_item_t *resultMail = NULL;
        emf_mail_list_item_t *mailList = NULL;
-       int accountId = 0;
        int index = 0;
        int count = 0;
-       emf_mailbox_t mailbox = {};
-       emf_mail_t *mail = NULL;
 
-       
+       emf_mail_data_t* mailData = NULL;
        m_result = true;
 
        try 
        {
-
                // Todo : will be re-implemented as using email_get_thread_information_ex 
                if(email_get_thread_information_ex(emailTreadId, &resultMail) != EMF_ERROR_NONE) 
                {
@@ -463,17 +468,18 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                {
                        return NULL;
                }
-               
-               if (email_get_mail(&mailbox, resultMail->mail_id, &mail) != EMF_ERROR_NONE)
+
+               //get mail data
+               if (email_get_mail_data(resultMail->mail_id,&mailData) != EMF_ERROR_NONE)
                {
                        ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get email data fail" );
                }
-               
+       
                // account Id
                m_unreadMessages = 0;
 
                LogDebug("start email_get_mail_list_ex");
-               if (email_get_mail_list_ex(accountId, NULL, emailTreadId, 0, resultMail->thread_item_count, 
+               if (email_get_mail_list_ex(mailData->account_id, NULL, emailTreadId, 0, resultMail->thread_item_count, 
                        EMF_SORT_DATETIME_HIGH, &mailList, &count) != EMF_ERROR_NONE)
                {
                        ThrowMsg(WrtDeviceApis::Commons::UnknownException, "get email data fail" );
@@ -481,8 +487,6 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                LogDebug("end email_get_mail_list_ex");
                
                // unread msg count
-               accountId = resultMail->account_id;     
-
                for (index = 0; index < count; index++)
                {
                        if (mailList[index].flags_seen_field)
@@ -501,6 +505,11 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
 
                // time horrible split 
                // 2011 11 08 00 35 45
+
+#if 1
+               m_time = resultMail->date_time;
+#else
+
                if (resultMail->datetime[0] != '\0')
                {
                        char buf[MAX_DATETIME_STRING_LENGTH];
@@ -528,13 +537,14 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                        targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
                        timeinfo.tm_min = atoi(buf);
 
-
                        memset(buf, 0x00, sizeof(buf));
                        targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
                        timeinfo.tm_sec = atoi(buf);
 
                        m_time = mktime(&timeinfo);
                }
+
+#endif
        
                // preview
                // not support 
@@ -568,29 +578,24 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                        LogDebug(m_subject);            
                }
 
-               // to, cc, bcc
-               if (mail->head!= NULL)
+               if (mailData->full_address_to != NULL)
                {
-                       if (mail->head->bcc != NULL)
-                       {
-                               LogDebug(mail->head->bcc);
-                               m_bcc.push_back(mail->head->bcc);
-                       }
-
-                       if (mail->head->to != NULL)
-                       {
-                               LogDebug(mail->head->to);
-                               m_to.push_back(mail->head->to);
-                       }
+                       LogDebug("Header To " << mailData->full_address_to);
+                       m_to.push_back(mailData->full_address_to);
+               }
 
-                       if (mail->head->cc != NULL)
-                       {
-                               LogDebug(mail->head->cc);
-                               m_cc.push_back(mail->head->cc);
-                       }
+               if (mailData->full_address_bcc != NULL)
+               {
+                       LogDebug("Header Bcc " << mailData->full_address_bcc);
+                       m_to.push_back(mailData->full_address_bcc);
+               }
 
+               if (mailData->full_address_cc != NULL)
+               {
+                       LogDebug("Header CC " << mailData->full_address_cc);
+                       m_to.push_back(mailData->full_address_cc);
                }
-       
+               
                m_lastMessageId = resultMail->mail_id;
                LogDebug(m_lastMessageId);              
                m_result = true;
@@ -601,9 +606,9 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                LogError("Exception: " << ex.GetMessage());
        }
 
-       if (mail != NULL)
+       if (mailData != NULL)
        {
-               email_free_mail(&mail , 1);
+               email_free_mail_data(&mailData , 1);
        }
        
        if (resultMail != NULL)
@@ -611,7 +616,6 @@ bool Conversation::makeConversationFromEmailThreadId(unsigned int emailTreadId)
                free(resultMail);
        }
 
-
        return m_result;
 
 }
index f7f0214..6f5513d 100755 (executable)
@@ -46,6 +46,12 @@ namespace TizenApis {
 
                }
 
+               ConversationQueryGenerator::ConversationQueryGenerator(const Api::Tizen::SortModePtr& sortMode,
+                               const long limit, const long offset, const int type):MessageQueryGenerator(sortMode, limit, offset, type){
+
+               }
+               
+
                ConversationQueryGenerator::~ConversationQueryGenerator() {
                }
 
@@ -54,8 +60,11 @@ namespace TizenApis {
                        attributeMap.clear();
 
                        attributeMap.insert(
-                                                                                                               std::pair<std::string, std::string>(
-                                                                                                                               ConversationFilterValidatorFactory::ATTRIBUTE_ID,          "ADDRESS_ID"));
+                                                                                       std::pair<std::string, std::string>(
+                                                                                                       ConversationFilterValidatorFactory::ATTRIBUTE_ID,          "ADDRESS_ID"));
+                       attributeMap.insert(
+                                                                                       std::pair<std::string, std::string>(
+                                                                                                       ConversationFilterValidatorFactory::ATTRIBUTE_TYPE,          "MAIN_TYPE"));                     
                        attributeMap.insert(
                                                                                        std::pair<std::string, std::string>(
                                                                                                        ConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP,       "MSG_TIME"));
index c3bfde5..5188aad 100755 (executable)
@@ -37,6 +37,7 @@ namespace TizenApis {
                        public:
                                ConversationQueryGenerator();
                                ConversationQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
+                               ConversationQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type);
 
                                virtual ~ConversationQueryGenerator();
 
index c3d9724..541080b 100755 (executable)
@@ -27,8 +27,8 @@
 #include <cstddef>
 #include <cstdlib>
 #include <ctime>
-#include <emf-types.h>
-#include <Emf_Mapi.h>
+#include <email-types.h>
+#include <email-api.h>
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
 #include <dpl/scoped_fclose.h>
@@ -58,25 +58,10 @@ namespace TizenApis {
 namespace Platform {
 namespace Messaging {
 
-#if 0 // UNUSED CODE
 namespace {
-//#define USE_OUTBOX
-
-#ifdef USE_OUTBOX
-const Api::Messaging::FolderType DEFAULT_FOLDER = Api::Messaging::OUTBOX;
-const char* DEFAULT_FOLDER_NAME = EMF_OUTBOX_NAME;
-#else
-const Api::Messaging::FolderType DEFAULT_FOLDER = Api::Messaging::DRAFTBOX;
-const char* DEFAULT_FOLDER_NAME = EMF_DRAFTBOX_NAME;
-#endif
-}
-#endif
-
-namespace {
-const char* TEMP_FOLDER = "/tmp";
 const char* COMMAND_NAME = "/bin/cp";
 const char* COMMAND_SWITCH_RECURSIVE = "-r";
-const char* COMMAND_SWITCH_FORCE = "-f";
+//const char* COMMAND_SWITCH_FORCE = "-f";
 }
 
 Email::Email(const string& id) :
@@ -188,24 +173,26 @@ void Email::sendCancel(int handle)
 int Email::downloadBody()
 {
        LOG_ENTER
-
        return MailSync::getInstance().downloadBody( Api::Messaging::MessageFactory::convertToEmail(SharedFromThis()) );
-       
        LOG_EXIT
 }
 
 void Email::downloadBodyCancel( int handle)
 {      
-       
-       return ;
+       return MailSync::getInstance().cancelDownloadBody(handle);
 }
 
 int Email::downloadAttachment( const Api::Messaging::IAttachmentPtr& attachment)
 {
        LOG_ENTER
-
        return MailSync::getInstance().downloadAttachment( Api::Messaging::MessageFactory::convertToEmail(SharedFromThis()), attachment );
-       
+       LOG_EXIT
+}
+
+void Email::downloadAttachmentCancel( int handle)
+{      
+       LOG_ENTER
+       return MailSync::getInstance().cancelDownloadAttachment(handle);
        LOG_EXIT
 }
 
@@ -219,23 +206,59 @@ void Email::update(bool draftsOnly)
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
 
+    updateSubject();
+    updateBody();
+    updateRecipients();
+    updateAttachments();
+    updateReadStatus();
+
+    emf_attachment_data_t* attachment=NULL;
+    int attachmentCount = 0;
+    int error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("Nothing to update or error. [" << error << "]");
+    }
+
+    error = email_update_mail( m_mail.Get(), attachment, attachmentCount, NULL, 0);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("Nothing to update or error. [" << error << "]");
+    }
+
+    if (attachment)
+    {
+           error = email_free_attachment_data(&attachment, attachmentCount);
+           if (EMF_ERROR_NONE != error) {
+                 LogWarning("Nothing to update or error. [" << error << "]");
+           }
+    }
+#if 0  
     LogDebug("getCurrentFolder() = " << getCurrentFolder() );
     if (!draftsOnly || (getCurrentFolder() == Api::Messaging::DRAFTBOX)) {
+               
         updateBody();
         updateSubject();
         updateRecipients();
-        updateFrom();
         updateAttachments();
         updatePriority();
+               
     } else {
         LogWarning("Updating only read status. Folder: " << getCurrentFolder());
     }
     updateReadStatus();
 
-    int error = email_update_message(getIntId(), m_mail.Get());
+    //get attachment
+    emf_attachment_data_t* attachment=NULL;
+    int attachmentCount = 0;
+    int error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("Nothing to update or error. [" << error << "]");
+    }
+
+    error = email_update_mail( m_mail.Get(), attachment, attachmentCount, NULL, 0);
     if (EMF_ERROR_NONE != error) {
-        LogWarning("Nothing to update or error. [" << error << "]");
+         LogWarning("Nothing to update or error. [" << error << "]");
     }
+#endif
 
     LOG_EXIT
 }
@@ -245,7 +268,7 @@ int Email::getAccountID()
        LOG_ENTER
 
        if ( m_mail )
-               return m_mail->info->account_id;
+               return m_mail->account_id;
        else
                return -1;
        
@@ -257,7 +280,7 @@ int Email::getUID()
        LOG_ENTER
        
        if (m_mail)
-               return m_mail->info->uid;
+               return m_mail->mail_id;
        else
                return -1;
 
@@ -266,11 +289,15 @@ int Email::getUID()
 
 int Email::isBodyDownloaded()
 {
-       
+
        if (m_mail)
-               return m_mail->info->body_downloaded;
+               if ( m_mail->body_download_status == 1 )        // 1 is fully downloaded body.
+                       return true;
+               else
+                       return false;
        else
                return false;
+
 }
 
 bool Email::hasAttachment()
@@ -298,22 +325,30 @@ void Email::moveToFolder(const FolderType newFolder)
 
 void Email::moveToFolder(const string& newFolder)
 {
-    update();
+       Assert(m_mail && "mail is NULL.");
+       
+       update();
 
-    int accountId = Messaging::getInstance().getEmailAccountId(getFromRef());
-    ScopedMailbox mailbox(
-        EmailService::createMailbox(accountId, newFolder.c_str())
-        );
+       int accountId = m_mail->account_id;
+       int mailId = getIntId();
 
-    int mailId = getIntId();
+       emf_mailbox_t* mailbox = EmailService::alloc<emf_mailbox_t>();
+       mailbox->account_id = accountId;
+       mailbox->name = (NULL != newFolder.c_str() ? strdup(newFolder.c_str()) : NULL);
 
-    int error = email_move_mail_to_mailbox(&mailId, 1, mailbox.Get());
-    if (EMF_ERROR_NONE != error) {
-        ThrowMsg(
-            WrtDeviceApis::Commons::PlatformException,
-            "Couldn't move mail to folder: " << newFolder << ". [" <<
-            error << "]");
-    }
+       int error = email_move_mail_to_mailbox(&mailId, 1, mailbox);
+       if (EMF_ERROR_NONE != error) {
+       ThrowMsg(
+           WrtDeviceApis::Commons::PlatformException,
+           "Couldn't move mail to folder: " << newFolder << ". [" <<
+           error << "]");
+       }
+       
+       error = email_free_mailbox(&mailbox, 1);        //free
+       if (EMF_ERROR_NONE != error) {
+           LogError("Failed to destroy mailbox: " << error);
+       }
+       
 }
 
 void Email::copyToFolder(const FolderType newFolder)
@@ -327,23 +362,30 @@ void Email::copyToFolder(const FolderType newFolder)
 
 void Email::copyToFolder(const string& newFolder)
 {
-    LOG_ENTER
-
-    update();
-
-    int accountId = Messaging::getInstance().getEmailAccountId(getFromRef());
-
-    ScopedMail mail(EmailService::cloneMail(m_mail.Get()));
-    ScopedMailbox mailbox(
-        EmailService::createMailbox(accountId, newFolder.c_str())
-        );
+       LOG_ENTER
+       Assert(m_mail && "mail is NULL.");
 
-    int mailId = EmailService::addMailToMailbox(mail.Get(), mailbox.Get());
-    // TODO Is following check necessary?
-    if (0 == mailId) {
-        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Cloned mail didn't get new id.");
-    }
+       update();
 
+       int accountId = m_mail->account_id;
+       ScopedMail mail(EmailService::cloneMail(m_mail.Get())); //clone
+       mail->mailbox_name = (NULL != newFolder.c_str() ? strdup(newFolder.c_str()) : NULL);
+       mail->account_id = accountId;
+       
+       //Attachment
+       emf_attachment_data_t* attachment = NULL;
+       int attachmentCount = 0;
+       int error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);    //get Attachment list
+       if (EMF_ERROR_NONE != error) {
+               ThrowMsg( WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't get attachment list: " << newFolder << ". [" << error << "]");
+       }
+       
+       int mailId = EmailService::addMail( mail.Get(), attachment );
+       if (0 == mailId) {
+           ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Cloned mail didn't get new id.");
+       }
+       
     LOG_EXIT
 }
 
@@ -385,16 +427,19 @@ void Email::create( Api::Messaging::EmailAccountInfo& account )
        LOG_ENTER
 
        m_accountId = account.getIntId();
-       MailSender::getInstance();
+       //MailSender::getInstance();
        
       LogDebug("account ID : " << m_accountId);
-       ScopedMail mail(EmailService::createMail(account));
+       ScopedMail mail(EmailService::createMailData(account));
+       
        setEmailAccount(account);       //save account
-       ScopedMailbox mailbox(EmailService::getMailboxByType(account.getIntId(), EMF_MAILBOX_TYPE_DRAFT));
-       setId(convertId(EmailService::addMailToMailbox(mail.Get(), mailbox.Get())));
+
+       mail->mailbox_type = EMF_MAILBOX_TYPE_DRAFT;
+       
+       setId(convertId(EmailService::addMail(mail.Get(), NULL)));
        setFolderType(Api::Messaging::DRAFTBOX);
        setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
-           
+       
     LOG_EXIT
 }
 
@@ -402,16 +447,21 @@ void Email::reload()
 {
     LOG_ENTER
 
-   //EmailAccountInfo account = Messaging::getInstance().getCurrentEmailAccount();
-    LogDebug("account ID :" << m_accountId);
-    m_mail.Reset(EmailService::readMail(m_accountId, getIntId()));
+    LogDebug("mail ID :" << getIntId());
+    m_mail.Reset(EmailService::readMail(getIntId()));          //reset Mail Data
+
+    readHeader();
+    readBody();
+    readInfo();
 
-    if (m_mail->head) { readHeader(); }
-    if (m_mail->body) { readBody(); }
-    if (m_mail->info) { readInfo(); }
+    //if (m_mail->head) { readHeader(); }
+    //if (m_mail->body) { readBody(); }
+    //if (m_mail->info) { readInfo(); }
 
-    m_mailbox.Reset(EmailService::getMailboxByMailId(m_accountId, getIntId()) );
-    setFolderType(EmailConverter::toFolderType(m_mailbox->mailbox_type));
+    //m_mailbox.Reset(EmailService::getMailboxByMailId(m_accountId, getIntId()) );
+    //setFolderType(EmailConverter::toFolderType(m_mailbox->mailbox_type));
+    
+    setFolderType(EmailConverter::toFolderType(m_mail->mailbox_type));
 
     LOG_EXIT
 }
@@ -420,27 +470,73 @@ void Email::readHeader()
 {
     LOG_ENTER
 
-    Assert(m_mail && m_mail->head && "Header is NULL.");
+    Assert(m_mail && "Header is NULL.");
 
-    if (m_mail->head->subject) {
-        setSubject(m_mail->head->subject);
+    if (m_mail->subject) {
+        setSubject(m_mail->subject);
     }
 
-    if (m_mail->head->to) {
-        appendToRecipients(EmailUtils::stripAddressLine(m_mail->head->to));
+    if (m_mail->full_address_to) {
+        appendToRecipients(EmailUtils::stripAddressLine(m_mail->full_address_to));
     }
 
-    if (m_mail->head->cc) {
-        appendCcRecipients(EmailUtils::stripAddressLine(m_mail->head->cc));
+    if (m_mail->full_address_cc) {
+        appendCcRecipients(EmailUtils::stripAddressLine(m_mail->full_address_cc));
     }
 
-    if (m_mail->head->bcc) {
-        appendBccRecipients(EmailUtils::stripAddressLine(m_mail->head->bcc));
+    if (m_mail->full_address_bcc) {
+        appendBccRecipients(EmailUtils::stripAddressLine(m_mail->full_address_bcc));
     }
 
+#if 1
+    struct tm *t;
+    t = localtime(&m_mail->date_time);
+    struct tm timeinfo;
+    memcpy(t, &timeinfo, sizeof(struct tm));
+    setDateTime(timeinfo); 
+
+#else
+
+       if (m_mail->datetime[0] != '\0')
+       {
+               char buf[MAX_DATETIME_STRING_LENGTH];
+               char *targetBuf = m_mail->datetime;
+               struct tm timeinfo;
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.4s", targetBuf);
+               timeinfo.tm_year = atoi(buf) - 1900;
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
+               timeinfo.tm_mon =  atoi(buf) - 1;
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
+               timeinfo.tm_mday =      atoi(buf);
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
+               timeinfo.tm_hour = atoi(buf);
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
+               timeinfo.tm_min = atoi(buf);
+
+               memset(buf, 0x00, sizeof(buf));
+               targetBuf += snprintf(buf, sizeof(buf), "%.2s", targetBuf);
+               timeinfo.tm_sec = atoi(buf);
+               
+               setDateTime(timeinfo);
+       }
+
+#endif
+       
+#if 0
     time_t rawtime;
     time(&rawtime);
     struct tm tmpTime = *(localtime(&rawtime));
+
     tmpTime.tm_year = m_mail->head->datetime.year;
     tmpTime.tm_mon = m_mail->head->datetime.month;
     tmpTime.tm_mday = m_mail->head->datetime.day;
@@ -449,10 +545,11 @@ void Email::readHeader()
     tmpTime.tm_sec = m_mail->head->datetime.second;
     mktime(&tmpTime);
     setDateTime(tmpTime);
+#endif
 
-    if (m_mail->head->from) {
+    if (m_mail->full_address_from) {
         Recipients from;
-        from.setRecipients(m_mail->head->from);
+        from.setRecipients(m_mail->full_address_from);
         setSourceAddress(from);
         setSourceAddressValidity(true); //not needed to update in platform
     }
@@ -463,13 +560,13 @@ void Email::readHeader()
 void Email::readBody() {
        LOG_ENTER
 
-       Assert(m_mail && m_mail->body && "Body is NULL.");
+       Assert(m_mail && "Body is NULL.");
 
-       if (m_mail->body->plain) {
-               DPL::ScopedFClose file(::fopen(m_mail->body->plain, "r"));
+       if (m_mail->file_path_plain) {
+               DPL::ScopedFClose file(::fopen(m_mail->file_path_plain, "r"));
                if (!file) {
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                                       "Cannot read body file: " << m_mail->body->plain);
+                                       "Cannot read body file: " << m_mail->file_path_plain);
                }
                fseek(file.Get(), 0, SEEK_END);
                long int size = ftell(file.Get());
@@ -481,11 +578,11 @@ void Email::readBody() {
        }
 
        //html body.
-       if (m_mail->body->html) {
-               DPL::ScopedFClose file(::fopen(m_mail->body->html, "r")); //auto close, scopedFClose
+       if (m_mail->file_path_html) {
+               DPL::ScopedFClose file(::fopen(m_mail->file_path_html, "r")); //auto close, scopedFClose
                if (!file) {
                        ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                                       "Cannot read html body file: " << m_mail->body->html);
+                                       "Cannot read html body file: " << m_mail->file_path_html);
                }
 
                fseek(file.Get(), 0, SEEK_END);
@@ -496,41 +593,59 @@ void Email::readBody() {
                fread(data.Get(), 1, size, file.Get());
                setHtmlBody(data.Get()); //setHtmlBody declarate in Email Calss.
        }
+
+       //Attachment
+       //emf_attachment_info_t* attachment = NULL;
+       emf_attachment_data_t* attachment = NULL;
+       int attachmentCount = 0;
        
-       if (m_mail->body->attachment && m_mail->body->attachment_num > 0) {
-               LogDebug("reading attachments , attahcment count = " << m_mail->body->attachment_num);
-               emf_attachment_info_t* attach = m_mail->body->attachment;
-               for (int i = 0; i < m_mail->body->attachment_num; ++i) {
-                       if (!attach) {
-                               LogDebug("throw platform exception");
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                                               "Attachment list shorter than expected.");
-                       }
+       int error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);    //get Attachment list
+       if (EMF_ERROR_NONE != error) {
+               ThrowMsg( WrtDeviceApis::Commons::PlatformException, "Couldn't get attachment list: ");
+       }
+       
+       if ( attachment && attachmentCount > 0)
+       {
+               LogDebug("reading attachments , attahcment count = " << attachmentCount);
+               int i = 0;
+
+               for ( i = 0; i < attachmentCount; i++)
+               {
+                       Try {
+                               LogDebug("attachment ID :" << attachment[i].attachment_id << " name :" << attachment[i].attachment_name << " download :" << attachment[i].save_status << "savefile :" << attachment[i].attachment_path);
+                                                       
+                               IAttachmentPtr tmpAtt(new Attachment());
+                               if (attachment[i].attachment_path)
+                                       tmpAtt->init(attachment[i].attachment_path, false);
                        
-                       try {
-                               
-                               LogError("id :" << attach->attachment_id << " name :" << attach->name << " download :" << attach->downloaded << " savefile :" << attach->savename );
-                               
-                               IAttachmentPtr tmpAtt(new Attachment(attach));
-                               LogError(" create new attachment ");
                                if (tmpAtt)
                                {
-                                       //tmpAtt->setMessage(SharedFromThis());                 //set IMessagePtr
-                                       tmpAtt->rename(attach->name);
-                                       tmpAtt->setAttachmentID(attach->attachment_id);
-                                       tmpAtt->setDownloaded(attach->downloaded);
+                                       tmpAtt->rename(std::string(attachment[i].attachment_name));
+                                       tmpAtt->setAttachmentID(attachment[i].attachment_id);
+                                       tmpAtt->setDownloaded(attachment[i].save_status);
+                                       //tmpAtt->setMimeType(std::string(attachment[i].attachment_mime_type));
                                        tmpAtt->setNth(i+1);
+                       
                                        appendAttachment(tmpAtt);
-                                       LogError(" append complete");
                                }
-                                                               
-                               attach = attach->next;
-               }
-               catch (const WrtDeviceApis::Commons::Exception& ex) {
-                               LogError("Error while trying to append attachment " <<
-                                       attach->savename << ": " << ex.DumpToString());
+                                       LogDebug(" append Attachment complete");
+
+                       
                        }
+                       catch ( const WrtDeviceApis::Commons::Exception& ex )
+                       {
+                               LogError("Error while trying to append attachment " << attachment[i].attachment_path << ": " << ex.DumpToString());
+                       }
+                       
                }
+
+             if (attachment)
+             {
+                       error = email_free_attachment_data(&attachment, attachmentCount);
+                       if (EMF_ERROR_NONE != error) {
+                               ThrowMsg( WrtDeviceApis::Commons::PlatformException, " attachment_data free error! ");
+                       }
+             }
        }
 
        LOG_EXIT
@@ -540,16 +655,14 @@ void Email::readInfo()
 {
     LOG_ENTER
 
-    Assert(m_mail && m_mail->info && "Info is NULL.");
+    Assert(m_mail && "Info is NULL.");
 
-    setReadStatus(m_mail->info->flags.seen == 1);
+    setReadStatus(m_mail->flags_seen_field == 1);
 
-    m_accountId = m_mail->info->account_id;
+    m_accountId = m_mail->account_id;
 
-    setPriority(
-        EmailConverter::toMessagePriority( m_mail->info->extra_flags.priority )
-        );
-    setSize(m_mail->info->rfc822_size);
+    setPriority( EmailConverter::toMessagePriority( m_mail->priority ) );
+    setSize(m_mail->mail_size);
 
     LOG_EXIT
 }
@@ -563,37 +676,28 @@ void Email::updateBody()
     if (!m_mail) {
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
-
-    if (!m_mail->body) {
-        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Body is NULL.");
-    }
-    if (!m_mail->body->plain) {
-        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Body file is NULL.");
+    if (!m_mail->file_path_plain) {
+        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Plain Body is NULL.");
     }
-
-    if (!m_mail->body->html) {
-       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Html Body file is NULL.");
-    }
-
-    if (!m_mail->info) {
-        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Info is NULL.");
-    }
-
+    if (!m_mail->file_path_html) {
+        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Html Body file is NULL.");
+    } 
+   
     //update plain body.
-    FILE* f = fopen(m_mail->body->plain, "w");
+    FILE* f = fopen(m_mail->file_path_plain, "w");
     if (NULL != f) {
-        //fprintf(f, getBodyRef().c_str());
         fwrite(getBodyRef().c_str(), strlen(getBodyRef().c_str()), 1, f);
         fclose(f);
     }
     else
     {
-               LogDebug("Plain Body file is NULL.");
+         LogDebug("Plain Body file is NULL.");
+         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Plain Body File Open Error");
     }
 
-    if (m_mail->body->html) {
+    if (m_mail->file_path_html) {
         //update html body
-        f = fopen(m_mail->body->html, "w");
+        f = fopen(m_mail->file_path_html, "w");
            if (NULL != f) {
                //fprintf(f, getHtmlBody().c_str());
                  fwrite(getHtmlBody().c_str(), strlen(getHtmlBody().c_str()), 1, f);
@@ -603,9 +707,11 @@ void Email::updateBody()
     else
     {
                LogDebug("Html Body file is NULL.");
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "HTML Body File Open Error");
     }
     
-    m_mail->info->body_downloaded = true;
+    m_mail->body_download_status = true;
+       
     setBodyValidity(true);
 
     LOG_EXIT
@@ -622,12 +728,8 @@ void Email::updateSubject()
     if (!m_mail) {
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail not allocated.");
     }
-
-    if (!m_mail->head) {
-        m_mail->head = EmailService::alloc<emf_mail_head_t>();
-    }
-
-    m_mail->head->subject = String::strdup(getSubjectRef());
+    
+    m_mail->subject = String::strdup(getSubjectRef());
     setSubjectValidity(true);
 
     LOG_EXIT
@@ -645,11 +747,7 @@ void Email::updateReadStatus()
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail not allocated.");
     }
 
-    if (!m_mail->info) {
-        EmailService::alloc<emf_mail_info_t>();
-    }
-
-    m_mail->info->flags.seen = isRead();
+    m_mail->flags_seen_field = isRead();
     setReadStatusValidity(true);
 
     LOG_EXIT
@@ -668,60 +766,129 @@ void Email::updateIsRead()
     LOG_EXIT
 }
 
-void Email::addMessageToDraft()
+void Email::updateMessage()
 {
     LOG_ENTER
+       emf_meeting_request_t *meeting_req = NULL;
 
-#if 0
-       //check Message Status.
     DPL::Mutex::ScopedLock mx(&m_updateMutex);
 
     if (!m_mail) {
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
 
+    LogDebug("getCurrentFolder() = " << getCurrentFolder() );
+
     updateBody();
     updateSubject();
     updateRecipients();
     updateFrom();
+    updateAttachments();
     updatePriority();
+    updateReadStatus();
 
-    int error = email_update_message(getIntId(), m_mail.Get());        
-    LogDebug("add finished, mailId = " << error);              
-#endif
+    //get attachment
+    emf_attachment_data_t* attachment=NULL;
+    int attachmentCount = 0;
+    int error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("email_get_attachment_data_list [" << error << "]");
+    }
 
-    if ( getUID() > 0 && m_accountId > 0)
-    {  //update
+       error = email_get_meeting_request(m_mail->mail_id, &meeting_req);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("email_get_meeting_request() failed [%d]\n" << error);
+    }
 
-       update();
+    error = email_update_mail( m_mail.Get(), attachment, attachmentCount, meeting_req, 0);
+    if (EMF_ERROR_NONE != error) {
+         LogWarning("Nothing to update or error. [" << error << "]");
+    }
+
+       if(meeting_req)
+               email_free_meeting_request(&meeting_req, 1);
+
+    LOG_EXIT
+}
+
+void Email::addMessageToDraft()
+{
+    LOG_ENTER
+
+    MailSender::getInstance(); //start email service
        
+    if ( getUID() > 0 && m_accountId > 0)
+    {  
+               update();
     }
     else
-    {
+    {  
+               DPL::Mutex::ScopedLock mx(&m_updateMutex);
+               
                Api::Messaging::EmailAccountInfo account = getEmailAccount();
                m_accountId = account.getIntId();       //set account ID
-               MailSender::getInstance();
+               LogDebug("account ID : " << m_accountId);
+               m_mail.Reset(EmailService::createMailData(account));
+               
+               updateSubject();
+               updateBody();
+               updateRecipients();
+               updatePriority();
+               updateReadStatus();
+               
+               emf_mailbox_t* mailbox;
+               int error = email_get_mailbox_by_mailbox_type(m_accountId, EMF_MAILBOX_TYPE_DRAFT, &mailbox );
+               if (EMF_ERROR_NONE != error) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << error << "]");
+               }
+               if ( mailbox->name )
+                       m_mail->mailbox_name = strdup(mailbox->name);
+               LogDebug("mail MailBox Name :" << m_mail->mailbox_name);
+
+               error = email_add_mail(m_mail.Get(), NULL, 0, NULL, 0);
+               if (EMF_ERROR_NONE != error) {
+                      ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                               "Couldn't add message to mailbox. [" << error << "]");
+               }
+               
+               LogDebug("message id =" << m_mail->mail_id);
                
-               LogDebug("account ID : " << m_accountId);       
-               ScopedMail mail(EmailService::createMail(account));
+               setId(convertId(m_mail->mail_id));
+               setFolderType(DRAFTBOX);
+               setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
 
-               LogDebug("get mail" );
-               emf_mail_t* ma = mail.Get();
-               if (ma)
-                       LogDebug("UID : " << ma->info->uid);
+               updateAttachments();    //update Attachment.
                
-               setEmailAccount(account);       //save account
-               ScopedMailbox mailbox(EmailService::getMailboxByType(account.getIntId(), EMF_MAILBOX_TYPE_DRAFT));
-               setId(convertId(EmailService::addMailToMailbox(mail.Get(), mailbox.Get())));
+               error = email_free_mailbox(&mailbox, 1);
+               if (EMF_ERROR_NONE != error) {
+                       LogError("Failed to destroy mailbox: " << error);
+               }
 
-               reload();       //reload mail
-               update(); //update message.
+               LogDebug("m_mail->from" << m_mail->full_address_from);
 
-               LogDebug("Folder = " << EmailConverter::toFolderType(m_mailbox->mailbox_type));
-               setFolderType(EmailConverter::toFolderType(m_mailbox->mailbox_type));
-               setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
+               emf_mail_data_t* result = NULL;
+
+               error = email_get_mail_data(m_mail->mail_id, &result);
+               if (EMF_ERROR_NONE != error) {
+                   ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                            "Couldn't find message " << m_mail->mail_id << ". [" << error << "]");
+               }
+
+               if (m_mail->file_path_plain)
+                       free(m_mail->file_path_plain);
+               m_mail->file_path_plain = strdup(result->file_path_plain);
+               
+               if ( m_mail->file_path_html)
+                       free(m_mail->file_path_html);
+               m_mail->file_path_html = strdup(result->file_path_html);
                
-               LogDebug("Message ID : " << getUID());
+               error = email_free_mail_data(&result, 1);
+               if (EMF_ERROR_NONE != error) {
+                   ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                            "Couldn't find message " << m_mail->mail_id << ". [" << error << "]");
+               }               
+
     }
 
     LOG_EXIT
@@ -737,35 +904,31 @@ void Email::updateRecipients()
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
 
-    if (!m_mail->head) {
-        m_mail->head = EmailService::alloc<emf_mail_head_t>();
-    }
-
     if (!getToValidity()) {
         std::string addressLine = EmailUtils::formatAddressLine(getToRecipients());
-        if (m_mail->head->to) {
-            free(m_mail->head->to);
+        if (m_mail->full_address_to) {
+            free(m_mail->full_address_to);
         }
-        m_mail->head->to = String::strdup(addressLine);
+        m_mail->full_address_to = String::strdup(addressLine);
         setToValidity(true);
     }
 
     if (!getCcValidity()) {
         std::string addressLine = EmailUtils::formatAddressLine(getCcRecipients());
-        if (m_mail->head->cc) {
-            free(m_mail->head->cc);
+        if (m_mail->full_address_cc) {
+            free(m_mail->full_address_cc);
         }
-        m_mail->head->cc = String::strdup(addressLine);
+        m_mail->full_address_cc = String::strdup(addressLine);
         setCcValidity(true);
     }
 
     if (!getBccValidity()) {
         std::string addressLine = EmailUtils::formatAddressLine(
                 getBccRecipients());
-        if (m_mail->head->bcc) {
-            free(m_mail->head->bcc);
+        if (m_mail->full_address_bcc) {
+            free(m_mail->full_address_bcc);
         }
-        m_mail->head->bcc = String::strdup(addressLine);
+        m_mail->full_address_cc = String::strdup(addressLine);
         setBccValidity(true);
     }
 
@@ -782,12 +945,12 @@ void Email::updateFrom()
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
 
-    if (!m_mail->info) {
-        EmailService::alloc<emf_mail_info_t>();
-    }
+    m_mail->account_id = m_accountId;
 
-    m_mail->info->account_id = m_accountId;
-    // TODO Update m_mail->head->from as well
+    if (m_mail->full_address_from) {
+          free(m_mail->full_address_from);
+    }
+    m_mail->full_address_from = String::strdup(getFrom());
 
     setFromValidity(true);
 
@@ -804,122 +967,134 @@ void Email::updateAttachments()
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail is NULL.");
     }
 
-    emf_attachment_info_t* attachment = NULL;
+    emf_attachment_data_t* attachment = NULL;
+    int attachmentCount = 0;           
+    emf_mailbox_t* mailBox = NULL;
+    int error = 0;
+
     Try {
-        LogDebug("update attachments, msgId=" << getIdRef());
-
-        if (!m_mail->body) {
-            m_mail->body = EmailService::alloc<emf_mail_body_t>();
-        } else {
-               //clean attachment
-               int i = m_mail->body->attachment_num;
-               LogDebug("clean attachment, attachment count=" << i);
-               attachment = m_mail->body->attachment;
-               std::stringstream stream;
+                //clean attachment
+               LogDebug("update attachments, msgId=" << getIdRef());
+               error = email_get_attachment_data_list( m_mail->mail_id, &attachment, &attachmentCount);        //get Attachment list
+               if (EMF_ERROR_NONE != error) {
+                       ThrowMsg( WrtDeviceApis::Commons::PlatformException, "Couldn't get attachment list: ");
+               }
                
-               while(attachment)
-               {       
-                       LogDebug("delete file :" << attachment->name << " saved name :" << attachment->savename );
-                       int aId = attachment->attachment_id;
-                       char* mId = m_mail->head->mid;
-                       int n_mId = 0;
-                       stream << mId;
-                       stream >> n_mId;
-                       stream << aId;
-
-                       LogDebug("mID :"  << n_mId << " Attachment Id :" << aId );
-                       
-                       int error = email_delete_attachment(m_mailbox.Get(), n_mId, (const char*)(stream.str()).c_str());
-                       if (EMF_ERROR_NONE != error) {
-                           LogDebug("Error Num = " << error);
-                           ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                                    "Error while adding attachment. [" << error << "]");
+               error = email_get_mailbox_by_name(m_mail->account_id, m_mail->mailbox_name, &mailBox);
+               if (EMF_ERROR_NONE != error) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't get mailbox. [" << error << "]");
+               }       
+                
+               if ( attachmentCount > 0 )
+               {
+                       int i = 0;
+                       std::stringstream stream;
+                       for ( i = 0; i < attachmentCount; i++)
+                       {
+                               LogDebug("file name:" << attachment[i].attachment_name << " file path :" << attachment[i].attachment_path);
+                               int attachmentId = attachment[i].attachment_id;
+
+                               stream << attachmentId;
+                               int error = email_delete_attachment(mailBox, m_mail->mail_id, (const char*)(stream.str()).c_str());
+                               if (EMF_ERROR_NONE != error) {
+                                   LogDebug("Error Num = " << error);
+                                   ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                            "Error while adding attachment. [" << error << "]");
+                               }
+                               stream.str("");
+                       }
+
+                       if ( attachment )
+                       {
+                               error = email_free_attachment_data(&attachment, attachmentCount);
+                               if (EMF_ERROR_NONE != error) {
+                                       ThrowMsg( WrtDeviceApis::Commons::PlatformException, " attachment_data free error! ");
+                               }
                        }
-                       attachment = attachment->next;
+
                }
                
-            m_mail->body->attachment_num = 0;
-            if (NULL != m_mail->body->attachment) {
-                EmailService::freeAttachment(m_mail->body->attachment);
-                m_mail->body->attachment = NULL;
-            }
-        }
+               //set Attachment
+               std::size_t attachmentSize = getAttachmentsCount();
+               LogDebug("update attachments, attachmentSize=" << attachmentSize);
+               if (attachmentSize > 0) {
+                       emf_attachment_info_t* attachment_info = NULL;
+                       for (std::size_t i = 0; i < attachmentSize; ++i) {
+                               IAttachmentPtr att = getAttachment(i);
+                               if (!att) {
+                                       continue;
+                               }
+
+                               //copy attachment file
+                               std::stringstream cp_cmd;
+                               char buf[] = "/tmp/XXXXXX";
+                               int i = mkstemp(buf);
+
+                               cp_cmd << COMMAND_NAME;
+                               cp_cmd << " " << COMMAND_SWITCH_RECURSIVE;
+                               cp_cmd << " \"" << att->getFullPath() << "\"";
+                               cp_cmd << " \"" << buf << "\"";
+
+                               attachment_info = EmailService::alloc<emf_attachment_info_t>();
+                               attachment_info->name = String::strdup(att->getShortName());
+                               attachment_info->savename = String::strdup( buf );
+                               attachment_info->next = NULL;
+                               attachment_info->downloaded = true;
+
+                               LogDebug("Copy Command=" << cp_cmd.str());
+
+                               int result = system(cp_cmd.str().c_str());
+                               if (-1 != result) {
+                                       if (0 != WIFEXITED(result)) {
+                                               if (0 != WEXITSTATUS(result)) {
+                                                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Command failed.");
+                                               }
+                                       } else {
+                                               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                               "Command terminated abnormally.");
+                                       }
+                               } else {
+                                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't launch command.");
+                               }
 
-        std::size_t attachmentSize = getAttachmentsCount();
-       LogDebug("update attachments, attachmentSize=" << attachmentSize);
-        if (attachmentSize > 0) {
-            if (!m_mail->info) {
-                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail info is NULL.");
-            }
-
-            for (std::size_t i = 0; i < attachmentSize; ++i) {
-                IAttachmentPtr att = getAttachment(i);
-                if (!att) {
-                    continue;
-                }
-
-                       //copy attachment file
-                       std::stringstream to_oss;
-                       to_oss << TEMP_FOLDER << "/" << att->getShortName();
-                       LogDebug("temp file=" << to_oss.str());
+                               LogDebug("add Attachment");
+                               int error = email_add_attachment(mailBox,
+                                                        m_mail->mail_id, attachment_info);
+                               if (EMF_ERROR_NONE != error) {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                    "Error while adding attachment. [" << error << "]");
+                               }
+                               else 
+                               {       
+                                       LogDebug(" attachment id : " << attachment_info->attachment_id);                                
+                                               //IMessagePtr msg = DPL::DynamicPointerCast<IMessage>(this);
+                                       att->setDownloaded(true);
+                                       att->setAttachmentID(attachment_info->attachment_id);
+                                       att->setMessage(SharedFromThis());
+                                       att->setNth(i+1);
+                               }
+                               
+                               if (attachment_info)
+                                       EmailService::freeAttachment(attachment_info);
+                       }       
                        
-                       std::stringstream cp_oss;
-                       cp_oss << COMMAND_NAME;
-                       cp_oss << " " << COMMAND_SWITCH_RECURSIVE;
-                       cp_oss << " \"" << att->getFullPath() << "\"";
-                       cp_oss << " \"" << to_oss.str() << "\"";
-
-                attachment = EmailService::alloc<emf_attachment_info_t>();     //create attachment struct
-                attachment->name = String::strdup(att->getShortName());
-                //attachment->savename = String::strdup( att->getFullPath() );
-                attachment->savename = String::strdup( to_oss.str().c_str() );
-                
-                attachment->next = NULL;
-                    attachment->downloaded = true;
-
-                       int result = system(cp_oss.str().c_str());                      
-                       if (-1 != result) {
-                           if (0 != WIFEXITED(result)) {
-                               if (0 != WEXITSTATUS(result)) {
-                                   ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Command failed.");
-                               }
-                           } else {
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                                        "Command terminated abnormally.");
-                           }
-                       } else {
-                           ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Couldn't launch command.");
-                       }
-                                                                       
-                    LogDebug( "mailbox type = " << m_mailbox.Get()->mailbox_type);
-
-                int error = email_add_attachment(m_mailbox.Get(),
-                                                 m_mail->info->uid,
-                                                 attachment);
-                if (EMF_ERROR_NONE != error) {
-                    ThrowMsg(WrtDeviceApis::Commons::PlatformException,
-                             "Error while adding attachment. [" << error << "]");
-                }
-               else 
-               {       
-                       LogDebug(" attachment id : " << attachment->attachment_id);                             
-                       //IMessagePtr msg = DPL::DynamicPointerCast<IMessage>(this);
-                       att->setDownloaded(true);
-                       att->setAttachmentID(attachment->attachment_id);
-                       att->setMessage(SharedFromThis());
-                       att->setNth(i+1);
-               }
-
-                EmailService::freeAttachment(attachment);
-            }
-
-            setAttachmentsValidity(true);
-        }
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        EmailService::freeAttachment(attachment);
-        throw;
-    }
+               }
+       
+       } 
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+          if (attachment) 
+          {
+               int error = email_free_attachment_data(&attachment, attachmentCount);
+               if (EMF_ERROR_NONE != error) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                    "Error while adding attachment data [" << error << "]");
+               }
+
+               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                    "Error attachment Update");
+          }
+       }
 
     LOG_EXIT
 }
@@ -934,12 +1109,7 @@ void Email::updatePriority()
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Mail not allocated.");
     }
 
-    if (!m_mail->info) {
-        m_mail->info = EmailService::alloc<emf_mail_info_t>();
-    }
-
-    m_mail->info->extra_flags.priority = EmailConverter::toMailPriority(
-            getPriority());
+    m_mail->priority = EmailConverter::toMailPriority( getPriority());
     setPriorityValid(true);
 
     LOG_EXIT
@@ -949,6 +1119,7 @@ int Email::getIntId() const
 {
     return convertId(getIdRef());
 }
+
 }
 }
 }
index 502a9ae..7cd900b 100755 (executable)
@@ -80,6 +80,8 @@ class Email : public Api::Messaging::IEmail
 
        virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment);
 
+       virtual void downloadAttachmentCancel( int handle );
+
     // implementation of interface of IMessage class
     virtual void update(bool draftsOnly = false);
 
@@ -130,6 +132,8 @@ class Email : public Api::Messaging::IEmail
 
     void updateIsRead();
        
+    void updateMessage();      
+       
     void addMessageToDraft();
        
     void updatePriority();
@@ -140,7 +144,7 @@ class Email : public Api::Messaging::IEmail
     DPL::Mutex m_updateMutex;
     int m_accountId;
     ScopedMail m_mail;
-    ScopedMailbox m_mailbox;
+    ScopedMailbox m_mailbox;   //delete?
 };
 }
 }
index 2559123..877f3dc 100755 (executable)
@@ -113,6 +113,24 @@ Api::Messaging::FolderType toFolderType(emf_mailbox_type_e mailboxType)
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Conversion failed.");
     }
 }
+
+Api::Messaging::FolderType toFolderType(int mailboxType)
+{
+    LOG_ENTER
+    switch (mailboxType) {
+    case EMF_MAILBOX_TYPE_INBOX: return Api::Messaging::INBOX;
+    case EMF_MAILBOX_TYPE_OUTBOX: return Api::Messaging::OUTBOX;
+    case EMF_MAILBOX_TYPE_SENTBOX: return Api::Messaging::SENTBOX;
+    case EMF_MAILBOX_TYPE_DRAFT: return Api::Messaging::DRAFTBOX;
+    case EMF_MAILBOX_TYPE_SPAMBOX: return Api::Messaging::SPAMBOX;
+    case EMF_MAILBOX_TYPE_ALL_EMAILS: return Api::Messaging::ALL_FOLDERS;
+    case EMF_MAILBOX_TYPE_USER_DEFINED: return Api::Messaging::USERDEFINED_FOLDER;
+    default:
+        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Conversion failed.");
+    }
+}
+
+
 }
 }
 }
index 7d50c44..6ccdade 100755 (executable)
@@ -17,7 +17,7 @@
 #ifndef _TIZEN_MESSAGING_EMAILCONVERTER_H_
 #define _TIZEN_MESSAGING_EMAILCONVERTER_H_
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <API/Messaging/MessagePriority.h>
 #include <API/Messaging/IMessagingTypes.h>
@@ -36,6 +36,8 @@ emf_mailbox_type_e toMailboxType(Api::Messaging::FolderType folder);
 const char* toMailboxName(Api::Messaging::FolderType folder);
 
 Api::Messaging::FolderType toFolderType(emf_mailbox_type_e mailboxType);
+Api::Messaging::FolderType toFolderType(int mailboxType);
+
 }
 }
 }
index fd6a9e9..fbf51b9 100755 (executable)
@@ -23,7 +23,7 @@
 #include <dpl/assert.h>
 #include <dpl/scoped_free.h>
 
-#include <Emf_Mapi.h>
+#include <email-api.h>
 
 #include <Commons/Exception.h>
 #include "EmailUtils.h"
@@ -38,47 +38,40 @@ namespace TizenApis {
 namespace Platform {
 namespace Messaging {
 namespace EmailService {
-emf_mail_t* createMail(const Api::Messaging::EmailAccountInfo& account)
+
+emf_mail_data_t* createMailData(const Api::Messaging::EmailAccountInfo& account)
 {
     LOG_ENTER
-    ScopedMail result(alloc<emf_mail_t>());
+    ScopedMail result(alloc<emf_mail_data_t>());
 
-    result->info = alloc<emf_mail_info_t>();
-    result->info->account_id = account.getIntId();
-    result->info->flags.draft = 1;
-    result->info->extra_flags.priority = EMF_MAIL_PRIORITY_NORMAL;
+    result->account_id = account.getIntId();
+    result->flags_draft_field = 1;
+    result->priority = EMF_MAIL_PRIORITY_NORMAL;
 
-    result->head = alloc<emf_mail_head_t>();
-    std::string from = EmailUtils::formatAddress(account.getAddress(),
-                                                 account.getName());
-    result->head->from = strdup(from.c_str());
+    std::string from = EmailUtils::formatAddress(account.getAddress(), account.getName());
+    result->full_address_from = strdup(from.c_str());
 
-    result->body = alloc<emf_mail_body_t>();
     std::string bodyFile = tmpnam(NULL);
-
     FILE* f = fopen(bodyFile.c_str(), "w");
     fclose(f);
-    result->body->plain = strdup(bodyFile.c_str());
+
+    result->file_path_plain = strdup(bodyFile.c_str());
+
     std::string htmlFile = tmpnam(NULL);
-       
     f = fopen(htmlFile.c_str(), "w");
     fclose(f);
-    result->body->html = strdup(htmlFile.c_str());
+    result->file_path_html = strdup(htmlFile.c_str());
 
     LOG_EXIT
     return result.Release();
 }
 
-emf_mail_t* readMail(int accountId,
-        int mailId)
+emf_mail_data_t* readMail(int mailId)
 {
     LOG_ENTER
-    emf_mail_t* result = NULL;
-
-    emf_mailbox_t mailbox = {};
-    mailbox.account_id = accountId;
-
-    int error = email_get_mail(&mailbox, mailId, &result);
+    emf_mail_data_t* result = NULL;
+    
+    int error = email_get_mail_data(mailId, &result);
     if (EMF_ERROR_NONE != error) {
         ThrowMsg(WrtDeviceApis::Commons::PlatformException,
                  "Couldn't find message " << mailId << ". [" << error << "]");
@@ -119,21 +112,65 @@ emf_mailbox_t* getMailboxByType(int accountId,
     return result;
 }
 
-int addMailToMailbox(emf_mail_t* mail,
-        emf_mailbox_t* mailbox)
+int addMail(emf_mail_data_t* mail, emf_attachment_data_t* attachment)
 {
     LOG_ENTER
-    Assert(mail && mailbox);
+    Assert(mail);
+
+    int error = 0;
+    if (!mail->mailbox_name)
+    {
+               //get mail box
+               if ( mail->mailbox_type > 0)
+               {
+                       emf_mailbox_t* mailbox;
+                       error = email_get_mailbox_by_mailbox_type(mail->account_id, EMF_MAILBOX_TYPE_DRAFT, &mailbox );
+                       if (EMF_ERROR_NONE != error) {
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << error << "]");
+                       }
+
+                       if ( mailbox->name )
+                               mail->mailbox_name = strdup(mailbox->name);
+
+                       LogDebug("mail MailBox Name :" << mail->mailbox_name);
+                       
+                       error = email_free_mailbox(&mailbox, 1);
+                  if (EMF_ERROR_NONE != error) {
+                      LogError("Failed to destroy mailbox: " << error);
+                  }
+               }                                       
+    }
 
-    int error = email_add_message(mail, mailbox, 1);
+    error = email_add_mail(mail, attachment, mail->attachment_count, NULL, 0);
+    if (EMF_ERROR_NONE != error) {
+        ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                 "Couldn't add message to mailbox. [" << error << "]");
+    }
+   
+    LOG_EXIT
+    LogDebug("Mail to MailBox, mail id = " << mail->mail_id );
+    return mail->mail_id;
+}
+
+#if 0
+int addMailToMailbox(emf_mail_data_t* mail,
+        emf_attachment_data_t* attachment, int attachment_count )
+{
+    LOG_ENTER
+    Assert(mail);
+
+    int error = email_add_mail(mail, attachment, attachment_count, NULL, 0);
     if (EMF_ERROR_NONE != error) {
         ThrowMsg(WrtDeviceApis::Commons::PlatformException,
                  "Couldn't add message to mailbox. [" << error << "]");
     }
 
     LOG_EXIT
-    return mail->info->uid;
+    LogDebug("Mail to MailBox, mail id = " << mail->mail_id );
+    return mail->mail_id;
 }
+#endif
 
 void freeAttachment(emf_attachment_info_t* attachment)
 {
@@ -144,9 +181,9 @@ void freeAttachment(emf_attachment_info_t* attachment)
     if (EMF_ERROR_NONE != error) {
         LogWarning("Couldn't free attachment. [" << error << "]");
     }
-    LOG_ENTER
+    LOG_EXIT
 }
-
+/*
 emf_mailbox_t* createMailbox(int accountId,
         const char* name)
 {
@@ -158,20 +195,21 @@ emf_mailbox_t* createMailbox(int accountId,
     LOG_EXIT
     return result;
 }
-
+*/
+       
 // TODO This clonning is not efficent.
-emf_mail_t* cloneMail(const emf_mail_t* mail)
+emf_mail_data_t* cloneMail(const emf_mail_data_t* mail)
 {
     LOG_ENTER
-    emf_mail_t* result = readMail(mail->info->account_id, mail->info->uid);
-    result->info->uid = 0;
+    emf_mail_data_t* result = readMail(mail->mail_id);
+    result->mail_id = 0;
+    result->account_id = 0;
 
     LOG_EXIT
     return result;
 }
 
-emf_mailbox_t* getMailboxByMailId(int accountId,
-        int mailId)
+emf_mailbox_t* getMailboxByMailId(int accountId, int mailId)
 {
     LOG_ENTER
     char* mailboxName = NULL;
@@ -197,7 +235,6 @@ emf_mailbox_t* getMailboxByMailId(int accountId,
 void updateSeenFlag(int accountId, int mailId, bool isReadChangeStatus)
 {
     LOG_ENTER
-
        
     if ( accountId > -1 )
     {
@@ -219,6 +256,7 @@ void updateSeenFlag(int accountId, int mailId, bool isReadChangeStatus)
     LOG_EXIT
 }
 
+
 }
 }
 }
index 884a81c..19e288c 100755 (executable)
@@ -25,7 +25,7 @@
 #include <cstdlib>
 #include <new>
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <API/Messaging/EmailAccountInfo.h>
 
@@ -45,6 +45,32 @@ T* alloc()
     return result;
 }
 
+#if 1
+emf_mail_data_t* createMailData(const Api::Messaging::EmailAccountInfo& account);
+
+emf_mail_data_t* readMail(int mailId);
+
+emf_mailbox_t* getMailboxByType(int accountId,
+        emf_mailbox_type_e type);
+
+int addMail(emf_mail_data_t* mail, emf_attachment_data_t* attachment);
+
+//int addMailToMailbox(emf_mail_data_t* mail, emf_mailbox_t* mailbox);
+
+void deleteMail(int accountId, int mailId);
+
+void freeAttachment(emf_attachment_info_t* attachment);
+
+//emf_mailbox_t* createMailbox(int accountId, const char* name);
+
+emf_mail_data_t* cloneMail(const emf_mail_data_t* mail);
+
+emf_mailbox_t* getMailboxByMailId(int accountId, int mailId);
+
+void updateSeenFlag(int accountId, int mailId, bool isReadChangeStatus);
+
+#else 
+
 emf_mail_t* createMail(const Api::Messaging::EmailAccountInfo& account);
 
 emf_mail_t* readMail(int accountId,
@@ -71,6 +97,8 @@ emf_mailbox_t* getMailboxByMailId(int accountId,
 
 void updateSeenFlag(int accountId, int mailId, bool isReadChangeStatus);
 
+#endif
+
 }
 }
 }
old mode 100644 (file)
new mode 100755 (executable)
index 2a75634..691f6cc
@@ -28,7 +28,7 @@
 #include <API/Messaging/log.h>
 #include <Commons/Exception.h>
 
-#include <emf-types.h>
+#include <email-types.h>
 
 #include <dpl/log/log.h>
 
index d882ec1..d940028 100755 (executable)
  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
  */
 #include <utility>
-#include <emf-types.h>
-#include <Emf_Mapi.h>
-#include <Emf_Mapi_Network.h>
-#include <Emf_Mapi_Init.h>
-#include <Emf_Mapi_Account.h>
+#include <email-types.h>
+#include <email-api.h>
+#include <email-api-network.h>
+#include <email-api-init.h>
+#include <email-api-account.h>
 
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
@@ -30,6 +30,7 @@
 #include <Commons/ThreadPool.h>
 #include <API/Messaging/ReqReceiverMessage.h>
 #include <API/Messaging/EventSendMessage.h>
+#include <API/Messaging/EventMessagingService.h>
 #include <API/Messaging/EventOnSendingFailed.h>
 #include "MailSender.h"
 #include "NetworkStatus.h"
@@ -137,10 +138,12 @@ void MailSender::OnEventReceived(const DBus::MessageEvent& event)
         case NOTI_SEND_FINISH:
         {
             const Api::Messaging::IEmailPtr& mail = it->second.mail;
-            Api::Messaging::EventSendMessageReqReceiver* requestReceiver =
-                mail->getRequestReceiver();
+            //Api::Messaging::EventSendMessageReqReceiver* requestReceiver = mail->getRequestReceiver();
+            Api::Messaging::EventMessagingServiceReqReceiver* requestReceiver = mail->getRequestReceiver();
+               
             if (requestReceiver) {
-                Api::Messaging::EventSendMessagePtr event = mail->getSendMessageEvent();
+                //Api::Messaging::EventSendMessagePtr event = mail->getSendMessageEvent();
+                Api::Messaging::EventMessagingServicePtr event = mail->getMessagingServiceEvent();
                     if (event)
                        {
                                for (size_t i = 0; i < mail->getToRecipients().getRecipientSize(); ++i) {
@@ -167,8 +170,8 @@ void MailSender::OnEventReceived(const DBus::MessageEvent& event)
         {
             const Api::Messaging::IEmailPtr& mail = it->second.mail;
             Api::Messaging::EventOnSendingFailedEmitterPtr emitter = mail->getEmitter();
-            Api::Messaging::EventSendMessageReqReceiver *requestReceiver =
-                mail->getRequestReceiver();
+            //Api::Messaging::EventSendMessageReqReceiver *requestReceiver = mail->getRequestReceiver();
+            Api::Messaging::EventMessagingServiceReqReceiver* requestReceiver = mail->getRequestReceiver();
             if (emitter) {
                 Api::Messaging::EventOnSendingFailedPtr event(
                     new Api::Messaging::EventOnSendingFailed()
@@ -197,7 +200,8 @@ void MailSender::OnEventReceived(const DBus::MessageEvent& event)
                 }
                 emitter->emit(event);
             } else if (requestReceiver) {
-                Api::Messaging::EventSendMessagePtr event = mail->getSendMessageEvent();
+                //Api::Messaging::EventSendMessagePtr event = mail->getSendMessageEvent();
+                       Api::Messaging::EventMessagingServicePtr event = mail->getMessagingServiceEvent();
                 event->setExceptionCode(
                     WrtDeviceApis::Commons::ExceptionCodes::UnknownException
                     );
index 5d559e2..43e9583 100755 (executable)
  * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
  */
 #include <utility>
-#include <emf-types.h>
-#include <Emf_Mapi.h>
-#include <Emf_Mapi_Network.h>
-#include <Emf_Mapi_Init.h>
-#include <Emf_Mapi_Account.h>
+#include <email-types.h>
+#include <email-api.h>
+#include <email-api-network.h>
+#include <email-api-init.h>
+#include <email-api-account.h>
 
 #include <dpl/log/log.h>
 #include <dpl/assert.h>
@@ -163,11 +163,29 @@ void MailSync::cancelDownloadBody(int handle)
        
 }
 
+void MailSync::cancelDownloadAttachment(int handle)
+{
+       Assert(handle > -1);
+
+       SyncRequestIterator it = m_SyncRequests.find(handle);
+       if ( m_SyncRequests.end() != it)
+       {
+               if (  it->second.messagingService )
+                       cancelEmailJobInternal( it->second.messagingService->getAccountID() , it->second.handle);
+               //cancelDownloadBodyInternal(it->second.mail, it->second.handle );
+       }
+       else
+       {
+               LogDebug("Don't find cancel DownloadAttachment handle : " << handle);
+       }
+       
+}
+
 int MailSync::downloadAttachment(const Api::Messaging::IEmailPtr& mail, const Api::Messaging::IAttachmentPtr& attachment)
 {      
        if ( mail && attachment )
        {       
-               int mailId = mail->convertId(mail->getIdRef());         // get mail id
+               //int mailId = mail->convertId(mail->getIdRef());               // get mail id
                LogDebug("start attachment, mail Id : " << mail->getIdRef());
                SyncRequestIterator it;
                for( it = m_SyncRequests.begin(); it != m_SyncRequests.end(); ++it)
@@ -224,7 +242,7 @@ int MailSync::syncAccountInternal( const Api::Messaging::IMessagingServicePtr& m
        unsigned emf_handle = 0;
        
        memset(&mailbox, 0, sizeof(emf_mailbox_t));
-       mailbox.name = NULL;    /* all folders. */
+       mailbox.name = NULL;                            /* all folders. */
        mailbox.account_id = account_id; //set account id.
        int slot_size;
        
@@ -324,24 +342,31 @@ int MailSync::syncFolderInternal(const Api::Messaging::IMessagingServicePtr& mes
        LogDebug("Folder Name=" << folderName << " limit : " << limit);
 
        int account_id = messagingService->getAccountID();
-       emf_mailbox_t mailbox;
-       gchar *src_box =g_strdup( folderName.c_str() );
-       unsigned emf_handle = 0;
-       
+
+       unsigned emf_handle = 0;        
        int err = 0;
-       memset(&mailbox, 0, sizeof(emf_mailbox_t));
-       mailbox.name = src_box;
-       mailbox.account_id = account_id;
        int slot_size = 0;
-               
+       emf_mailbox_t* mailbox;
+       char* mailbox_name = strdup(folderName.c_str());
+       
+       err = email_get_mailbox_by_name(account_id, mailbox_name, &mailbox );
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << err << "]");
+       }       
+       
        if ( limit < 0 )
                slot_size = m_default_slot_size;
        else
                slot_size = limit;
        
-       email_set_mail_slot_size(0, src_box, slot_size);
+       err = email_set_mail_slot_size(0, mailbox_name, slot_size);
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't set mail solt size. [" << err << "]");
+       }
        
-       err = email_sync_header(&mailbox, &emf_handle);
+       err = email_sync_header(mailbox, &emf_handle);
        if (err != EMF_ERROR_NONE) {
                LogDebug("fail to sync folders - err : " << err);
        }
@@ -353,10 +378,13 @@ int MailSync::syncFolderInternal(const Api::Messaging::IMessagingServicePtr& mes
                m_SyncRequests.insert(std::make_pair(emf_handle, data));
        }
 
-       if (src_box) {
-               g_free(src_box);
-       }
+       if (mailbox_name)
+               free(mailbox_name);
 
+       if ( mailbox )
+               if  (  EMF_ERROR_NONE != email_free_mailbox( &mailbox , 1) )
+                       LogDebug("fail to email_free_mailbox - err ");
+       
        return emf_handle;
 }
        
@@ -378,7 +406,7 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
                LogDebug(" Debus mailID = " <<  mailId <<  " , Nth = " << nth );
                
                SyncRequestIterator it = m_SyncRequests.begin();
-               for ( it; it != m_SyncRequests.end(); it++ )
+               for ( ; it != m_SyncRequests.end(); it++ )
                {
                        const Api::Messaging::IEmailPtr& mail = it->second.mail;
                        
@@ -401,7 +429,7 @@ void MailSync::OnEventReceived(const DBus::MessageEvent& event)
                                                        emf_attachment_info_t *attach_info = NULL;
                                                        memset(&mailbox, 0, sizeof(emf_mailbox_t));
                                                        mailbox.account_id = acountId; //set account id.
-                                                       int attachmentId = attachment->getAttachmentID();
+                                                       //int attachmentId = attachment->getAttachmentID();
                                                        std::stringstream stream;
                                                        stream << attachment->getAttachmentID();
                                                        LogDebug("Attachment ID = " << stream.str());
@@ -550,19 +578,26 @@ int MailSync::downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int a
        int err = 0;
        int mailId = mail->convertId(mail->getIdRef());
        unsigned int emf_handle = 0;
-
-
-       LogDebug("folder type = " << mail->getCurrentFolder());
        
-       emf_mailbox_t mailbox;
-       memset(&mailbox, 0, sizeof(emf_mailbox_t));
+       LogDebug("folder type = " << mail->getCurrentFolder());
 
-       mailbox.name = strdup("INBOX");
-       
-       mailbox.account_id = account_id;        //set account id.       
-       LogDebug("mailbox.account_id " << mailbox.account_id << " mailId : " << mailId);
-       err = email_download_body(&mailbox, mailId, 0, &emf_handle);
+       char *mailbox_name =NULL;
+       err = email_get_mailbox_name_by_mail_id(mailId, &mailbox_name);
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << err << "]");
+       }
+       LogDebug("mail ID :" << mailId );
+       LogDebug("mailbox name : " << mailbox_name );   
+
+       emf_mailbox_t* mailbox;
+       err = email_get_mailbox_by_name(mail->getAccountID(), mailbox_name, &mailbox );
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << err << "]");
+       }
        
+       err = email_download_body(mailbox, mailId, 0, &emf_handle);
        if (err != EMF_ERROR_NONE) {
                LogDebug("fail to downloadBody - err : " << err);
                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to initialize downloadBody request. [" << err << "]");
@@ -575,6 +610,10 @@ int MailSync::downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int a
                m_SyncRequests.insert(std::make_pair(emf_handle, data));
        }
 
+       if ( mailbox )
+               if  (  EMF_ERROR_NONE != email_free_mailbox( &mailbox , 1) )
+                       LogDebug("fail to email_free_mailbox - err ");
+
        return emf_handle;
 
 }
@@ -582,22 +621,31 @@ int MailSync::downloadBodyInternal( const Api::Messaging::IEmailPtr& mail, int a
 int MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail, int account_id, const Api::Messaging::IAttachmentPtr& attachment)
 {
        LogDebug("downloadAttachmentInternal");
-
+       Assert(mail);
+       
        int err = 0;
        int nth = 0;
-       int idx = 0;
        int mailId = mail->convertId(mail->getIdRef());
        unsigned emf_handle = 0;
        
-       emf_mailbox_t mailbox;
-       //gchar *src_box = g_strdup(folder_name);
-       memset(&mailbox, 0, sizeof(emf_mailbox_t));
-       mailbox.account_id = account_id;        //set account id.
-       LogDebug("mailbox.account_id " << mailbox.account_id );
-       LogDebug("Attachment ID :" << attachment->getAttachmentID());
+       char *mailbox_name =NULL;
+       err = email_get_mailbox_name_by_mail_id(mailId, &mailbox_name);
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << err << "]");
+       }
+       LogDebug("mail ID :" << mailId );
+       LogDebug("mailbox name : " << mailbox_name );   
+
+       emf_mailbox_t* mailbox;
+       err = email_get_mailbox_by_name(mail->getAccountID(), mailbox_name, &mailbox );
+       if (EMF_ERROR_NONE != err) {
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                       "Couldn't add message to mailbox. [" << err << "]");
+       }
        
+       LogDebug("Attachment ID :" << attachment->getAttachmentID());   
        std::stringstream stream;
-       //stream << attachment->getAttachmentID();
        
        if (stream.fail()) {
                ThrowMsg(WrtDeviceApis::Commons::UnknownException,
@@ -606,7 +654,7 @@ int MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail,
 
        //get nth 
        std::vector<Api::Messaging::IAttachmentPtr> attachments = mail->getAttachments();
-       for ( int i = 0 ; i < attachments.size() ; i ++)
+       for ( unsigned int i = 0 ; i < attachments.size() ; i ++)
        {
                LogDebug( "attachment ID is = " << attachments[i]->getAttachmentID());
                if (attachments[i]->getAttachmentID() == attachment->getAttachmentID())
@@ -618,9 +666,8 @@ int MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail,
        
        stream << nth+1;
        LogDebug("nth = " << stream.str());
-
        LogDebug("attachment Order Index = " << stream.str());
-       err = email_download_attachment(&mailbox, mailId, stream.str().c_str() , &emf_handle);
+       err = email_download_attachment(mailbox, mailId, stream.str().c_str() , &emf_handle);
        if (err != EMF_ERROR_NONE) {
                LogDebug("fail to downloadAttachment - err : " << err);
                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to initialize downloadAttachment request. [" << err << "]");
@@ -631,11 +678,14 @@ int MailSync::downloadAttachmentInternal(const Api::Messaging::IEmailPtr& mail,
                LogDebug("handle : " << emf_handle);
                SyncRequestData data = SyncRequestData( emf_handle,     
                        MESSAGING_SERVICE_SYNC_TYPE_DOWNLOAD_ATTACHMENT, mail, attachment );
-               m_SyncRequests.insert(std::make_pair(emf_handle, data));
+               m_SyncRequests.insert(std::make_pair(emf_handle, data));                
        }
 
-       return emf_handle;
+       if ( mailbox )
+               if  (  EMF_ERROR_NONE != email_free_mailbox( &mailbox , 1) )
+                       LogDebug("fail to email_free_mailbox - err ");
        
+       return emf_handle;
 }
 
 void MailSync::cancelEmailJobInternal(int accountId, int handle)
index f7eab61..ad60ba4 100755 (executable)
@@ -43,7 +43,7 @@ MessageFolder::MessageFolder()
 
 MessageFolder::MessageFolder(emf_mailbox_t m_mailboxes)
 {
-       m_id = (int)m_mailboxes.mailbox_type;   
+       m_id = m_mailboxes.mailbox_id;  
        m_parentid = -1;
        m_accountid = m_mailboxes.account_id;
        m_contentType = TYPE_EMAIL;
@@ -109,17 +109,17 @@ int MessageFolder::getFolderType(emf_mailbox_type_e folderType)
        {
                return FOLDER_INBOX;
        }
-       else if(EMF_MAILBOX_TYPE_OUTBOX == folderType)
+       else if(EMF_MAILBOX_TYPE_SENTBOX == folderType)
        {
-               return FOLDER_OUTBOX;
+               return FOLDER_SENTBOX;
        }
        else if(EMF_MAILBOX_TYPE_DRAFT == folderType)
        {
                return FOLDER_DRAFTS;
        }
-       else if(EMF_MAILBOX_TYPE_SENTBOX == folderType)
+       else if(EMF_MAILBOX_TYPE_OUTBOX == folderType)
        {
-               return FOLDER_SENTBOX;
+               return FOLDER_OUTBOX;
        }
        else if(EMF_MAILBOX_TYPE_ALL_EMAILS != folderType)
        {
index 05f4112..4b8851a 100755 (executable)
@@ -24,7 +24,7 @@
 #include <vector>
 #include <API/Messaging/IMessageFolder.h>
 
-#include <emf-types.h>
+#include <email-types.h>
 
 
 namespace TizenApis {
index b126750..a006752 100755 (executable)
 #include <API/Messaging/log.h>
 #include <Commons/Exception.h>
 
-#include <emf-types.h>
+#include <email-types.h>
+#include <MsgStorageTypes.h>
+#include <sstream>
+#include <time.h>
 
 #include <dpl/log/log.h>
 
@@ -78,6 +81,31 @@ namespace TizenApis {
                        initAttributeMap();
                }
 
+               MessageQueryGenerator::MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type):
+                       m_messageType(MESSAGE_TYPE_NOT_INITIALIZED){
+                       LogDebug("<<< limit:" << limit << ", offset:" << offset);
+                       m_query.append(getQueryPrefix());
+
+                       //TODO check sort mode validation
+                       m_sortMode = sortMode;
+
+                       m_limit = limit;
+                       m_offset = offset;
+                       m_serviceType = type;
+                       
+                       if((type == Api::Messaging::SMS) || (type == Api::Messaging::MMS))
+                       {
+                               m_mode = MODE_SMS_MMS;
+                       }
+                       else
+                       {
+                               m_mode = MODE_EMAIL;
+                       }
+
+                       initAttributeMap();
+               }
+                               
+
                MessageQueryGenerator::~MessageQueryGenerator() {
                }
 
@@ -102,7 +130,10 @@ namespace TizenApis {
                                                                                                        MessageFilterValidatorFactory::ATTRIBUTE_ID,             "mail_id"));
                        attributeMap.insert(
                                                                                        std::pair<std::string, std::string>(
-                                                                                                       MessageFilterValidatorFactory::ATTRIBUTE_FOLDER,          "mailbox_type"));
+                                                                                                       MessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID,      "account_id"));                       
+                       attributeMap.insert(
+                                                                                       std::pair<std::string, std::string>(
+                                                                                                       MessageFilterValidatorFactory::ATTRIBUTE_FOLDER,          "mailbox_id"));
                        attributeMap.insert(
                                                                                        std::pair<std::string, std::string>(
                                                                                                        MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP,       "date_time"));
@@ -126,7 +157,7 @@ namespace TizenApis {
                                                                                                        MessageFilterValidatorFactory::ATTRIBUTE_IS_READ,          "mail_status"));     //TODO 1:seen, 2:deleted, 4:flagged, 8:answered, 20:draft
                        attributeMap.insert(
                                                                                        std::pair<std::string, std::string>(
-                                                                                                       MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY,         "priority"));
+                                                                                                       MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY,         "isHighPriority"));
                        attributeMap.insert(
                                                                                        std::pair<std::string, std::string>(
                                                                                                        MessageFilterValidatorFactory::ATTRIBUTE_SUBJECT,          "subject"));
@@ -208,6 +239,7 @@ namespace TizenApis {
                void MessageQueryGenerator::visitPreComposite(Api::Tizen::FilterType& type, int depth){
                        LogDebug("<<<");
                        m_queryVector.push_back("(");
+                       LogDebug("getServiceType = " << getServiceType());                      
                        LogDebug(">>>");
                }
 
@@ -223,7 +255,10 @@ namespace TizenApis {
                                }
 
                                LogDebug(">>>");
-                               return;
+                               if(m_mode == MODE_EMAIL)
+                               {
+                                       return;
+                               }
                        }
 
                        if(type == INTERSECTION_FILTER){
@@ -244,7 +279,10 @@ namespace TizenApis {
                        LogDebug("<<<");
                        if(m_typeProcessing == 1){
                                m_typeProcessing = 0;
-                               m_queryVector.erase(m_queryVector.end());
+                               if(m_mode == MODE_EMAIL)
+                               {
+                                       m_queryVector.erase(m_queryVector.end());
+                               }
                        }else{
                        }
 
@@ -288,14 +326,18 @@ namespace TizenApis {
                        std::string retFolderType;
                        std::ostringstream outstream;
 
-                       if(value.compare("INBOX") == 0){
-                               outstream << EMF_MAILBOX_TYPE_INBOX;
-                       }else if(value.compare("OUTBOX") == 0){
-                               outstream << EMF_MAILBOX_TYPE_OUTBOX;
-                       }else if(value.compare("DRAFTBOX") == 0){
-                               outstream << EMF_MAILBOX_TYPE_DRAFT;
-                       }else if(value.compare("SENTBOX") == 0){
-                               outstream << EMF_MAILBOX_TYPE_SENTBOX;
+                       if(value.compare("1") == 0){
+                               LogDebug("<<< value:[INBOX]");
+                               outstream << MSG_INBOX_ID;
+                       }else if(value.compare("2") == 0){
+                               LogDebug("<<< value:[OUTBOX]");                 
+                               outstream << MSG_OUTBOX_ID;
+                       }else if(value.compare("3") == 0){
+                               LogDebug("<<< value:[DRAFTBOX]");                       
+                               outstream << MSG_DRAFT_ID;
+                       }else if(value.compare("4") == 0){
+                               LogDebug("<<< value:[SENTBOX]");                        
+                               outstream << MSG_SENTBOX_ID;
                        }else{
                                LogDebug("[ERROR] unsupported type:["<< value << "]");
                                ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid folder id");
@@ -380,9 +422,23 @@ namespace TizenApis {
 
                //convert from '20111115000000' to 2011-11-15 00:00:00
                std::string MessageQueryGenerator::createDateTimeTypeForSmsMms(Api::Tizen::AnyPtr& value){
+                       std::string initialValueStr;
                        LogDebug("<<< value:[" << value->toString() << "]");
 
-                       std::string tmpValueString = value->toString();
+                       if (!value->isNullOrUndefined()) {
+                               if( TizenApis::Api::Tizen::PrimitiveType_Time==value->getType() ) {
+                                       LogDebug("<<<initialValue->getType()[" << value->getType() <<"]");                                      
+                                       tm date = value->getDateTm();
+                                       initialValueStr = toDateDbStr(date);
+                                       LogDebug("<<<valueStr[" << initialValueStr <<"]");
+                               }
+                               else {
+                                       LogError("initialValue->getType() : [" << value->getType() << "]");                                     
+                                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid value Type");
+                               }                               
+                       }
+
+                       std::string tmpValueString = initialValueStr;
                        std::string secondsSinceType;
                        secondsSinceType.append("strftime('%s', ");                     //SQL time format function
                        if(m_mode == MODE_SMS_MMS){
@@ -396,19 +452,58 @@ namespace TizenApis {
                        return secondsSinceType;
                }
 
+               std::string MessageQueryGenerator::createDateTimeTypeForSmsMms(std::string& timeString){
+                       LogDebug("<<< value:[" << timeString << "]");
+
+                       std::string tmpValueString;
+                       std::string secondsSinceType;
+                       secondsSinceType.append("strftime('%s', ");                     //SQL time format function
+                       if(m_mode == MODE_SMS_MMS){
+                               tmpValueString = convertToTimeFormat(timeString);
+                       }
+
+                       secondsSinceType.append(tmpValueString);
+                       secondsSinceType.append(")");
+
+                       LogDebug(">>> retPriorityType:[" << secondsSinceType << "]");
+                       return secondsSinceType;
+               }
+
                std::string MessageQueryGenerator::createDateTimeTypeForEmail(Api::Tizen::AnyPtr& value)
                {
+                       std::string initialValueStr;
                        LogDebug("<<< value:[" << value->toString() << "]");
 
                        if(value->getType() != PrimitiveType_Time){
                                LogError("[ERROR]>> invalid type");
                                return NULL;
                        }
+                               
+                       if (!value->isNullOrUndefined()) {
+                               if( TizenApis::Api::Tizen::PrimitiveType_Time==value->getType() ) {
+                                       LogDebug("<<<initialValue->getType()[" << value->getType() <<"]");                                      
+                                       tm date = value->getDateTm();
+                                       initialValueStr = toDateDbStr(date);
+                                       LogDebug("<<<valueStr[" << initialValueStr <<"]");
+                               }
+                               else {
+                                       LogError("initialValue->getType() : [" << value->getType() << "]");                                     
+                                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid value Type");
+                               }                               
+                       }
+                       return initialValueStr;
+               }
 
-                       std::string retPriorityType;
-                       retPriorityType = value->toString();
-
-                       return retPriorityType;
+               std::string MessageQueryGenerator::toDateDbStr(const tm &date) const
+               {
+                       stringstream ss;
+                       ss << setfill('0') << setiosflags(ios::right) << setw(4) << (date.tm_year + 1900);
+                       ss << setfill('0') << setiosflags(ios::right) << setw(2) << (date.tm_mon + 1);
+                       ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_mday;
+                       ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_hour;
+                       ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_min;
+                       ss << setfill('0') << setiosflags(ios::right) << setw(2) << date.tm_sec;
+                       return ss.str();
                }
 
                std::string MessageQueryGenerator::convertBooleanStringToIntegerString(std::string& booleanString){
@@ -442,6 +537,12 @@ namespace TizenApis {
                                        }else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY)==0){
                                                retClause = emfAttributeName + "=" + createPriorityTypeForEmail(valueString);
                                                break;
+                                       }else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_SERVICE_ID)==0){
+                                               retClause = emfAttributeName + "=" + valueString;
+                                               break;
+                                       } else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_FOLDER)==0) {
+                                               retClause = emfAttributeName + "=" + valueString;
+                                               break;
                                        }
                                }else if(m_mode == MODE_SMS_MMS){
                                        if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_FROM)==0){
@@ -456,13 +557,18 @@ namespace TizenApis {
                                        }else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY)==0){
                                                retClause = emfAttributeName + "=" + createPriorityTypeForSmsMms(valueString);
                                                break;
+                                       } else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_FOLDER)==0) {
+                                               retClause = emfAttributeName + "=" + createFolderType(valueString);
+                                               break;
+                                       } else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_TYPE)==0) {
+                                               retClause = emfAttributeName + "=" + convertMessageTypeToString(valueString);
+                                               break;
                                        }
+
                                }
 
                                if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_IS_READ)==0) {
                                        retClause = emfAttributeName + "=" + convertBooleanStringToIntegerString(valueString);
-                               } else if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_FOLDER)==0) {
-                                       retClause = emfAttributeName + "=" + createFolderType(valueString);
                                } else if (attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_ATTACHMENT) == 0 ) {
                                        if(valueString.compare("true") == 0){
                                                retClause = emfAttributeName + " > 0" ;
@@ -591,6 +697,26 @@ namespace TizenApis {
                }
 
 
+               std::string MessageQueryGenerator::convertMessageTypeToString(std::string& stringType){
+                       LogDebug("<<< value:[" << stringType << "]");
+                       std::string retMessageType;
+                       std::ostringstream outstream;
+
+                       if(stringType.compare("messaging.sms") ==0){
+                               outstream << Api::Messaging::SMS;
+                       }else if(stringType.compare("messaging.mms") ==0){
+                               outstream << Api::Messaging::MMS;
+                       }else if(stringType.compare("messaging.email") ==0){
+                               outstream << Api::Messaging::EMAIL;
+                       }else{
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid msg type");
+                       }
+
+                       retMessageType = outstream.str();
+                       
+                       return retMessageType;
+               }
+
                void MessageQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
@@ -599,9 +725,11 @@ namespace TizenApis {
                                m_currentType = value->toString();
 
                                m_messageType = convertMessageType(m_currentType);
-
-                               LogDebug(">>> skip type");
-                               return;
+                               if(m_messageType == Api::Messaging::EMAIL)
+                               {
+                                       LogDebug(">>> skip type");
+                                       return;
+                               }
                        }
 
                        std::string emfAttributeName = convertToEmfAttrName(attrName);
@@ -637,22 +765,48 @@ namespace TizenApis {
                void MessageQueryGenerator::visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth) {
                        LogDebug("<<< sttrName:[" << attrName <<"]");
 
+                       string initialValueStr;
+                       string endValueStr;
+
                        if(initialValue == NULL || endValue == NULL)
                                return;
-
-                       LogDebug("initialVAlue:[" << initialValue->toString() << "]");
-                       LogDebug("endValue:[" << endValue->toString() << "]");
-
+                       
                        std::string tmpStringBuffer;
 
                        std::string emfAttributeName = convertToEmfAttrName(attrName);
                        if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)==0){
+
+                               if (!initialValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==initialValue->getType() ) {
+                                               LogDebug("<<<initialValue->getType()[" << initialValue->getType() <<"]");                                       
+                                               tm date = initialValue->getDateTm();
+                                               initialValueStr = toDateDbStr(date);
+                                               LogDebug("<<<valueStr[" << initialValueStr <<"]");
+                                       }
+                                       else {
+                                               LogError("initialValue->getType() : [" << initialValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid initialValue Type");
+                                       }
+                               }
+                               
+                               if (!endValue->isNullOrUndefined()) {
+                                       if( TizenApis::Api::Tizen::PrimitiveType_Time==endValue->getType() ) {
+                                               LogDebug("<<<initialValue->getType()[" << endValue->getType() <<"]");                                   
+                                               tm date = endValue->getDateTm();
+                                               endValueStr = toDateDbStr(date);
+                                       } else {
+                                               LogError("endValue->getType() : [" << endValue->getType() << "]");                                      
+                                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid endValue Type");
+                                       }
+                               }
+
+                               
                                if(m_mode == MODE_EMAIL){
-                                       tmpStringBuffer.append(emfAttributeName + " BETWEEN " + initialValue->toString() + " AND " + endValue->toString());
+                                       tmpStringBuffer.append(emfAttributeName + " BETWEEN " + initialValueStr + " AND " + endValueStr);
                                }else if(m_mode == MODE_SMS_MMS){
                                        tmpStringBuffer.append(emfAttributeName + " BETWEEN " +
-                                                       createDateTimeTypeForSmsMms(initialValue) + " AND " +
-                                                       createDateTimeTypeForSmsMms(endValue));
+                                                       createDateTimeTypeForSmsMms(initialValueStr) + " AND " +
+                                                       createDateTimeTypeForSmsMms(endValueStr));
                                }
                        }
 
@@ -699,11 +853,16 @@ namespace TizenApis {
                                }
 
                                m_query.append(getQuerySuffix());
-                               m_query.append(buffer.str());
+//                             m_query.append(buffer.str());
+                               m_orderLimit.append(buffer.str());
                                return m_query;
                        }
                }
 
+               std::string MessageQueryGenerator::getOrderLimit(){
+                       return m_orderLimit;
+               }
+
                std::string MessageQueryGenerator::getQueryPrefix(){
                        return MessageQueryGenerator::STRING_WHERE;
                }
index c1541d4..9b75dfe 100755 (executable)
@@ -46,9 +46,11 @@ namespace TizenApis {
                        private:
                                QueryGeneratorMode m_mode;
                                std::string m_query;
+                               std::string m_orderLimit;                               
                                std::vector<std::string> m_queryVector;
 
                                int m_messageType;
+                               int m_serviceType;
 
                                std::vector<std::string> typeVector;
 
@@ -73,6 +75,7 @@ namespace TizenApis {
                        public:
                                MessageQueryGenerator();
                                MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
+                               MessageQueryGenerator(const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type);                            
                                virtual ~MessageQueryGenerator();
 
                                void visitPreComposite(Api::Tizen::FilterType& type, int depth);
@@ -83,6 +86,7 @@ namespace TizenApis {
                                void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
 
                                std::string getQuery();
+                               std::string getOrderLimit();                            
 
 //                             bool containMailType();
 //                             bool containType(int type);
@@ -98,6 +102,10 @@ namespace TizenApis {
                                        return m_mode;
                                }
 
+                               int getServiceType(){
+                                       return m_serviceType;
+                               }                               
+
                                void reset(QueryGeneratorMode mode);
 
                        protected:
@@ -111,6 +119,7 @@ namespace TizenApis {
                                std::string convertToEmfAttrName(std::string attrName);
 
                                void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
+                               std::string convertMessageTypeToString(std::string& stringType);                                
 
                        private:
                                std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
@@ -124,9 +133,11 @@ namespace TizenApis {
                                std::string createDateTimeTypeForEmail(Api::Tizen::AnyPtr& value);
 
                                std::string createDateTimeTypeForSmsMms(Api::Tizen::AnyPtr& value);
+                               std::string createDateTimeTypeForSmsMms(std::string& timeString);                               
 
                                std::string convertToTimeFormat(const std::string& timeString);
                                std::string convertBooleanStringToIntegerString(std::string& booleanString);
+                               std::string toDateDbStr(const std::tm &date) const;
 
                                void initAttributeMap();
                                std::string getQueryFromVector();
index f8ee85b..6479d4b 100755 (executable)
@@ -23,8 +23,8 @@
  * @version    0.1
  * @brief
  */
-#include <emf-types.h>
-#include <Emf_Mapi.h>
+#include <email-types.h>
+#include <email-api.h>
 
 #include <Commons/Exception.h>
 #include <Commons/StringUtils.h>
@@ -145,7 +145,7 @@ Messaging::~Messaging()
 {
     // Endservice for email management
     m_dbusConnection->RemoveListener(this);
-    m_dbusConnection->setWorkerThread(NULL);
+//    m_dbusConnection->setWorkerThread(NULL);
     m_dbusWorkerThread->Quit();
     delete m_dbusWorkerThread;
 
@@ -305,8 +305,15 @@ std::string Messaging::generateFilterSql(const Api::Tizen::FilterPtr& filter){
                LogDebug("message_list.nCount:" << message_list.nCount);
                for (int i = 0; i < message_list.nCount; i++) {
 //                     int msgId = msg_get_message_id(message_list.msgInfo[i]);
-
-                       string addressVal = msg_get_ith_address(message_list.msgInfo[i], 0);
+                       string addressVal;
+                       if(msg_get_ith_address(message_list.msgInfo[i], 0) == NULL)
+                       {
+                               addressVal = "";
+                       }
+                       else
+                       {
+                               addressVal = msg_get_ith_address(message_list.msgInfo[i], 0);
+                       }
                        LogDebug("<<< addressVal:" << addressVal);
 
                        int msgType = msg_get_message_type(message_list.msgInfo[i]);
@@ -358,6 +365,42 @@ std::string Messaging::generateFilterSql(const Api::Tizen::FilterPtr& filter){
                LogDebug("<<< queryString:[" << queryString <<"]");
 
                vector<IMessagePtr> retVal;
+               std::string tempString = "";
+               MSG_LIST_S message_list = {0, NULL};
+
+               Try{
+                       MSG_ERROR_T res = MSG_ERR_UNKNOWN;
+
+                       MessageStorageReader reader;
+                       reader.MsgStoConnectDB();
+                       res = reader.queryMessage(queryString, tempString, &message_list);
+
+                       if (MSG_SUCCESS != res) {
+                               LogError("msg_get_folder_view_list failed " << res);
+                               Throw(WrtDeviceApis::Commons::PlatformException);
+                       }
+                       reader.MsgStoDisconnectDB();
+
+                       retVal = createVectorFromeMessageList(message_list);
+
+                       msg_release_message_list(&message_list);
+               }Catch(WrtDeviceApis::Commons::PlatformException) {
+                       LogError("Problem with message creation, cleaning");
+                       if (message_list.nCount) {
+                               msg_release_message_list(&message_list);
+                       }
+                       throw;
+               }       //Catch
+
+               LogDebug(">>>");
+               return retVal;
+       }
+
+       vector<IMessagePtr> Messaging::querySmsMmsMessages(const std::string& queryString, const std::string& orderLimitString){
+               LogDebug("<<< queryString:[" << queryString <<"]");
+               LogDebug("<<< orderLimitString:[" << orderLimitString <<"]");           
+
+               vector<IMessagePtr> retVal;
                MSG_LIST_S message_list = {0, NULL};
 
                Try{
@@ -365,7 +408,7 @@ std::string Messaging::generateFilterSql(const Api::Tizen::FilterPtr& filter){
 
                        MessageStorageReader reader;
                        reader.MsgStoConnectDB();
-                       res = reader.queryMessage(queryString, &message_list);
+                       res = reader.queryMessage(queryString, orderLimitString, &message_list);
 
                        if (MSG_SUCCESS != res) {
                                LogError("msg_get_folder_view_list failed " << res);
@@ -388,8 +431,9 @@ std::string Messaging::generateFilterSql(const Api::Tizen::FilterPtr& filter){
                return retVal;
        }
 
-vector<IConversationPtr> Messaging::querySmsMmsConversation(const std::string& sqlWhereClause){
+vector<IConversationPtr> Messaging::querySmsMmsConversation(const std::string& sqlWhereClause, const std::string& orderLimitString){
        LogDebug("sqlWhereClause:[" << sqlWhereClause << "]");
+       LogDebug("<<< orderLimitString:[" << orderLimitString <<"]");           
 
        std::vector<Api::Messaging::IConversationPtr> recVec;
        MSG_THREAD_VIEW_LIST_S threadViewList;
@@ -398,7 +442,7 @@ vector<IConversationPtr> Messaging::querySmsMmsConversation(const std::string& s
 
        MessageStorageReader reader;
        reader.MsgStoConnectDB();
-       res = reader.queryConversation(sqlWhereClause, &threadViewList);
+       res = reader.queryConversation(sqlWhereClause, orderLimitString, &threadViewList);
 
        if (MSG_SUCCESS != res) {
                LogError("queryConversation failed:" << res);
@@ -442,7 +486,7 @@ vector<IConversationPtr> Messaging::queryEmailConversation(const std::string& sq
                                LogDebug("mailList[i].thread_id:[" << mailList[i].thread_id << "]");                            
                                LogDebug("mailList[i].from:[" << mailList[i].from << "]");
                                LogDebug("mailList[i].from_email_address : [" << mailList[i].from_email_address <<"]");
-                               LogDebug("mailList[i].datetime:[" << mailList[i].datetime << "]");
+                               //LogDebug("mailList[i].datetime:[" << mailList[i].datetime << "]");
                                LogDebug("mailList[i].subject:[" << mailList[i].subject << "]");
                                LogDebug("mailList[i].mailbox_name:[" << mailList[i].mailbox_name << "]");
                                LogDebug("mailList[i].previewBodyText:[" << mailList[i].previewBodyText << "]");
@@ -491,7 +535,7 @@ vector<IMessagePtr> Messaging::queryEmailMessage(const std::string& sqlWhereClau
                        //TODO for debug
                        LogDebug("mailList[i].from:[" << mailList[i].from << "]");
                        LogDebug("mailList[i].from_email_address : [" << mailList[i].from_email_address <<"]");
-                       LogDebug("mailList[i].datetime:[" << mailList[i].datetime << "]");
+                       //LogDebug("mailList[i].datetime:[" << mailList[i].datetime << "]");
                        LogDebug("mailList[i].subject:[" << mailList[i].subject << "]");
                        LogDebug("mailList[i].mailbox_name:[" << mailList[i].mailbox_name << "]");
                        LogDebug("mailList[i].previewBodyText:[" << mailList[i].previewBodyText << "]");
@@ -590,6 +634,89 @@ vector<IMessagePtr> Messaging::findMessages(const Api::Tizen::FilterPtr& filter,
        return retVal;
 }
 
+vector<IMessagePtr> Messaging::findMessages(const Api::Tizen::FilterPtr& filter, const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type)
+{
+       LogDebug("<<<");
+
+       vector<IMessagePtr> retVal;
+       std::string filterSql;
+       std::string orderLimitSql ="";
+       std::string typeAndString = "AND A.MAIN_TYPE=";
+       std::string typeString = "A.MAIN_TYPE=";
+
+       MessageQueryGeneratorPtr queryGenerator(new MessageQueryGenerator(sortMode, limit, offset, type));
+
+       IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
+       filter->travel(filterVisitor, 0);
+       filterSql = queryGenerator->getQuery();
+       orderLimitSql = queryGenerator->getOrderLimit();
+       LogDebug("filterSql:[" << filterSql <<"]");
+       LogDebug("orderLimitSql:[" << orderLimitSql <<"]");
+
+       int messageType = queryGenerator->getMessageType();
+       if(messageType != -1)
+       {
+               if(messageType != type)
+               {
+                       LogDebug("filter messageType and service msg type is diff");            
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid Fiilter Type");
+               }
+       }
+       switch(type){
+               case Api::Messaging::EMAIL:
+                       LogDebug("message type is EMAIL:[" << messageType <<"]");
+                       retVal = queryEmailMessage(filterSql);
+                       break;
+
+               case Api::Messaging::SMS:
+                       LogDebug("message type is SMS :[" << messageType <<"]");
+                       typeString.append("1");
+                       typeAndString.append("1");
+                       if(filterSql.length() == 0)
+                       {
+                               filterSql.append(typeString);
+                               LogDebug("filterSql:[" << filterSql <<"]");
+                       }
+                       else
+                       {
+                               filterSql.append(typeAndString);
+                               LogDebug("filterSql:[" << filterSql <<"]");                             
+                       }
+                       LogDebug("filterSql:[" << filterSql <<"]");
+                       LogDebug("orderLimitSql.length():[" << orderLimitSql.length() <<"]");
+                       retVal = querySmsMmsMessages(filterSql, orderLimitSql);
+                       LogDebug("filterSql:[" << filterSql <<"]");                             
+                       break;                  
+               case Api::Messaging::MMS:
+                       LogDebug("message type is MMS:[" << messageType <<"]");
+                       typeString.append("2");
+                       typeAndString.append("2");
+                       if(filterSql.length() == 0)
+                       {
+                               filterSql.append(typeString);
+                               LogDebug("filterSql:[" << filterSql <<"]");
+                       }
+                       else
+                       {
+                               filterSql.append(typeAndString);
+                               LogDebug("filterSql:[" << filterSql <<"]");                     
+                       }
+                       LogDebug("filterSql:[" << filterSql <<"]");                     
+                       LogDebug("orderLimitSql.length():[" << orderLimitSql.length() <<"]");
+                       retVal = querySmsMmsMessages(filterSql, orderLimitSql);
+                       LogDebug("filterSql:[" << filterSql <<"]");                     
+                       break;
+
+               default:
+                       MsgLogError("[ERROR] >>> invlid message type:[" << messageType <<"]");
+                       return retVal;
+       }
+
+       LogDebug(">>>");
+       return retVal;
+}
+
+
 vector<string> Messaging::getMessageIds(MessageType msgType,
         FolderType folder)
 {
@@ -922,11 +1049,16 @@ void Messaging::addOnMessageReceived(
         m_onMessageReceivedHandleMgr = MsgServiceHandleMgrPtr(
                 new MsgServiceHandleMgr());
         int err;
-
-        err = msg_reg_storage_change_callback(
-        m_onMessageReceivedHandleMgr->getHandle(),
-        onMessageStorageChanged,
-        this);
+        Try{
+            err = msg_reg_storage_change_callback(
+            m_onMessageReceivedHandleMgr->getHandle(),
+            onMessageStorageChanged,
+            this);
+        }
+        Catch(WrtDeviceApis::Commons::PlatformException){
+            LogDebug("addOnMessageReceived failed");
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
 
         if (err != MSG_SUCCESS) {
             LogError("Couldn't register on MMS received callback, err=" << err);
@@ -967,11 +1099,16 @@ void Messaging::addOnMessageReceived(
         m_onMessageReceivedHandleMgr = MsgServiceHandleMgrPtr(
                 new MsgServiceHandleMgr());
         int err;
-
-        err = msg_reg_storage_change_callback(
-        m_onMessageReceivedHandleMgr->getHandle(),
-        onMessageStorageChanged,
-        this);
+        Try{
+            err = msg_reg_storage_change_callback(
+            m_onMessageReceivedHandleMgr->getHandle(),
+            onMessageStorageChanged,
+            this);
+        }
+        Catch(WrtDeviceApis::Commons::PlatformException){
+            LogDebug("addOnMessageReceived failed");                           
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
 
         if (err != MSG_SUCCESS) {
             LogError("Couldn't register on MMS received callback, err=" << err);
@@ -1013,13 +1150,21 @@ void Messaging::addOnMessageReceived(
                 new MsgServiceHandleMgr());
         int err;
 
-        err = msg_reg_storage_change_callback(
-        m_onMessageReceivedHandleMgr->getHandle(),
-        onMessageStorageChanged,
-        this);
+        Try
+        {
+            err = msg_reg_storage_change_callback(
+            m_onMessageReceivedHandleMgr->getHandle(),
+            onMessageStorageChanged,
+            this);
+        }
+        Catch(WrtDeviceApis::Commons::PlatformException){
+            LogDebug("addOnMessageReceived failed");                           
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
 
         if (err != MSG_SUCCESS) {
             LogError("Couldn't register on MMS received callback, err=" << err);
+//             Throw(WrtDeviceApis::Commons::UnknownException);
         }
 
         m_dbusConnection->open(DBUS_BUS_SYSTEM);
@@ -1109,34 +1254,47 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
     EventMessageReceivedPtr jsEvent(new EventMessageReceived());
     DBus::MessagePtr message = event.GetArg0();
 
-
-    if (!message) {
+    if (!message) 
+    {
         jsEvent->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::PlatformException);
         m_onMessageReceived.emit(jsEvent);
-    } else {
-        if (message->getInterface() == DBUS_INTERFACE_EMAIL_RECEIVED) {
+    } 
+    else 
+    {
+        if (message->getInterface() == DBUS_INTERFACE_EMAIL_RECEIVED) 
+        {
             int account_id = 0, mail_id = 0, thread_id = 0, status = 0;
             std::string name;
             emf_mailbox_t m_mailboxes;         
             emf_mailbox_t* mailboxes = NULL;
                        
             DBus::Message::ReadIterator it = message->getReadIterator();
-            for (int i = 0; it->isValid(); it->next(), ++i) {
-                if ((i == 0) && (it->getArgType() == DBUS_TYPE_INT32)) {
-                       status = it->getInt();
-                               LogInfo("status: " << status);                                  
-                } else if ((i == 1) && (it->getArgType() == DBUS_TYPE_INT32)) {
+            for (int i = 0; it->isValid(); it->next(), ++i) 
+            {
+                if ((i == 0) && (it->getArgType() == DBUS_TYPE_INT32)) 
+                {
+                    status = it->getInt();
+                    LogInfo("status: " << status);                                     
+                } 
+                else if ((i == 1) && (it->getArgType() == DBUS_TYPE_INT32)) 
+                {
                     account_id = it->getInt();
-                                       LogInfo("account_id: " << account_id);                                  
-                } else if ((i == 2) && (it->getArgType() == DBUS_TYPE_INT32)) {
-                                       mail_id = it->getInt();
-                                       LogInfo("mail_id: " << mail_id);                                                                                
-                } else if ((i == 3) && (it->getArgType() == DBUS_TYPE_STRING)) {
-                                       name = it->getString();
-                                       LogInfo("name: " << name);                                                                              
-                    } else if ((i == 4) && (it->getArgType() == DBUS_TYPE_INT32)) {
-                                       thread_id = it->getInt();
-                                       LogInfo("thread_id: " << thread_id);                                                                            
+                    LogInfo("account_id: " << account_id);                                     
+                } 
+                else if ((i == 2) && (it->getArgType() == DBUS_TYPE_INT32)) 
+                {
+                    mail_id = it->getInt();
+                    LogInfo("mail_id: " << mail_id);                                                                           
+                } 
+                else if ((i == 3) && (it->getArgType() == DBUS_TYPE_STRING)) 
+                {
+                    name = it->getString();
+                    LogInfo("name: " << name);                                                                         
+                } 
+                else if ((i == 4) && (it->getArgType() == DBUS_TYPE_INT32)) 
+                {
+                    thread_id = it->getInt();
+                    LogInfo("thread_id: " << thread_id);                                                                               
                 }
             }
                                        
@@ -1145,66 +1303,71 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 LogInfo("Email received. mail_id: " << mail_id);
 
                 IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
-
+                IConversationPtr conversation(new Conversation(thread_id, EMAIL));
+                               
                 // TODO Temporary fix: ignore messages from OUTBOX, SENTBOX & DRAFTBOX -> most probably we added them
                 Api::Messaging::FolderType folder = msg->getCurrentFolder();
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
                                
-                if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX !=
-                    folder) {
+                if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder) 
+                {
                     IEmailPtr email = MessageFactory::convertToEmail(msg);
                     jsEvent->setMessage(msg);
+                    jsEvent->setConversation(conversation);                                    
+
                     if(m_onMessageReceived.size() > 0){
-                    m_onMessageReceived.emit(jsEvent);
+                        m_onMessageReceived.emit(jsEvent);
                     }
 
                     if(m_onConversationReceived.size() > 0){
-                    m_onConversationReceived.emit(jsEvent);
+                        m_onConversationReceived.emit(jsEvent);
                     }
 
                 } else {
-                    LogWarning(
-                        "New email message in ignored folder: " << folder);
+                    LogWarning("New email message in ignored folder: " << folder);
                 }
             }
             else if ((mail_id > 0) && (NOTI_MAIL_DELETE == status)) 
             { // TODO also RECEIVE_THREAD_ITEM?
                 LogInfo("Email received. delete type: " << mail_id);                   
 
-                     std::vector<std::string> strIds = String::split(name, ',');
+                std::vector<std::string> strIds = String::split(name, ',');
 
-                       std::stringstream stream;                                               
-                       for (std::vector<std::string>::iterator it = strIds.begin(); it != strIds.end(); ++it) {
-                           LogDebug("ID is :" << *it);
+                std::stringstream stream;                                              
+                for (std::vector<std::string>::iterator it = strIds.begin(); it != strIds.end(); ++it) 
+                {
+                    LogDebug("ID is :" << *it);
 
-                           if ( (*it).length() > 0 ) //vaild id
-                           {
-                                   stream<< *it;
-                                   int id;
-                                   stream >> id;
+                    if ( (*it).length() > 0 ) //vaild id
+                    {
+                        stream<< *it;
+                        int id;
+                        stream >> id;
                                        
-                                   IMessagePtr msg = MessageFactory::createMessage(EMAIL, id);
+                        IMessagePtr msg = MessageFactory::createMessage(EMAIL, id);
+                        IConversationPtr conversation(new Conversation(thread_id, EMAIL));                                     
 
-                               Api::Messaging::FolderType folder = msg->getCurrentFolder();
-                               jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+                        Api::Messaging::FolderType folder = msg->getCurrentFolder();
+                        jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
                                                
-                               if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
-                                   IEmailPtr email = MessageFactory::convertToEmail(msg);
-                                   jsEvent->setMessage(msg);
-                                   if(m_onMessageReceived.size() > 0){
-                                           m_onMessageReceived.emit(jsEvent);
-                                   }
-                                   if(m_onConversationReceived.size() > 0){
-                                       m_onConversationReceived.emit(jsEvent);
-                                   }
-                               } else {
-                                   LogWarning(
-                                       "New email message in ignored folder: " << folder);
-                               }
-                               }
+                        if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
+                            IEmailPtr email = MessageFactory::convertToEmail(msg);
+                            jsEvent->setMessage(msg);
+                            jsEvent->setConversation(conversation);
+                            if(m_onMessageReceived.size() > 0){
+                                m_onMessageReceived.emit(jsEvent);
+                            }
+                            if(m_onConversationReceived.size() > 0){
+                                m_onConversationReceived.emit(jsEvent);
+                            }
+                        } 
+                        else {
+                            LogWarning("New email message in ignored folder: " << folder);
+                        }
+                    }
                                
-                           stream.clear();
-                       } //for
+                    stream.clear();
+                } //for
                                        
             }
             else if ((mail_id > 0) && (NOTI_MAIL_UPDATE == status)) 
@@ -1212,6 +1375,7 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 LogInfo("Email received. mail_id: " << mail_id);
 
                 IMessagePtr msg = MessageFactory::createMessage(EMAIL, mail_id);
+                IConversationPtr conversation(new Conversation(thread_id, EMAIL));
 
                 Api::Messaging::FolderType folder = msg->getCurrentFolder();
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
@@ -1219,13 +1383,13 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 if (true) { // if (OUTBOX != folder && SENTBOX != folder && DRAFTBOX != folder)
                     IEmailPtr email = MessageFactory::convertToEmail(msg);
                     jsEvent->setMessage(msg);
+                    jsEvent->setConversation(conversation);
                     if(m_onMessageReceived.size() > 0)
-                       m_onMessageReceived.emit(jsEvent);
+                        m_onMessageReceived.emit(jsEvent);
                     if(m_onConversationReceived.size() > 0)
-                    m_onConversationReceived.emit(jsEvent);
+                        m_onConversationReceived.emit(jsEvent);
                 } else {
-                    LogWarning(
-                        "New email message in ignored folder: " << folder);
+                    LogWarning("New email message in ignored folder: " << folder);
                 }
             }
             else if (NOTI_MAILBOX_ADD == status) 
@@ -1239,10 +1403,10 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 Api::Messaging::IMessageFolderPtr folderPtr(new MessageFolder(m_mailboxes));
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
-               if(m_onFolderReceived.size() > 0)
-               {               
-                m_onFolderReceived.emit(jsEvent);
-               }
+                if(m_onFolderReceived.size() > 0)
+                {
+                    m_onFolderReceived.emit(jsEvent);
+                }
 
             }
             else if (NOTI_MAILBOX_UPDATE == status) 
@@ -1257,12 +1421,10 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
                                
-               if(m_onFolderReceived.size() > 0)
-               {               
-                m_onFolderReceived.emit(jsEvent);
-               }
-
-
+                if(m_onFolderReceived.size() > 0)
+                {
+                    m_onFolderReceived.emit(jsEvent);
+                }
             }
             else if (NOTI_MAILBOX_DELETE == status) 
             {
@@ -1276,17 +1438,18 @@ void Messaging::OnEventReceived(const DBus::MessageEvent& event)
                 jsEvent->setMessageFolder(folderPtr);
                 jsEvent->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
                                
-               if(m_onFolderReceived.size() > 0)
-               {               
-                m_onFolderReceived.emit(jsEvent);
-               }
-
+                if(m_onFolderReceived.size() > 0)
+                {
+                    m_onFolderReceived.emit(jsEvent);
+                }
             }
             else 
             {
                 LogError("Couldn't retrieve message or it has been malformed.");
             }
-        } else {
+        } 
+        else // DBUS_INTERFACE_EMAIL_RECEIVED
+        {
             LogDebug("Wrong DBus interface, skipping it.");
         }
     }
@@ -1300,122 +1463,130 @@ void Messaging::onMessageStorageChanged(MSG_HANDLE_T handle,
 
     LogDebug("ENTER");
 
-       MSG_ERROR_T err = MSG_SUCCESS;
-
-       msg_message_t msg = msg_new_message();
-       MSG_SENDINGOPT_S sendOpt = {0, };
-
-       err = msg_get_message(handle, *pMsgIdList->msgIdList, msg, &sendOpt);
-
-    LogDebug("err" << err);    
-       
+    MSG_ERROR_T err = MSG_SUCCESS;
 
-       if (err != MSG_SUCCESS)
-       {
-               LogDebug("Get Message Failed!");
-               msg_release_message(&msg);
-               return;
-       }
+    if(storageChangeType == MSG_STORAGE_CHANGE_CONTACT)
+    {
+        LogDebug("storageChangeType is MSG_STORAGE_CHANGE_CONTACT");   
+        return;
+    }
        
     Messaging* this_ = static_cast<Messaging*>(data);
-    if (this_) {
+    if (this_) 
+    {
         Try {
-                       int MsgType = msg_get_message_type(msg);
+            int msgCount = pMsgIdList->nCount;
+            LogDebug("msgCount = "<< msgCount);
 
-            if((MsgType > MSG_TYPE_INVALID) && ( MsgType <= MSG_TYPE_SMS_REJECT))
+            for(int index = 0; index < msgCount; index++)
             {
-                if(msg_get_message_type(msg) != MSG_TYPE_MMS_NOTI)
-                       {
-                    IMessagePtr message = MessageFactory::createMessage(
-                                          SMS,
-                                          msg_get_message_id(
-                                          msg));
-                    ISmsPtr sms = MessageFactory::convertToSms(message);
-                    IConversationPtr conversation(new Conversation(message->getId(), SMS));
-                    EventMessageReceivedPtr event(new EventMessageReceived());
-                    event->setMessage(message);
-                    event->setConversation(conversation);
-
-                    if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
-                    {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
-                    }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
-                    {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
-                    }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
-                    {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
-                    }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_CONTACT)
-                    {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);
-                    }
+                msg_message_t msg = msg_new_message();
+                MSG_SENDINGOPT_S sendOpt = {0, };
+                err = msg_get_message(handle, pMsgIdList->msgIdList[index], msg, &sendOpt);
 
-                    if(this_->m_onMessageReceived.size() > 0){
-                       this_->m_onMessageReceived.emit(event);
-                    }
-                    if(this_->m_onConversationReceived.size() > 0){
-                    this_->m_onConversationReceived.emit(event);
-                    }
+                LogDebug("err" << err);        
+       
+
+                if (err != MSG_SUCCESS)
+                {
+                    LogDebug("Get Message Failed!");
+                    msg_release_message(&msg);
+                    return;
                 }
-                       else
-                       {
-                               LogError("Ignore this sms, this is mms noti.");
-                       }
-            }
-            else if((MsgType >= MSG_TYPE_MMS) && (MsgType <= MSG_TYPE_MMS_NOTI))
-            {
-                if(msg_get_message_type(msg) != MSG_TYPE_MMS_NOTI)
-                       {
-                    IMessagePtr message = MessageFactory::createMessage(
-                                          MMS,
-                                          msg_get_message_id(
-                                          msg));
-                                       IMmsPtr mms = MessageFactory::convertToMms(message);
-                    IConversationPtr conversation(new Conversation(message->getId(), MMS));
-                                       EventMessageReceivedPtr event(new EventMessageReceived());
-                                       event->setMessage(message);
-                    event->setConversation(conversation);
-
-                    if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
+       
+                int MsgType = msg_get_message_type(msg);
+
+                if((MsgType > MSG_TYPE_INVALID) && ( MsgType <= MSG_TYPE_SMS_REJECT))
+                {
+                    if(msg_get_message_type(msg) != MSG_TYPE_MMS_NOTI)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+                        IMessagePtr message = MessageFactory::createMessage(
+                                                                            SMS,
+                                                                            msg_get_message_id(
+                                                                            msg));
+                        ISmsPtr sms = MessageFactory::convertToSms(message);
+                        IConversationPtr conversation(new Conversation(message->getId(), SMS));
+                        EventMessageReceivedPtr event(new EventMessageReceived());
+                        event->setMessage(message);
+                        event->setConversation(conversation);
+
+                        if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+                        }
+                        else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+                        }
+                        else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+                        }
+
+                        if(this_->m_onMessageReceived.size() > 0){
+                            this_->m_onMessageReceived.emit(event);
+                        }
+                        if(this_->m_onConversationReceived.size() > 0){
+                            this_->m_onConversationReceived.emit(event);
+                        }
                     }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
+                    else
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+                        LogError("Ignore this sms, this is mms noti.");
                     }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
+                }
+                else if((MsgType >= MSG_TYPE_MMS) && (MsgType <= MSG_TYPE_MMS_NOTI))
+                {
+                    if(msg_get_message_type(msg) != MSG_TYPE_MMS_NOTI)
                     {
-                        event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+                        IMessagePtr message = MessageFactory::createMessage(
+                                                                            MMS,
+                                                                            msg_get_message_id(
+                                                                            msg));
+                        IMmsPtr mms = MessageFactory::convertToMms(message);
+                        IConversationPtr conversation(new Conversation(message->getId(), MMS));
+                        EventMessageReceivedPtr event(new EventMessageReceived());
+                        event->setMessage(message);
+                        event->setConversation(conversation);
+
+                        if(storageChangeType == MSG_STORAGE_CHANGE_INSERT)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_ADDED);
+                        }
+                        else if(storageChangeType == MSG_STORAGE_CHANGE_UPDATE)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_UPDATED);
+                        }
+                        else if(storageChangeType == MSG_STORAGE_CHANGE_DELETE)
+                        {
+                            event->setMsg_Event_Type(EventMessageReceived::MSG_DELETED);
+                        }
+
+                        if(this_->m_onMessageReceived.size() > 0){
+                            this_->m_onMessageReceived.emit(event);
+                        }
+                        if(this_->m_onConversationReceived.size() > 0){
+                            this_->m_onConversationReceived.emit(event);
+                        }
                     }
-                    else if(storageChangeType == MSG_STORAGE_CHANGE_CONTACT)
+                    else
                     {
-                       event->setMsg_Event_Type(EventMessageReceived::MSG_MULTIPLE);
-                    }
-                    if(this_->m_onMessageReceived.size() > 0){
-                       this_->m_onMessageReceived.emit(event);
-                    }
-                    if(this_->m_onConversationReceived.size() > 0){
-                        this_->m_onConversationReceived.emit(event);
+                        LogError("Ignore this mms, this is mms noti.");
                     }
                 }
-                else
-                {
-                               LogError("Ignore this mms, this is mms noti.");
-               }
 
             }
         }
         Catch(WrtDeviceApis::Commons::ConversionException) {
             LogError("Couldn't convert message to sms.");
         }
+        Catch(WrtDeviceApis::Commons::PlatformException) {
+            LogError("onMessageStorageChanged platform exception");
+        }              
     }
 }
 
-
+/*
 void Messaging::onSmsReceived(MSG_HANDLE_T handle,
         msg_message_t msg,
         void* data)
@@ -1475,7 +1646,7 @@ void Messaging::onMmsReceived(MSG_HANDLE_T handle,
         }
     }
 }
-
+*/
 void Messaging::getNumberOfEmails(Api::Messaging::FolderType folder,
         int* read,
         int* unread)
@@ -1543,9 +1714,6 @@ void Messaging::getNumberOfSmsMms(Api::Messaging::FolderType folder,
         case OUTBOX:
             msgFolderId = MSG_OUTBOX_ID;
             break;
-        case SPAMBOX:
-            msgFolderId = MSG_SPAMBOX_ID;
-            break;
         case SENTBOX:
             msgFolderId = MSG_SENTBOX_ID;
             break;
@@ -2069,6 +2237,7 @@ std::vector<Api::Messaging::IConversationPtr> Messaging::queryConversations(cons
 
        std::vector<Api::Messaging::IConversationPtr> result;
        std::string filterSql;
+       std::string orderLimitSql ="";  
 
        ConversationQueryGeneratorPtr queryGenerator(new ConversationQueryGenerator(sortMode, limit, offset));
        IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
@@ -2093,13 +2262,89 @@ std::vector<Api::Messaging::IConversationPtr> Messaging::queryConversations(cons
                        IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
                        filter->travel(filterVisitor, 0);
                        filterSql = queryGenerator->getQuery();
-                       result = querySmsMmsConversation(filterSql);
+                       LogDebug("filterSql:[" << filterSql <<"]");
+                       LogDebug("orderLimitSql:[" << orderLimitSql <<"]");
+                       result = querySmsMmsConversation(filterSql, orderLimitSql);
                        break;
                }
 
                case Api::Messaging::MMS:{
                        LogDebug("type is MMS:[" << conversationType <<"]");
-                       result = querySmsMmsConversation(filterSql);
+                       queryGenerator->reset(MessageQueryGenerator::MODE_SMS_MMS);
+                       IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
+                       filter->travel(filterVisitor, 0);
+                       filterSql = queryGenerator->getQuery(); 
+                       LogDebug("filterSql:[" << filterSql <<"]");
+                       LogDebug("orderLimitSql:[" << orderLimitSql <<"]");
+                       result = querySmsMmsConversation(filterSql, orderLimitSql);
+                       break;
+               }
+
+               default:{
+                       LogError("[ERROR] >>> invlid type:[" << conversationType <<"]");
+                return result;
+               }
+       }       //switch
+
+       return result;
+}
+
+std::vector<Api::Messaging::IConversationPtr> Messaging::queryConversations(const Api::Tizen::FilterPtr& filter, 
+               const Api::Tizen::SortModePtr& sortMode, int type, long limit, long offset)
+{
+       LogDebug("Enter");
+
+       std::vector<Api::Messaging::IConversationPtr> result;
+       std::string filterSql;
+       std::string orderLimitSql ="";
+
+       ConversationQueryGeneratorPtr queryGenerator(new ConversationQueryGenerator(sortMode, limit, offset, type));
+       IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
+       filter->travel(filterVisitor, 0);
+
+       LogDebug("filterSql:[" << filterSql <<"]");
+       int conversationType = queryGenerator->getMessageType();
+       if(conversationType != -1)
+       {
+               if(conversationType != type)
+               {
+                       LogDebug("filter conversationType and service msg type is diff");               
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "invalid Fiilter Type");
+               }
+       }
+       switch(type){
+               case Api::Messaging::EMAIL:{
+                       LogDebug("type is EMAIL:[" << conversationType <<"]");
+                       queryGenerator->reset(MessageQueryGenerator::MODE_EMAIL);
+                       filter->travel(filterVisitor, 0);
+                       filterSql = queryGenerator->getQuery();
+                       result = queryEmailConversation(filterSql);
+                       break;
+               }
+
+               case Api::Messaging::SMS:{
+                       LogDebug("type is SMS:[" << conversationType <<"]");
+                       queryGenerator->reset(MessageQueryGenerator::MODE_SMS_MMS);
+                       IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
+                       filter->travel(filterVisitor, 0);
+                       filterSql = queryGenerator->getQuery();
+                       orderLimitSql = queryGenerator->getOrderLimit();
+                       LogDebug("filterSql:[" << filterSql <<"]");
+                       LogDebug("orderLimitSql:[" << orderLimitSql <<"]");                     
+                       result = querySmsMmsConversation(filterSql, orderLimitSql);
+                       break;
+               }
+
+               case Api::Messaging::MMS:{
+                       LogDebug("type is MMS:[" << conversationType <<"]");
+                       queryGenerator->reset(MessageQueryGenerator::MODE_SMS_MMS);
+                       IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<IFilterVisitor>(queryGenerator);
+                       filter->travel(filterVisitor, 0);
+                       filterSql = queryGenerator->getQuery();
+                       orderLimitSql = queryGenerator->getOrderLimit();        
+                       LogDebug("filterSql:[" << filterSql <<"]");
+                       LogDebug("orderLimitSql:[" << orderLimitSql <<"]");
+                       result = querySmsMmsConversation(filterSql, orderLimitSql);
                        break;
                }
 
index 1106dee..d3d8981 100755 (executable)
@@ -79,6 +79,8 @@ class Messaging : public Api::Messaging::IMessaging,
 
     virtual std::vector<Api::Messaging::IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter,
                const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
+    virtual std::vector<Api::Messaging::IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter,
+               const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset, const int type);
     virtual std::vector<Api::Messaging::IMessagePtr> findMessages(const Api::Tizen::FilterPtr& filter);
 
     virtual std::vector<std::string> getMessageIds(Api::Messaging::MessageType msgType,
@@ -123,6 +125,8 @@ class Messaging : public Api::Messaging::IMessaging,
 
     std::vector<Api::Messaging::IConversationPtr> queryConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter, long limit=0, long offset=0);
 
+    std::vector<Api::Messaging::IConversationPtr> queryConversations(const Api::Tizen::FilterPtr& filter, const Api::Tizen::SortModePtr& sortMode, int type, long limit=0, long offset=0);
+
     bool deleteConversations(const Api::Tizen::SortModePtr& sortMode, const Api::Tizen::FilterPtr& filter);
 
     bool deleteConversations(const std::vector<Api::Messaging::IConversationPtr>& conversations);
@@ -135,10 +139,11 @@ class Messaging : public Api::Messaging::IMessaging,
     std::string generateFilterSql(const Api::Tizen::FilterPtr& filter);
 
     std::vector<Api::Messaging::IConversationPtr> queryEmailConversation(const std::string& sqlWhereClause);
-    std::vector<Api::Messaging::IConversationPtr> querySmsMmsConversation(const std::string& sqlWhereClause);
+    std::vector<Api::Messaging::IConversationPtr> querySmsMmsConversation(const std::string& sqlWhereClause, const std::string& orderLimitString);
 
 //    std::vector<Api::Messaging::IMessagePtr> querySmsMmsMessages(const Api::Tizen::FilterPtr& filter, const Api::Tizen::SortModePtr& sortMode, const long limit, const long offset);
     std::vector<Api::Messaging::IMessagePtr> querySmsMmsMessages(const std::string& sqlWhereClause);
+    std::vector<Api::Messaging::IMessagePtr> querySmsMmsMessages(const std::string& sqlWhereClause, const std::string& orderLimitString);
     std::vector<Api::Messaging::IMessagePtr> queryEmailMessage(const std::string& sqlWhereClause);
 
     std::vector<Api::Messaging::IMessagePtr> createVectorFromeMessageList(const MSG_LIST_S& message_list);
@@ -164,14 +169,14 @@ class Messaging : public Api::Messaging::IMessaging,
             MSG_STORAGE_CHANGE_TYPE_T storageChangeType,
             MSG_MSGID_LIST_S *pMsgIdList,
             void* data);
-
+/*
     static void onSmsReceived(MSG_HANDLE_T handle,
             msg_message_t msg,
             void* data);
     static void onMmsReceived(MSG_HANDLE_T handle,
             msg_message_t msg,
             void* data);
-
+*/
   private:
 
     void getNumberOfEmails(Api::Messaging::FolderType folder,
index 2ad93b2..e71b250 100755 (executable)
 #include <API/Messaging/EmailAccountInfo.h>
 #include "MessagingService.h"
 #include "MailSync.h"
+#include "API/Messaging/EventMessagingService.h"
 
-#include <emf-types.h>
-#include <Emf_Mapi.h>
+#include <email-types.h>
+#include <email-api.h>
 
 using namespace DPL;
 using namespace std;
@@ -177,6 +178,20 @@ Api::Messaging::IMessagePtr MessagingService::getMessageFromOpId(int opIdx)
        return msg;
 }
 
+Api::Messaging::EventMessagingServicePtr MessagingService::getEventFromOpId(int opIdx)
+{
+       LogDebug("operation index : " << opIdx);
+       OpRequestsIterator it = m_opRequests.find(opIdx);
+       EventMessagingServicePtr event;
+       if ( m_opRequests.end() != it)
+       {
+               LogDebug("Find Event");
+               event = it->second.event;
+       }
+
+       return event;
+}
+
 void MessagingService::setHandleToOpId(int opIdx, int handle)
 {
        LogDebug("operation index : " << opIdx);
@@ -202,6 +217,22 @@ void MessagingService::setMessageToOpId(int opIdx, Api::Messaging::IMessagePtr&
        }
 }
 
+void MessagingService::setEventToOpId(int opIdx, Api::Messaging::EventMessagingServicePtr & event)
+{
+       LogDebug("operation index : " << opIdx);
+       OpRequestsIterator it = m_opRequests.find(opIdx);
+
+       if ( m_opRequests.end() != it)
+       {
+               LogDebug("set Message ");
+               if (event)
+               {
+                       LogDebug("vaild event ");
+                       it->second.event = event;
+               }
+       }
+}
+
 int MessagingService::getOpTypeFromOpId(int opIdx)
 {
     LogDebug("operation index : " << opIdx);
@@ -230,6 +261,55 @@ int MessagingService::deleteOpId(int opIdx)
        return opIdx;
 }
 
+void MessagingService::cancelOperation(int opId, int handle, int eventType, Api::Messaging::IMessagePtr& message)
+{
+       if (handle > 0)
+       {
+               if (eventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY
+                       || eventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
+               {
+                       Api::Messaging::IEmailPtr email = DPL::DynamicPointerCast<IEmail >(message);
+                       if (email) 
+                       {
+                               if ( eventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY )
+                               {       
+                                       LogDebug("Cancel Download Body , handle = " << handle);
+                                       email->downloadBodyCancel(handle);
+                               }
+                               else if ( eventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
+                               {
+                                       LogDebug("Cancel Download Attachment , handle = " << handle);
+                                       email->downloadAttachmentCancel(handle);
+                               }                               
+                       }
+                       else
+                       {
+                               ThrowMsg(  WrtDeviceApis::Commons::ConversionException, "Conversion IMessage to IEmail error");
+                       }
+
+               }
+               else if (eventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC)
+               {
+                       syncCancel(handle);
+               }
+               else if (eventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER)
+               {
+                       syncFolderCancel(handle);
+               }
+               else if (eventType == MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE)
+               {
+                       message->sendCancel(handle);
+                       deleteOpId(opId);
+               }
+               else
+               {
+
+               }
+                                               
+       }
+       
+}
+
 }
 }      //namespace Platform
 }      //namespace WrtPlugins
index b5aef35..e501f51 100755 (executable)
@@ -28,6 +28,8 @@
 #include <dpl/noncopyable.h>
 
 #include <API/Messaging/IMessagingService.h>
+#include <API/Messaging/EventMessagingService.h>
+
 //#include <Commons/Emitters.h>
 
 namespace TizenApis {
@@ -52,12 +54,17 @@ public:
        virtual int syncFolder(const Api::Messaging::IMessagingServicePtr& messagingService, const std::string& folder_name, const int limit);
        virtual void syncFolderCancel(int handle);
 
+       virtual void cancelOperation(int opId, int handle, int eventType, Api::Messaging::IMessagePtr& message);
+
        int createOpId(int type);
        int getHandleFromOpId(int opId);
        int getOpTypeFromOpId(int opId);
        Api::Messaging::IMessagePtr getMessageFromOpId(int opId);
+       Api::Messaging::EventMessagingServicePtr getEventFromOpId(int opId);
+       
        void setHandleToOpId(int opId, int handle);
        void setMessageToOpId(int opId, Api::Messaging::IMessagePtr& message);
+       void setEventToOpId(int opId, Api::Messaging::EventMessagingServicePtr& event);
        int deleteOpId(int opId);
 
 protected:
@@ -83,11 +90,13 @@ private:
                unsigned int handle;
                unsigned short type;
                Api::Messaging::IMessagePtr message;
+               Api::Messaging::EventMessagingServicePtr event;
 
                explicit MessagingServiceOpData(int handle, int type) :
                    handle(handle),
                    type(type),
-                   message(NULL)
+                   message(NULL),
+                   event(NULL)
                {
                }
        };
index 58f835f..5489516 100755 (executable)
@@ -26,8 +26,8 @@
 #include "MessagingService.h"
 
 //for email service
-#include <emf-types.h>
-#include <Emf_Mapi.h>
+#include <email-types.h>
+#include <email-api.h>
 
 using namespace std;
 using namespace DPL;
@@ -59,19 +59,20 @@ std::vector<Api::Messaging::EmailAccountInfo> MessagingServiceManager::getEmailA
                if (email_get_account_list(&accounts, &count)) {
                        if (0 < count)
                        {
-                               
+                               std::stringstream stream;
                                for (int i = 0; i < count; ++i) {
+                                       stream << "[" << accounts[i].account_name << "] " << accounts[i].user_name;
                                        LogDebug("account ID :" << accounts[i].account_id << "Name :" << accounts[i].user_name << "Addr :" << accounts[i].email_addr );
                                        Api::Messaging::EmailAccountInfo account(accounts[i].account_id,
-                                                                 accounts[i].user_name,
+                                                                 stream.str(),
                                                                  accounts[i].email_addr );
                                        result.push_back(account);
+                                       stream.str("");
                                }
 
                                if (accounts != NULL) {
                                    email_free_account(&accounts, count);
                                }
-
                        }
                }               
        }
@@ -157,7 +158,6 @@ void MessagingServiceManager::OnRequestReceived(const EventGetMessagingServicePt
                                                m_messagingServices.push_back(Api::Messaging::IMessagingServicePtr(messagingService));
                                        }
                                        
-                                       idx++;                                  
                                }
                                                                                        
                        }
index deadb8c..e05000e 100755 (executable)
@@ -39,6 +39,7 @@ extern "C" {
 #include <MapiStorage.h>
 }
 
+
 namespace {
 const char* TEXT_AREA = "Text";
 const char* TEXT_FILE_EXTENSION = ".txt";
@@ -191,9 +192,6 @@ void Mms::readFolder(msg_message_t& messageData)
     case MSG_DRAFT_ID:
         setFolderType(Api::Messaging::DRAFTBOX);
         break;
-    case MSG_SPAMBOX_ID:
-        setFolderType(Api::Messaging::SPAMBOX);
-        break;
     default:
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Unsupported folder id.");
     }
@@ -276,7 +274,7 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
 
     for (int p = 0; p < msgBody.pageCnt; ++p) {
         LogDebug("page " << p);
-        MMS_PAGE_S *page = msg_mms_get_page(p);
+        MMS_PAGE_S *page = msg_mms_get_page(&msgBody, p);
         if (!page) {
             LogError("returned page is null, continue");
             continue;
@@ -335,7 +333,7 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
 
     LogDebug("attachment count: " << msgBody.attachCnt);
     for (int a = 0; a < msgBody.attachCnt; ++a) {
-        MMS_ATTACH_S* attachment = msg_mms_get_attachment(a);
+        MMS_ATTACH_S* attachment = msg_mms_get_attachment(&msgBody, a);
         if (!attachment) {
             LogError("attachment is null, continue");
             continue;
@@ -673,6 +671,54 @@ void Mms::updateIsRead()
 
 }
 
+void Mms::updateMessage()
+{
+       LogDebug("updating m_id=" << getIdRef());
+       MSG_ERROR_T err = MSG_SUCCESS;
+       
+       if (!m_messageData) {
+               //error if platform message not exists
+               LogError("message can not be updated");
+               Throw(WrtDeviceApis::Commons::PlatformException);
+       }
+       
+       Try
+       {
+
+               msg_message_t msg = msg_new_message();
+               
+               MSG_SENDINGOPT_S sendOpt = {0};
+               
+               err = msg_get_message(MsgGetCommonHandle(), convertId(getIdRef()), msg, &sendOpt);
+               
+               if (err != MSG_SUCCESS)
+               {
+                       LogError("Get Message Failed!");
+                       msg_release_message(&msg);
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+               }
+       
+               if (this->getIdRef().empty()) {
+                       LogError("existing msgId is zero, update msg not done");
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                       "existing msgId is zero, update msg not done");
+               }
+               
+               update(TRUE);
+               
+               if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, &sendOpt))
+               {
+                       LogError("Failed to update message");
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+               }
+       }
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError("platform error occurs");
+       }
+}
+
+
+
 void Mms::addMessageToDraft()
 {
     LogDebug("convert m_id= " << convertId(getIdRef()));       
@@ -694,6 +740,7 @@ void Mms::addMessageToDraft()
 
     Try
     {
+        int msgId = -1;
         MSG_SENDINGOPT_S option = { false, false, false };
         option.option.smsSendOpt.bReplyPath = true;
         // trying to get message from platform
@@ -711,12 +758,55 @@ void Mms::addMessageToDraft()
             LogError("msg_add_message failed, error code=" << ret);
             Throw(WrtDeviceApis::Commons::PlatformException);
         }
+        else
+        {
+            msgId = ret;       
+        }
 
+#if 0
         //releasing platform message structure
-        //msg_release_message(&m_messageData);
+               MSG_LIST_S folder_list_view = { 0, NULL };
+               const MSG_SORT_RULE_S sort_rules = { MSG_SORT_BY_DISPLAY_TIME, true };
+
+               ret = msg_get_folder_view_list(MsgGetCommonHandle(), platfromFolderId, &sort_rules, &folder_list_view);
+               if (ret < MSG_SUCCESS) {
+                         LogError("msg_get_folder_view_list failed, error code=" << ret);
+                         Throw(WrtDeviceApis::Commons::PlatformException);
+                  }
+               
+               if ( MSG_TYPE_SMS == msg_get_message_type(folder_list_view.msgInfo[0]))
+               {
+                 msgId = msg_get_message_id(folder_list_view.msgInfo[0]);
+                 LogDebug("Message ID : " << msgId);
+               }
+               else
+               {
+                 LogError("invalid type , type = " << msg_get_message_type(folder_list_view.msgInfo[0]));
+                  if ( folder_list_view.nCount )
+                         msg_release_message_list(&folder_list_view);
+                 Throw(WrtDeviceApis::Commons::PlatformException);
+               }
+               
+               if (msgId < 0)
+               {
+                  if ( folder_list_view.nCount )
+                         msg_release_message_list(&folder_list_view);
+                 Throw(WrtDeviceApis::Commons::PlatformException);
+               }
+#endif
+        LogDebug("Message ID : " << msgId);
+        if (msgId < 0)
+        {
+            LogDebug("Message ID is invailded ");
+            Throw(WrtDeviceApis::Commons::PlatformException);
+        }
+         
+        msg_set_message_id(m_messageData, msgId);
 
+        setId(convertId(msgId));
         setFolderType(Api::Messaging::DRAFTBOX);
         setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
+       
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("remove message error");
@@ -887,10 +977,8 @@ int Mms::send()
         update();
 
         LogDebug("Start Sending Message...");
-        LogDebug("msgId=" << msg_get_message_id(m_messageData));
-        LogDebug("subject: " << msg_get_subject(m_messageData));
         LogDebug("recipient count: " << msg_get_address_count(m_messageData));
-          LogDebug("body size : " <<  msg_get_message_body_size( m_messageData ));
+       LogDebug("body size : " <<  msg_get_message_body_size( m_messageData ));
                
         for (int i = 0; i < msg_get_address_count(m_messageData); ++i) {
             LogDebug("recipient[" << i << "]: " <<
@@ -923,11 +1011,11 @@ ERROR:
         ReqReceiverMessage *requestReceiver = getRequestReceiver();
         if (requestReceiver) {
             LogError("send Error");
-            EventSendMessagePtr event = getSendMessageEvent();
+            EventMessagingServicePtr event = getMessagingServiceEvent();
             event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
-                requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventSendMessage >::ManualAnswer(event);
+             requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService>::ManualAnswer(event);
         }
-
+   return 0;
 }
 
 void Mms::sendingCallback(MSG_SENT_STATUS_S *sent_status)
@@ -960,7 +1048,7 @@ void Mms::setSendingStatusOk()
     ReqReceiverMessage *requestReceiver = getRequestReceiver();
     if (requestReceiver) {
         LogInfo("calling JS success callback");
-        EventSendMessagePtr event = getSendMessageEvent();
+         EventMessagingServicePtr event = getMessagingServiceEvent();
         event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
 
          for ( int index=0; index < msg_get_address_count(m_messageData); index++)
@@ -969,7 +1057,7 @@ void Mms::setSendingStatusOk()
                event->m_successRecipients.push_back(msg_get_ith_address(m_messageData, index));
          }
          
-       requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventSendMessage >::ManualAnswer(event);
+       requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService >::ManualAnswer(event);
        
     }
 }
index 9dccd89..6179b4a 100755 (executable)
@@ -93,6 +93,8 @@ class Mms : public Api::Messaging::IMms,
 
     void updateIsRead();       
 
+    void updateMessage();      
+
     void addMessageToDraft();
 
     void readPriority(msg_message_t& messageData);
index 8511ae1..664f019 100755 (executable)
@@ -23,8 +23,8 @@
 
 #include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
-#include <emf-types.h>
-#include <Emf_Mapi_Message.h>
+#include <email-types.h>
+#include <email-api-mail.h>
 
 namespace TizenApis {
 namespace Platform {
@@ -32,7 +32,7 @@ namespace Messaging {
 
 struct ScopedMailPolicy
 {
-    typedef emf_mail_t* Type;
+    typedef emf_mail_data_t* Type;
 
     static Type NullValue()
     {
@@ -44,8 +44,8 @@ struct ScopedMailPolicy
     {
           LogDebug("Destroy");
         if (NullValue() != mail) {
-                LogDebug("email_free_mail");
-            int error = email_free_mail(&mail, 1);
+                LogDebug("email_free_mail_data");
+            int error = email_free_mail_data(&mail, 1);
             if (EMF_ERROR_NONE != error) {
                 LogError("Failed to destroy mail: " << error);
             }
@@ -53,7 +53,7 @@ struct ScopedMailPolicy
     }
 };
 
-typedef DPL::ScopedPtr<emf_mail_t, ScopedMailPolicy> ScopedMail;
+typedef DPL::ScopedPtr<emf_mail_data_t, ScopedMailPolicy> ScopedMail;
 }
 }
 }
diff --git a/src/platform/Tizen/Messaging/ScopedMailAttachment.h b/src/platform/Tizen/Messaging/ScopedMailAttachment.h
new file mode 100755 (executable)
index 0000000..e80df54
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License. 
+*/
+
+/**
+ * @author          Zbigniew Kostrzewa (z.kostrzewa@samsung.com)
+ */
+
+#ifndef TIZEN_MESSAGING_SCOPEDMAILATTACHMENT_H_
+#define TIZEN_MESSAGING_SCOPEDMAILATTACHMENT_H_
+
+#include <dpl/log/log.h>
+#include <dpl/scoped_ptr.h>
+#include <email-types.h>
+#include <email-api-mail.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Messaging {
+
+struct ScopedMailAttachmentPolicy
+{
+    typedef emf_attachment_info_t* Type;
+
+    static Type NullValue()
+    {
+        LogDebug("NullValue");
+        return NULL;
+    }
+
+    static void Destroy(Type attachment)
+    {
+          LogDebug("Destroy");
+        if (NullValue() != attachment) {
+                LogDebug("email_free_attachment_info");
+            int error = email_free_attachment_info(&attachment);
+            if (EMF_ERROR_NONE != error) {
+                LogError("Failed to destroy mail Attachment: " << error);
+            }
+        }
+    }
+};
+
+typedef DPL::ScopedPtr<emf_attachment_info_t, ScopedMailAttachmentPolicy> ScopedMailAttachment;
+}
+}
+}
+#endif //TIZEN_MESSAGING_SCOPEDMAILATTACHMENT_H_
\ No newline at end of file
index 6900f06..6b3ecfe 100755 (executable)
@@ -23,8 +23,9 @@
 
 #include <dpl/log/log.h>
 #include <dpl/scoped_ptr.h>
-#include <emf-types.h>
-#include <Emf_Mapi_Message.h>
+#include <email-types.h>
+#include <email-api-mail.h>
+#include <email-api-mailbox.h>
 
 namespace TizenApis {
 namespace Platform {
index 42efa5c..813645e 100755 (executable)
@@ -178,16 +178,12 @@ void Sms::copyToFolder(const std::string& newFolder)
 int Sms::send()
 {
     LogDebug("sending message, id=" << getIdRef());
-
+       if(m_messageData == NULL)
+               
     //prepare for sending sms
     update();
 
     // split the message
-    LogDebug("Start Sending Message...");
-    LogDebug("msgId=" << msg_get_message_id(m_messageData));
-    LogDebug("subject: " << msg_get_subject(m_messageData));
-    LogDebug("recipient count: " << msg_get_address_count(m_messageData));
-
     SendRequest req;
 
     for (int i = 0; i < msg_get_address_count(m_messageData); ++i) {
@@ -278,8 +274,8 @@ void Sms::sendSubMessage()
     while (!m_sendRequests.empty()) {
         // send as long as the sending fails until there are no more messages
         for (MSG_ERROR_T err = MSG_ERR_UNKNOWN;
-             err != MSG_SUCCESS && !currentQueue().empty();
-             ) {
+             err != MSG_SUCCESS && !currentQueue().empty(); ) 
+       {
             err = CallbackMgrSingleton::Instance().registerAndSend(
                     msg_sms_send_message,
                     currentQueue().front(),
@@ -319,14 +315,25 @@ void Sms::setSendingStatusOk(const string &recipient)
     //success callback should be executed here
     ReqReceiverMessage *requestReceiver = getRequestReceiver();
     if (requestReceiver) {
+        EventMessagingServicePtr event = getMessagingServiceEvent();
+        event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
+        event->m_successRecipients.push_back(recipient);
+         if ( event->m_successRecipients.size() + event->m_failRecipients.size() == (unsigned int)msg_get_address_count(m_messageData))
+        {
+               requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService >::ManualAnswer(event);
+        }
+        
+#if 0
         EventSendMessagePtr event = getSendMessageEvent();
         event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::None);
         event->m_successRecipients.push_back(recipient);
          //LogDebug("total address size : " << msg_get_address_count(m_messageData) << " Status size : " << event->m_successRecipients.size() + event->m_failRecipients.size());
-        if ( event->m_successRecipients.size() + event->m_failRecipients.size() == msg_get_address_count(m_messageData))
+        if ( event->m_successRecipients.size() + event->m_failRecipients.size() == (unsigned int)msg_get_address_count(m_messageData))
         {
                requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventSendMessage >::ManualAnswer(event);
         }
+#endif
+               
     }
 }
 
@@ -343,14 +350,14 @@ void Sms::setSendingStatusFailed(const string &recipient)
         ReqReceiverMessage *requestReceiver = getRequestReceiver();
         if (requestReceiver) {
             LogError("calling JS error callback");
-            EventSendMessagePtr event = getSendMessageEvent();
+            EventMessagingServicePtr event = getMessagingServiceEvent();
             event->setExceptionCode(WrtDeviceApis::Commons::ExceptionCodes::UnknownException);
-            event->m_failRecipients.push_back(recipient);
-                //LogDebug("total address size : " << msg_get_address_count(m_messageData) << " Status size : " << event->m_successRecipients.size() + event->m_failRecipients.size());
-                if ( event->m_successRecipients.size() + event->m_failRecipients.size() == msg_get_address_count(m_messageData))
+               event->m_successRecipients.push_back(recipient);
+                if ( event->m_successRecipients.size() + event->m_failRecipients.size() == (unsigned int)msg_get_address_count(m_messageData))
                 {
-                       requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventSendMessage >::ManualAnswer(event);
+                  requestReceiver->WrtDeviceApis::Commons::EventRequestReceiver< EventMessagingService >::ManualAnswer(event);
                 }
+
         }
     }
 }
@@ -377,13 +384,17 @@ void Sms::remove()
 
 void Sms::createNewMessage()
 {
+    LogDebug("enter");
     if (m_messageData) {
         // release platform message if it was created previously
         msg_release_message(&m_messageData);
         m_messageData = NULL;
     }
     // create new platform message
+    LogDebug("create messeage instance");
     m_messageData = msg_new_message();
+    LogDebug("created message : " << m_messageData);
+       
     Try
     {
         MSG_SENDINGOPT_S option = { false, false, false };
@@ -464,12 +475,18 @@ void Sms::updateBody()
     LogInfo("updating platfoprm body");
 
     // change body value in platform structure
-    msg_sms_set_message_body(m_messageData, getBodyRef().c_str(),
-                             getBodyRef().length());
-
+    if (  getBodyRef().length() >  0)
+    {
+    if (msg_sms_set_message_body(m_messageData, getBodyRef().c_str(),
+                             getBodyRef().length()) != MSG_SUCCESS) {
+        LogError("problem with update Body");
+        Throw(WrtDeviceApis::Commons::PlatformException);
+       }
     // set flag as true - platform synchronized with abstraction
     setBodyValidity(true);
 }
+    // set flag as true - platform synchronized with abstraction
+}
 
 void Sms::updateTo()
 {
@@ -592,6 +609,53 @@ void Sms::updateIsRead()
        
 }
 
+void Sms::updateMessage()
+{
+       LogDebug("updating m_id=" << getIdRef());
+       MSG_ERROR_T err = MSG_SUCCESS;
+       
+       if (!m_messageData) {
+               //error if platform message not exists
+               LogError("message can not be updated");
+               Throw(WrtDeviceApis::Commons::PlatformException);
+       }
+       
+       Try
+       {
+
+               msg_message_t msg = msg_new_message();
+               
+               MSG_SENDINGOPT_S sendOpt = {0};
+               
+               err = msg_get_message(MsgGetCommonHandle(), convertId(getIdRef()), msg, &sendOpt);
+               
+               if (err != MSG_SUCCESS)
+               {
+                       LogError("Get Message Failed!");
+                       msg_release_message(&msg);
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+               }
+       
+               if (this->getIdRef().empty()) {
+                       LogError("existing msgId is zero, update msg not done");
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException,
+                                       "existing msgId is zero, update msg not done");
+               }
+               
+               update(TRUE);
+               
+               if (MSG_SUCCESS != msg_update_message(MsgGetCommonHandle(), m_messageData, &sendOpt))
+               {
+                       LogError("Failed to update message");
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Failed to update message");
+               }
+       }
+       Catch(WrtDeviceApis::Commons::PlatformException) {
+               LogError("platform error occurs");
+       }
+}
+
+
 
 void Sms::addMessageToDraft()
 {
@@ -606,6 +670,7 @@ void Sms::addMessageToDraft()
 
     //update all sms data
     if (getCurrentFolder() == Api::Messaging::DRAFTBOX) {
+        LogDebug("update all sms data");
         updateBody();
         updateFrom();
         updateTo();
@@ -614,12 +679,12 @@ void Sms::addMessageToDraft()
 
     Try
     {
+        int msgId = -1;
         MSG_SENDINGOPT_S option = { false, false, false };
         option.option.smsSendOpt.bReplyPath = true;
         // trying to get message from platform
 
-        const MSG_FOLDER_ID_T platfromFolderId =
-        Messaging::convertFolderToPlatform(DRAFTBOX);
+        const MSG_FOLDER_ID_T platfromFolderId = Messaging::convertFolderToPlatform(DRAFTBOX);
 
         msg_set_message_id(m_messageData, 0);          
         msg_set_folder_id(m_messageData, platfromFolderId);
@@ -631,12 +696,60 @@ void Sms::addMessageToDraft()
             LogError("msg_add_message failed, error code=" << ret);
             Throw(WrtDeviceApis::Commons::PlatformException);
         }
-
-        //releasing platform message structure
-        //msg_release_message(&m_messageData);
+       else
+       {
+               msgId = ret;    
+       }
+                       
+#if 0
+         MSG_LIST_S folder_list_view = { 0, NULL };
+         const MSG_SORT_RULE_S sort_rules = { MSG_SORT_BY_DISPLAY_TIME, true };
                
+         ret = msg_get_folder_view_list(MsgGetCommonHandle(), platfromFolderId, &sort_rules, &folder_list_view);
+         if (ret < MSG_SUCCESS) {
+            LogError("msg_get_folder_view_list failed, error code=" << ret);
+            Throw(WrtDeviceApis::Commons::PlatformException);
+         }
+
+         if ( MSG_TYPE_SMS == msg_get_message_type(folder_list_view.msgInfo[0]))
+         {
+               msgId = msg_get_message_id(folder_list_view.msgInfo[0]);
+               LogDebug("Message ID : " << msgId);
+         }
+         else
+         {
+               LogError("invalid type , type = " << msg_get_message_type(folder_list_view.msgInfo[0]));
+                if ( folder_list_view.nCount )
+                       msg_release_message_list(&folder_list_view);
+               Throw(WrtDeviceApis::Commons::PlatformException);
+         }
+
+         if (msgId < 0)
+         {
+                if ( folder_list_view.nCount )
+                       msg_release_message_list(&folder_list_view);
+               Throw(WrtDeviceApis::Commons::PlatformException);
+         }
+#endif
+         
+         LogDebug("Message ID : " << msgId);
+         if (msgId < 0)
+         {
+                LogDebug("Message ID is invailded ");
+                Throw(WrtDeviceApis::Commons::PlatformException);
+         }
+         
+         msg_set_message_id(m_messageData, msgId);
+
+         setId(convertId(msgId));
         setFolderType(Api::Messaging::DRAFTBOX);
         setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
+         LogDebug("Message Status " <<  getMessageStatus());
+
+#if 0
+         if ( folder_list_view.nCount )
+               msg_release_message_list(&folder_list_view);
+#endif   
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("remove message error");
@@ -649,7 +762,6 @@ void Sms::addMessageToDraft()
 
 }
 
-
 void Sms::readRecipientList(msg_message_t& messageData)
 {
     LogDebug("Adding recipients to message, count=" <<
@@ -693,9 +805,6 @@ void Sms::readFolder(msg_message_t& messageData)
     case MSG_DRAFT_ID:
         setFolderType(Api::Messaging::DRAFTBOX);
         break;
-    case MSG_SPAMBOX_ID:
-        setFolderType(Api::Messaging::SPAMBOX);
-        break;
     default:
         LogError("Wrong folder id");
         ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Unsupported folder id.");
index 4ef1ded..49718e0 100755 (executable)
@@ -98,6 +98,8 @@ class Sms : public Api::Messaging::ISms,
 
     void updateIsRead();
 
+    void updateMessage();
+       
     void addMessageToDraft();
 
     void readRecipientList(msg_message_t& messageData);
index 4e2e461..aa45fa8 100755 (executable)
@@ -163,7 +163,7 @@ MSG_ERROR_T MessageStorageReader::MsgStoDisconnectDB(){
        return MSG_SUCCESS;
 }
 
-int MessageStorageReader::queryMessage(const std::string& whereClause, /*out*/MSG_LIST_S *pMsgFolderViewList){
+int MessageStorageReader::queryMessage(const std::string& whereClause, const std::string& orderLimit, /*out*/MSG_LIST_S *pMsgFolderViewList){
        LogDebug("<<< whereClause:[" << whereClause << "]");
 
        if (pMsgFolderViewList == NULL){
@@ -193,6 +193,15 @@ int MessageStorageReader::queryMessage(const std::string& whereClause, /*out*/MS
 
        tmpWhereClause.append("(A.ADDRESS_ID = B.ADDRESS_ID)");
 
+       if(orderLimit.length() == 0)
+       {
+               LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
+       }
+       else
+       {
+               tmpWhereClause.append(orderLimit);
+               LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
+       }
        LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
 
        oStream << "SELECT A.MSG_ID, A.ADDRESS_ID, A.FOLDER_ID, A.REFERENCE_ID, A.STORAGE_ID, A.MAIN_TYPE, A.SUB_TYPE, \
@@ -311,7 +320,7 @@ FROM " << MSGFW_MESSAGE_TABLE_NAME << " A, " << MSGFW_ADDRESS_TABLE_NAME << " B
        return MSG_SUCCESS;
 }
 
-int MessageStorageReader::queryConversation(const std::string& whereClause,
+int MessageStorageReader::queryConversation(const std::string& whereClause, const std::string& orderLimit,
                /*out*/MSG_THREAD_VIEW_LIST_S *pThreadViewList){
 
        pThreadViewList->nCount = 0;
@@ -330,9 +339,19 @@ int MessageStorageReader::queryConversation(const std::string& whereClause,
                tmpWhereClause.append(whereClause);
        }
 
-       oStream << "SELECT ADDRESS_ID, CONTACT_ID, ADDRESS_VAL, DISPLAY_NAME, FIRST_NAME,\
-                       LAST_NAME, IMAGE_PATH, UNREAD_CNT, SMS_CNT, MMS_CNT, MAIN_TYPE, SUB_TYPE, \
-                       MSG_DIRECTION, MSG_TIME, MSG_TEXT FROM " << MSGFW_ADDRESS_TABLE_NAME << " ";
+       if(orderLimit.length() == 0)
+       {
+               LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
+       }
+       else
+       {
+               tmpWhereClause.append(orderLimit);
+               LogDebug("<<< tmpWhereClause:[" << tmpWhereClause << "]");
+       }
+
+       oStream << "SELECT ADDRESS_ID, CONTACT_ID, ADDRESS_VAL, DISPLAY_NAME, FIRST_NAME, \
+LAST_NAME, IMAGE_PATH, UNREAD_CNT, SMS_CNT, MMS_CNT, MAIN_TYPE, SUB_TYPE, \
+MSG_DIRECTION, MSG_TIME, MSG_TEXT FROM " << MSGFW_ADDRESS_TABLE_NAME << " ";
 
        oStream << tmpWhereClause;
        stringSqlQuery = oStream.str();
index 06cd36f..b9f7cc4 100755 (executable)
@@ -43,8 +43,8 @@ class MessageStorageReader {
                MSG_ERROR_T MsgStoDisconnectDB();
 
        public:
-               int queryMessage(const std::string& whereClause, /*out*/MSG_LIST_S *pMsgFolderViewList);
-               int queryConversation(const std::string& whereClause, /*out*/MSG_THREAD_VIEW_LIST_S *pThreadViewList);
+               int queryMessage(const std::string& whereClause, const std::string& orderLimit, /*out*/MSG_LIST_S *pMsgFolderViewList);
+               int queryConversation(const std::string& whereClause, const std::string& orderLimit, /*out*/MSG_THREAD_VIEW_LIST_S *pThreadViewList);
 };
 
 #endif /* MessageStorageReader_H_ */
diff --git a/src/platform/Tizen/NFC/NFCAdapter.cpp b/src/platform/Tizen/NFC/NFCAdapter.cpp
new file mode 100755 (executable)
index 0000000..0be5bdd
--- /dev/null
@@ -0,0 +1,416 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dpl/log/log.h>
+#include <dpl/scoped_ptr.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <nfc.h>
+#include "NFCAdapter.h"
+#include "NFCUtil.h"
+
+using namespace TizenApis::Api::NFC;
+using namespace DPL;
+namespace TizenApis {
+namespace Platform {
+namespace NFC {
+static NFCAdapter *NFCAdapterPtr;
+namespace
+{
+       static void TagDetectedCallback(nfc_discovered_type_e type, nfc_tag_h tag, void *data) {
+               LogDebug("Callback TagDetectedCallback.");
+
+               if (data) {
+                       if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
+                               (static_cast<NFCAdapter*>(data))->updateCurrentHandle((void *)tag);
+                               (static_cast<NFCAdapter*>(data))->NFCHasDetected((void *)tag, NFC_TAG_TYPE);
+                       } else {
+                               (static_cast<NFCAdapter*>(data))->updateCurrentHandle(NULL);
+                               (static_cast<NFCAdapter*>(data))->NFCHasDetected(NULL, NFC_TAG_TYPE);
+                       }
+               } else {
+                       LogError("Callback private data is NULL.");
+               }
+
+       }
+
+       static void TargetDetectedCallback(nfc_discovered_type_e type, nfc_p2p_target_h target, void *data) {
+               LogDebug("Callback TargetDetectedCallback.");
+
+               if (data) {
+                       if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
+                               (static_cast<NFCAdapter*>(data))->updateCurrentHandle((void *)target);
+                               (static_cast<NFCAdapter*>(data))->NFCHasDetected((void *)target, NFC_TARGET_TYPE);
+                       } else {
+                               (static_cast<NFCAdapter*>(data))->updateCurrentHandle(NULL);
+                               (static_cast<NFCAdapter*>(data))->NFCHasDetected(NULL, NFC_TARGET_TYPE);
+                       }
+               } else {
+                       LogError("Callback private data is NULL.");
+               }
+
+       }
+       static void NFCInitializeCompletedCallback(nfc_error_e result, void *user_data) {
+               LogDebug("Callback NFCInitializeCompletedCallback. result : " << (int)result);
+               if (/*user_data &&*/ (result == NFC_ERROR_NONE))
+                       NFCAdapterPtr/*(static_cast<NFCAdapter*>(user_data))*/->getCurrentNFC();
+       }
+       static void NFCSetActivationCompletedCallback(nfc_error_e error, void *user_data) {
+               LogDebug("Callback NFCSetActivationCompletedCallback.");
+               NFCAdapterPtr->setPoweredManualAnswer(error);
+       }
+}//private namespace
+
+NFCAdapter::NFCAdapter()
+       :m_initialized(false) {
+       LogDebug("Platform::NFC Enter");
+       curHandle = NULL;
+       m_managerPriv = NULL;
+
+       m_NFCTagEmitterPtr.Reset();
+       m_NFCTargetEmitterPtr.Reset();
+       m_EventNFCChangedSetPoweredPtr.Reset();
+
+       m_tagFilter.Reset();
+       NFCAdapterPtr = this;
+}
+
+NFCAdapter::~NFCAdapter() {
+       LogDebug("Enter");
+       deinitialze();
+}
+
+void NFCAdapter::deinitialze() {
+       LogDebug("Enter");
+       int result = -1;
+
+       m_NFCTagEmitterPtr.Reset();
+       m_NFCTargetEmitterPtr.Reset();
+       m_EventNFCChangedSetPoweredPtr.Reset();
+
+       m_tagFilter.Reset();
+
+       nfc_manager_unset_tag_discovered_cb();
+       nfc_manager_unset_p2p_target_discovered_cb();
+
+       m_managerPriv = NULL;
+
+       if(m_initialized == true)
+       {
+               result = nfc_manager_deinitialize ();
+               if (result !=NFC_ERROR_NONE) {
+                       LogInfo("failed to deinitialize nfc");
+               }
+       }
+       m_initialized = false;
+
+       LogDebug("destroy nfc");
+}
+
+int NFCAdapter::setTagListener(const EventNFCChangedEmitterPtr& emitter,
+               TagFilterPtr pFilter, void *managerPriv) {
+       LogDebug(" NFCAdapter::setTagListener Entered");
+       int result = -1;
+       if (m_NFCTagEmitterPtr.Get() != NULL)
+               ThrowMsg(PlatformException, "It has already set Tag Listener");
+
+       m_NFCTagEmitterPtr = emitter;
+       m_managerPriv = managerPriv;
+
+       LogDebug(" NFCAdapter::setTagListener set discovered callback, filter size == " << pFilter->getFilterSize());
+
+       m_tagFilter = pFilter;
+
+       if (!m_initialized) {
+               if (initialize() != NFC_ERROR_NONE) {
+                       m_NFCTagEmitterPtr.Reset();
+                       ThrowMsg(PlatformException, "Could not initialize NFC.");
+               }
+       } else
+               getCurrentNFC();
+
+       if (pFilter->getFilterSize() > 0) {
+               int filter = NFC_TAG_FILTER_ALL_DISABLE;
+               for (int cnt = 0; cnt < pFilter->getFilterSize() ; cnt++) {
+                       LogDebug(" NFCAdapter::setTagListener filter == " << pFilter->getFilterValue(cnt));
+                       if ((pFilter->getFilterValue(cnt) >= NFC_TAGTYPE_ISO14443_A_PICC) && (pFilter->getFilterValue(cnt) <= NFC_TAGTYPE_MIFARE_DESFIRE_PICC))
+                               filter = filter |NFC_TAG_FILTER_ISO14443A_ENABLE;
+                       else if ((pFilter->getFilterValue(cnt) >= NFC_TAGTYPE_ISO14443_B_PICC) && (pFilter->getFilterValue(cnt) <= NFC_TAGTYPE_ISO14443_BPRIME_PICC))
+                               filter = filter |NFC_TAG_FILTER_ISO14443B_ENABLE;
+                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_FELICA_PICC)
+                               filter = filter |NFC_TAG_FILTER_FELICA_ENABLE ;
+                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_JEWEL_PICC)
+                               filter = filter |NFC_TAG_FILTER_JEWEL_ENABLE  ;
+                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_ISO15693_PICC)
+                               filter = filter |NFC_TAG_FILTER_ISO15693_ENABLE ;
+                       else if ((pFilter->getFilterValue(cnt) == NFC_TAGTYPE_GENERIC_PICC) || (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_UNKNOWN_TARGET)) {
+                               filter = NFC_TAG_FILTER_ALL_ENABLE;
+                               break;
+                       }
+               }
+               nfc_manager_set_tag_filter(filter);
+       } else {
+               nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
+       }
+
+       result = nfc_manager_set_tag_discovered_cb (TagDetectedCallback, this);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE) {
+               m_NFCTagEmitterPtr.Reset();
+               Util.throwNFCException(result, "failed to set callback of nfc_manager_set_ndef_discovered_cb");
+       }
+
+       LogInfo("NFCAdapter::setTagListener : result << " << result);
+       return result;
+}
+
+int NFCAdapter::setPeerListener(const EventNFCChangedEmitterPtr& emitter, void *managerPriv) {
+       LogDebug(" NFCAdapter::setPeerListener Entered");
+       int result = -1;
+
+       if (m_NFCTargetEmitterPtr.Get() != NULL)
+               ThrowMsg(PlatformException, "It has already set Peer Listener");
+
+       m_NFCTargetEmitterPtr = emitter;
+       m_managerPriv = managerPriv;
+
+       if (!m_initialized) {
+               if (initialize() != NFC_ERROR_NONE) {
+                       m_NFCTargetEmitterPtr.Reset();
+                       ThrowMsg(PlatformException, "Could not initialize NFC.");
+               }
+       } else
+               getCurrentNFC();
+
+       result = nfc_manager_set_p2p_target_discovered_cb (TargetDetectedCallback, this);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE) {
+               m_NFCTargetEmitterPtr.Reset();
+               Util.throwNFCException(result, "failed to set callback of nfc_manager_set_p2p_target_discovered_cb");
+       }
+
+       LogInfo("NFCAdapter::setPeerListener : result << " << result);
+       return result;
+}
+void NFCAdapter::unsetTagListener() {
+       LogDebug(" NFCAdapter::unsetTagListener Entered");
+
+       if (!m_initialized) {
+               if (initialize() != NFC_ERROR_NONE) {
+                       ThrowMsg(PlatformException, "Could not initialize NFC.");
+               }
+       }
+
+       nfc_manager_unset_tag_discovered_cb ();
+       nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
+       m_NFCTagEmitterPtr.Reset();
+       }
+
+void NFCAdapter::unsetPeerListener() {
+       LogDebug(" NFCAdapter::unsetPeerListener Entered");
+
+       if (!m_initialized) {
+               if (initialize() != NFC_ERROR_NONE) {
+                       ThrowMsg(PlatformException, "Could not initialize NFC.");
+               }
+       }
+
+       nfc_manager_unset_p2p_target_discovered_cb();
+       m_NFCTargetEmitterPtr.Reset();
+}
+
+void NFCAdapter::NFCHasDetected(void *props, EventNFCType type)
+{
+       LogDebug("NFCAdapter::NFCHasDetected Enter type : " << type);
+       if (((m_NFCTagEmitterPtr.Get() != NULL) && (type == NFC_TAG_TYPE)) ||
+               ((m_NFCTargetEmitterPtr.Get() != NULL) && (type == NFC_TARGET_TYPE))){
+               if ((props != NULL) && (type == NFC_TAG_TYPE)) {
+
+                       nfc_tag_type_e tagType;
+
+                       if (nfc_tag_get_type((nfc_tag_h)props, &tagType) == NFC_ERROR_NONE) {
+                               LogDebug("NFCAdapter::NFCHasDetected Tag real type : " << tagType);
+                               int cnt;
+                               for (cnt = 0; cnt < m_tagFilter->getFilterSize() ; cnt++) {
+                                       NFCUtil Util;
+                                       if (Util.convertTonfcTagType(static_cast<unsigned short>(tagType)) == m_tagFilter->getFilterValue(cnt))
+                                               break;
+                               }
+                               if ((m_tagFilter->getFilterSize() > 0) && (cnt == m_tagFilter->getFilterSize())) {
+                                       LogDebug("Filter doesn't have this tag type ");
+                                       return;
+                               }
+                       } else {
+                               LogDebug("It can't get real nfc tag type");
+                               int cnt;
+                               for (cnt = 0; cnt < m_tagFilter->getFilterSize() ; cnt++) {
+                                       if (NFC_TAGTYPE_GENERIC_PICC == m_tagFilter->getFilterValue(cnt))
+                                               break;
+                               }
+
+                               if (cnt == m_tagFilter->getFilterSize()) {
+                                       LogDebug("Filter doesn't have this tag type ");
+                                       return;
+                               }
+
+                       }
+               }
+
+               EventNFCChangedPtr event( new EventNFCChanged() );
+               LogDebug("nfc type was detected");
+               if (props == NULL)
+                       event->setNFCStatus(NFC_DETATCHED);
+               else
+                       event->setNFCStatus(NFC_ATTATCHED);
+               event->setNFCProperties(props);
+               event->setNFCType(type);
+               event->setPrivateNFCAdapterPtr(m_managerPriv);
+               LogDebug("emit event with nfc tag info");
+               if (type == NFC_TARGET_TYPE)
+                       m_NFCTargetEmitterPtr->emit(event);
+               else
+                       m_NFCTagEmitterPtr->emit(event);
+       } else {
+               LogDebug("m_NFCTagEmitterPtr.Get() != NULL ? " << (m_NFCTagEmitterPtr.Get() != NULL));
+       }
+
+
+}
+void NFCAdapter::getCurrentNFC() {
+       LogDebug("Enter");
+
+       if (m_NFCTagEmitterPtr.Get() != NULL) {
+               nfc_tag_h currentTag;
+               if (nfc_manager_get_connected_tag(&currentTag) == NFC_ERROR_NONE) {
+                       updateCurrentHandle((void *)currentTag);
+                       if (m_NFCTagEmitterPtr.Get() != NULL) {
+                               NFCHasDetected((void *)currentTag, NFC_TAG_TYPE);
+                       }
+               }
+       }
+
+       if (m_NFCTargetEmitterPtr.Get() != NULL) {
+               nfc_p2p_target_h currentTarget;
+               if (nfc_manager_get_connected_target(&currentTarget) == NFC_ERROR_NONE) {
+                       updateCurrentHandle((void *)currentTarget);
+                       NFCHasDetected(currentTarget, NFC_TARGET_TYPE);
+               }
+       }
+}
+
+int NFCAdapter::initialize() {
+       LogDebug("NFCAdapter::initialize Entered");
+       int result = -1;
+       nfc_manager_deinitialize();
+       result = nfc_manager_initialize(NFCInitializeCompletedCallback, this);
+       if (result != NFC_ERROR_NONE) {
+               LogError("Could not initialize NFC.");
+               m_initialized = false;
+       } else
+               m_initialized = true;
+       return result;
+}
+
+void *NFCAdapter::getCachedMessage() {
+       LogDebug("Entered");
+       nfc_ndef_message_h messageHandle;
+       int result = nfc_manager_get_cached_message(&messageHandle);
+       if (result == NFC_ERROR_INVALID_NDEF_MESSAGE)
+               return NULL;
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get cached message");
+
+       return (void *)(messageHandle);
+}
+
+bool NFCAdapter::isValidHandle(void * handle) {
+       LogDebug("Entered");
+       if ((handle != NULL) && (handle == curHandle))
+               return TRUE;
+
+       return FALSE;
+}
+
+void NFCAdapter::updateCurrentHandle(void *handle) {
+       LogDebug("Updated!");
+       curHandle = handle;
+}
+
+bool NFCAdapter::getPowerState() {
+       return nfc_manager_is_activated();
+}
+
+void NFCAdapter::setPowered(const EventNFCChangedSetPoweredPtr& event) {
+       LogDebug("Enter");
+       EventRequestReceiver<EventNFCChangedSetPowered>::PostRequest(event);
+}
+
+void NFCAdapter::OnRequestReceived(const EventNFCChangedSetPoweredPtr& event) {
+       LogDebug("Enter");
+       try {
+               NFCUtil Util;
+               if (m_EventNFCChangedSetPoweredPtr.Get() != NULL) {
+                       event->setResult(false);
+                       event->setError(Commons::JSTizenException::SERVICE_NOT_AVAILABLE);
+                       event->setErrorMessage("Progressing Identical Operation");
+                       return;
+               } else if (getPowerState() == event->getState()) {
+                       event->setResult(true);
+                       return;
+               }
+               event->switchToManualAnswer();
+
+               m_EventNFCChangedSetPoweredPtr = event;
+               int result = nfc_manager_set_activation(event->getState(), NFCSetActivationCompletedCallback, NULL);
+
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       m_EventNFCChangedSetPoweredPtr.Reset();
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventNFCChangedSetPowered>::ManualAnswer(event);
+               }
+       } catch (const WrtDeviceApis::Commons::Exception& ex) {
+               LogError("Exception: " << ex.GetMessage());
+               event->setResult(false);
+               m_EventNFCChangedSetPoweredPtr.Reset();
+               EventRequestReceiver<EventNFCChangedSetPowered>::ManualAnswer(event);
+       }
+}
+
+void NFCAdapter::setPoweredManualAnswer(int error) {
+       if (m_EventNFCChangedSetPoweredPtr.Get() != NULL) {
+               if (error == NFC_ERROR_NONE) {
+                       m_EventNFCChangedSetPoweredPtr->setResult(true);
+               } else {
+                       NFCUtil Util;
+                       m_EventNFCChangedSetPoweredPtr->setResult(false);
+                       m_EventNFCChangedSetPoweredPtr->setError(Util.getNFCErrorString(error));
+                       m_EventNFCChangedSetPoweredPtr->setErrorMessage(Util.getNFCErrorMessage(error));
+               }
+               EventRequestReceiver<EventNFCChangedSetPowered>::ManualAnswer(m_EventNFCChangedSetPoweredPtr);
+               m_EventNFCChangedSetPoweredPtr.Reset();
+       }
+}
+
+}
+}
+}
similarity index 67%
rename from src/platform/Tizen/NFC/NFCManager.h
rename to src/platform/Tizen/NFC/NFCAdapter.h
index 4055762..37f17ee 100755 (executable)
 
 
 
-#ifndef _MFCMANAGER_H_
-#define _MFCMANAGER_H_
+#ifndef _NFCADAPTER_H_
+#define _NFCADAPTER_H_
 
 #include <dpl/shared_ptr.h>
 #include <Commons/Emitters.h>
 
-#include <API/NFC/INFCManager.h>
+#include <API/NFC/INFCAdapter.h>
 #include <API/NFC/NFCFactory.h>
 #include <API/NFC/EventNFCChanged.h>
 #include <API/NFC/TagFilter.h>
@@ -32,12 +32,12 @@ using namespace TizenApis::Api::NFC;
 namespace TizenApis {
 namespace Platform {
 namespace NFC {
-class NFCManager : public INFCManager
+class NFCAdapter : public INFCAdapter
 {
        friend class  NFCFactory;
     public:
-               NFCManager();
-       virtual  ~NFCManager();
+               NFCAdapter();
+       virtual  ~NFCAdapter();
 
 public:
      /**
@@ -45,42 +45,41 @@ public:
      */
        virtual int setTagListener(const EventNFCChangedEmitterPtr& emitter, TagFilterPtr filter, void *managerPriv);
        virtual int setPeerListener(const EventNFCChangedEmitterPtr& emitter, void *managerPriv);
-       virtual int setNDEFListener(const EventNFCChangedNdefEmitterPtr& emitter);
-       virtual int setSEEventListener(const EventNFCChangedSeEventEmitterPtr& emitter);
-
        /**
      * clearWatch
      */
        virtual void unsetTagListener();
        virtual void unsetPeerListener();
-       virtual void unsetNDEFListener();
-       virtual void unsetSEEventListener();
 
-       virtual void NFCHasDetected(void *props, EventNFCType type);
-       virtual void NDEFHasDetected(std::vector<unsigned char> data);
-       virtual void SeEventHasDetected(nfcSeEventType event);
+       void NFCHasDetected(void *props, EventNFCType type);
 
        virtual void *getCachedMessage();
        virtual bool isValidHandle(void * handle);
-       virtual void updateCurrentHandle(void *handle);
+       void updateCurrentHandle(void *handle);
+       void getCurrentNFC();
+
+       virtual bool getPowerState();
+       virtual void setPowered(const EventNFCChangedSetPoweredPtr& event);
+       void setPoweredManualAnswer(int error);
 
+       virtual void deinitialze();
 private:
        /**
      * Initialize NFC.
      */
-       void initialize();
+       int initialize();
 
        EventNFCChangedEmitterPtr m_NFCTagEmitterPtr;
        EventNFCChangedEmitterPtr m_NFCTargetEmitterPtr;
-       EventNFCChangedNdefEmitterPtr m_NdefEmitterPtr;
-       EventNFCChangedSeEventEmitterPtr m_SeEventEmitterPtr;
+       EventNFCChangedSetPoweredPtr m_EventNFCChangedSetPoweredPtr;
        TagFilterPtr m_tagFilter;
        void *m_managerPriv;
-
        bool m_initialized;
+  protected:
+       virtual void OnRequestReceived(const EventNFCChangedSetPoweredPtr& event);
 };
 }
 }
 }
 
-#endif /* _MFCMANAGER_H_ */
+#endif /* _NFCADAPTER_H_ */
diff --git a/src/platform/Tizen/NFC/NFCManager.cpp b/src/platform/Tizen/NFC/NFCManager.cpp
deleted file mode 100755 (executable)
index dd13eee..0000000
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <dpl/log/log.h>
-#include <dpl/scoped_ptr.h>
-#include <Commons/Exception.h>
-#include <nfc.h>
-#include "NFCManager.h"
-#include "NFCUtil.h"
-
-using namespace TizenApis::Api::NFC;
-using namespace DPL;
-
-namespace TizenApis {
-namespace Platform {
-namespace NFC {
-
-namespace
-{
-       static void TagDetectedCallback(nfc_discovered_type_e type, nfc_tag_h tag, void *data) {
-               LogDebug("Callback TagDetectedCallback.");
-
-               if (data) {
-                       if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
-                               (static_cast<NFCManager*>(data))->updateCurrentHandle((void *)tag);
-                               (static_cast<NFCManager*>(data))->NFCHasDetected((void *)tag, NFC_TAG_TYPE);
-                       } else {
-                               (static_cast<NFCManager*>(data))->updateCurrentHandle(NULL);
-                               (static_cast<NFCManager*>(data))->NFCHasDetected(NULL, NFC_TAG_TYPE);
-                       }
-               } else {
-                       LogError("Callback private data is NULL.");
-               }
-
-       }
-
-       static void TargetDetectedCallback(nfc_discovered_type_e type, nfc_p2p_target_h target, void *data) {
-               LogDebug("Callback TargetDetectedCallback.");
-
-               if (data) {
-                       if (NFC_DISCOVERED_TYPE_ATTACHED == type) {
-                               (static_cast<NFCManager*>(data))->updateCurrentHandle((void *)target);
-                               (static_cast<NFCManager*>(data))->NFCHasDetected((void *)target, NFC_TARGET_TYPE);
-                       } else {
-                               (static_cast<NFCManager*>(data))->updateCurrentHandle(NULL);
-                               (static_cast<NFCManager*>(data))->NFCHasDetected(NULL, NFC_TARGET_TYPE);
-                       }
-               } else {
-                       LogError("Callback private data is NULL.");
-               }
-
-       }
-
-       static void NDEFDetectedCallback(nfc_ndef_message_h message, void *data) {
-               LogDebug("Callback NDEFDetectedCallback.");
-               if (data) {
-                       unsigned char *UrawData;
-                       int size;
-
-                       if (nfc_ndef_message_get_rawdata(message, &UrawData, &size) != NFC_ERROR_NONE) {
-                               LogError("Can't get rawdata of message");
-                               return;
-                       }
-
-                       NFCUtil Util;
-                       (static_cast<NFCManager*>(data))->NDEFHasDetected(Util.toVector(UrawData, size));
-
-               } else {
-                       LogError("Callback private data is NULL.");
-               }
-       }
-
-       static void SeEventCallback(nfc_se_event_e event, void *data) {
-               LogDebug("Callback NDEFDetectedCallback.");
-               if (data) {
-                       nfcSeEventType seEvent = NFC_SE_EVENTTYPE_END_TRANSACTION;
-                       switch(event) {
-                               case NFC_SE_EVENT_START_TRANSACTION:
-                                       seEvent = NFC_SE_EVENTTYPE_START_TRANSACTION;
-                                       break;
-                               case NFC_SE_EVENT_END_TRANSACTION:
-                                       seEvent = NFC_SE_EVENTTYPE_END_TRANSACTION;
-                                       break;
-                               case NFC_SE_EVENT_CONNECTIVITY:
-                                       seEvent = NFC_SE_EVENTTYPE_CONNECTIVITY;
-                                       break;
-                               case NFC_SE_EVENT_FIELD_ON:
-                                       seEvent = NFC_SE_EVENTTYPE_FIELD_ON;
-                                       break;
-                               case NFC_SE_EVENT_FIELD_OFF:
-                                       seEvent = NFC_SE_EVENTTYPE_FIELD_OFF;
-                                       break;
-                       }
-                       (static_cast<NFCManager*>(data))->SeEventHasDetected(seEvent);
-
-               } else {
-                       LogError("Callback private data is NULL.");
-               }
-       }
-}//private namespace
-
-NFCManager::NFCManager()
-       :m_initialized(false) {
-       LogDebug("Platform::NFC Enter");
-       initialize();
-       curHandle = NULL;
-
-       m_managerPriv = NULL;
-
-       m_NFCTagEmitterPtr.Reset();
-       m_NFCTargetEmitterPtr.Reset();
-       m_NdefEmitterPtr.Reset();
-       m_SeEventEmitterPtr.Reset();
-
-       m_tagFilter.Reset();
-
-}
-
-NFCManager::~NFCManager() {
-       LogDebug("Enter");
-       int result = -1;
-       if(m_initialized == true)
-{
-               result = nfc_manager_deinitialize ();
-               if (result !=NFC_ERROR_NONE) {
-                       LogInfo("failed to deinitialize nfc");
-               }
-       }
-
-       nfc_manager_unset_tag_discovered_cb();
-       nfc_manager_unset_p2p_target_discovered_cb();
-       nfc_manager_unset_ndef_discovered_cb();
-       nfc_manager_unset_se_event_cb();
-
-       m_managerPriv = NULL;
-
-       LogDebug("destroy nfc");
-}
-
-int NFCManager::setTagListener(const EventNFCChangedEmitterPtr& emitter,
-               TagFilterPtr pFilter, void *managerPriv) {
-       LogDebug(" NFCManager::setTagListener Entered");
-       int result = -1;
-
-       if (m_NFCTagEmitterPtr.Get() != NULL)
-               Throw(WrtDeviceApis::Commons::AlreadyInUseException);
-
-       m_NFCTagEmitterPtr = emitter;
-       m_managerPriv = managerPriv;
-
-       LogDebug(" NFCManager::setTagListener set discovered callback, filter size == " << pFilter->getFilterSize());
-
-       m_tagFilter = pFilter;
-       if (pFilter->getFilterSize() > 0) {
-               int filter = NFC_TAG_FILTER_ALL_DISABLE;
-               for (int cnt = 0; cnt < pFilter->getFilterSize() ; cnt++) {
-                       LogDebug(" NFCManager::setTagListener filter == " << pFilter->getFilterValue(cnt));
-                       if ((pFilter->getFilterValue(cnt) >= NFC_TAGTYPE_ISO14443_A_PICC) && (pFilter->getFilterValue(cnt) <= NFC_TAGTYPE_MIFARE_DESFIRE_PICC))
-                               filter = filter |NFC_TAG_FILTER_ISO14443A_ENABLE;
-                       else if ((pFilter->getFilterValue(cnt) >= NFC_TAGTYPE_ISO14443_B_PICC) && (pFilter->getFilterValue(cnt) <= NFC_TAGTYPE_ISO14443_BPRIME_PICC))
-                               filter = filter |NFC_TAG_FILTER_ISO14443B_ENABLE;
-                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_FELICA_PICC)
-                               filter = filter |NFC_TAG_FILTER_FELICA_ENABLE ;
-                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_JEWEL_PICC)
-                               filter = filter |NFC_TAG_FILTER_JEWEL_ENABLE  ;
-                       else if (pFilter->getFilterValue(cnt) == NFC_TAGTYPE_ISO15693_PICC)
-                               filter = filter |NFC_TAG_FILTER_ISO15693_ENABLE ;
-               }
-               nfc_manager_set_tag_filter(filter);
-       } else {
-               nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
-       }
-
-       result = nfc_manager_set_tag_discovered_cb (TagDetectedCallback, this);
-       if (result != NFC_ERROR_NONE)
-       {
-               LogInfo("failed to set callback of nfc_manager_set_ndef_discovered_cb");
-               return result;
-       }
-       LogInfo("NFCManager::setTagListener : result << " << result);
-       return result;
-}
-
-int NFCManager::setPeerListener(const EventNFCChangedEmitterPtr& emitter, void *managerPriv) {
-       LogDebug(" NFCManager::setPeerListener Entered");
-       int result = -1;
-
-       if (m_NFCTargetEmitterPtr.Get() != NULL)
-               Throw(WrtDeviceApis::Commons::AlreadyInUseException);
-
-       m_NFCTargetEmitterPtr = emitter;
-       m_managerPriv = managerPriv;
-       result = nfc_manager_set_p2p_target_discovered_cb (TargetDetectedCallback, this);
-
-       if (result != NFC_ERROR_NONE)
-       {
-               LogInfo("failed to set callback of nfc_manager_set_p2p_target_discovered_cb");
-               return result;
-       }
-
-       LogInfo("NFCManager::setPeerListener : result << " << result);
-       return result;
-}
-
-int NFCManager::setNDEFListener(const EventNFCChangedNdefEmitterPtr& emitter) {
-       LogDebug(" NFCManager::setNDEFListener Entered");
-       int result = -1;
-
-       if (m_NdefEmitterPtr.Get() != NULL)
-               Throw(WrtDeviceApis::Commons::AlreadyInUseException);
-
-       m_NdefEmitterPtr = emitter;
-       result = nfc_manager_set_ndef_discovered_cb(NDEFDetectedCallback, this);
-       if (result != NFC_ERROR_NONE)
-       {
-               LogInfo("failed to set callback of nfc_manager_set_ndef_discovered_cb");
-               return result;
-       }
-       nfc_manager_set_tag_filter(NFC_TAG_FILTER_ALL_ENABLE);
-       LogInfo("NFCManager::setNDEFListener : result << " << result);
-       return result;
-}
-
-int NFCManager::setSEEventListener(const EventNFCChangedSeEventEmitterPtr& emitter) {
-       LogDebug(" NFCManager::setNDEFListener Entered");
-       int result = -1;
-
-       if (m_SeEventEmitterPtr.Get() != NULL)
-               Throw(WrtDeviceApis::Commons::AlreadyInUseException);
-
-       m_SeEventEmitterPtr = emitter;
-       result = nfc_manager_set_se_event_cb (SeEventCallback, this);
-       if (result != NFC_ERROR_NONE)
-       {
-               LogInfo("failed to set callback of NFC_manager_set_tag_discovered_cb");
-               return result;
-       }
-       LogInfo("NFCManager::setSEEventListener : result << " << result);
-       return result;
-}
-
-void NFCManager::unsetTagListener(/*EventNFCChangedEmitter::IdType id*/) {
-       LogDebug(" NFCManager::unsetTagListener Entered");
-
-       nfc_manager_unset_tag_discovered_cb ();
-       m_NFCTagEmitterPtr.Reset();
-       }
-
-void NFCManager::unsetPeerListener(/*EventNFCChangedEmitter::IdType id*/) {
-       LogDebug(" NFCManager::unsetPeerListener Entered");
-       nfc_manager_unset_p2p_target_discovered_cb();
-       m_NFCTargetEmitterPtr.Reset();
-}
-
-
-void NFCManager::unsetNDEFListener() {
-       LogDebug(" NFCManager::unsetNDEFListener Entered");
-       nfc_manager_unset_ndef_discovered_cb();
-       m_NdefEmitterPtr.Reset();
-}
-
-void NFCManager::unsetSEEventListener() {
-       LogDebug(" NFCManager::unsetSEEventListener Entered");
-       nfc_manager_unset_se_event_cb();
-       m_SeEventEmitterPtr.Reset();
-}
-
-void NFCManager::NFCHasDetected(void *props, EventNFCType type)
-{
-       LogDebug("NFCManager::NFCHasDetected Enter type : " << type);
-
-       if (((m_NFCTagEmitterPtr.Get() != NULL) && (type == NFC_TAG_TYPE)) ||
-               ((m_NFCTargetEmitterPtr.Get() != NULL) && (type == NFC_TARGET_TYPE))){
-               EventNFCType nfcType = type;
-
-               if ((props != NULL) && (type == NFC_TAG_TYPE)) {
-
-                       nfc_tag_type_e tagType;
-
-                       if (nfc_tag_get_type((nfc_tag_h)props, &tagType) == NFC_ERROR_NONE) {
-                               LogDebug("NFCManager::NFCHasDetected Tag real type : " << tagType);
-                                                                       int cnt;
-                               for (cnt = 0; cnt < m_tagFilter->getFilterSize() ; cnt++) {
-                                       NFCUtil Util;
-                                       if (Util.convertTonfcTagType(static_cast<unsigned short>(tagType)) == m_tagFilter->getFilterValue(cnt))
-                                               break;
-                               }
-                               if ((m_tagFilter->getFilterSize() > 0) && (cnt == m_tagFilter->getFilterSize())) {
-                                       LogDebug("Filter doesn't have this tag type ");
-                                       return;
-                               }
-
-                               switch(tagType) {
-                                       case NFC_MIFARE_MINI_PICC:
-                                       case NFC_MIFARE_1K_PICC:
-                                       case NFC_MIFARE_4K_PICC:
-                                               nfcType = NFC_TAG_MIFARE_CLASSIC_TYPE;
-                                               break;
-                                       case NFC_MIFARE_ULTRA_PICC:
-                                               nfcType = NFC_TAG_MIFARE_ULTRA_TYPE;
-                                               break;
-                                       default:
-                                               nfcType = NFC_TAG_TYPE;
-                                               break;
-                               }
-                       } else {
-                               LogDebug("It can't get real nfc tag type");
-                               int cnt;
-                               for (cnt = 0; cnt < m_tagFilter->getFilterSize() ; cnt++) {
-                                       if (NFC_TAGTYPE_GENERIC_PICC == m_tagFilter->getFilterValue(cnt))
-                                               break;
-                               }
-
-                               if (cnt == m_tagFilter->getFilterSize()) {
-                                       LogDebug("Filter doesn't have this tag type ");
-                                       return;
-                               }
-
-                       }
-               }
-
-               EventNFCChangedPtr event( new EventNFCChanged() );
-               LogDebug("nfc type was detected");
-               if (props == NULL)
-                       event->setNFCStatus(NFC_DETATCHED);
-               else
-                       event->setNFCStatus(NFC_ATTATCHED);
-               event->setNFCProperties(props);
-               event->setNFCType(nfcType);
-               event->setPrivateNFCManagerPtr(m_managerPriv);
-               LogDebug("emit event with nfc tag info");
-               if (type == NFC_TARGET_TYPE)
-                       m_NFCTargetEmitterPtr->emit(event);
-               else
-                       m_NFCTagEmitterPtr->emit(event);
-       } else {
-               LogDebug("m_NFCTagEmitterPtr.Get() != NULL ? " << (m_NFCTagEmitterPtr.Get() != NULL));
-       }
-
-
-}
-
-void NFCManager::NDEFHasDetected(std::vector<unsigned char> data)
-{
-       LogDebug("NFCManager::NFCHasDetected Enter");
-
-       if (m_NdefEmitterPtr.Get() != NULL) {
-               EventNFCChangedNdefPtr event( new EventNFCChangedNdef() );
-               LogDebug("nfc type was detected");
-
-               event->setReadNdefResult(data);
-               LogDebug("emit event with nfc tag info");
-               m_NdefEmitterPtr->emit(event);
-       }
-}
-
-void NFCManager::SeEventHasDetected(nfcSeEventType eventType)
-{
-       LogDebug("NDEF is detected Enter");
-
-       if (m_SeEventEmitterPtr.Get() != NULL) {
-               EventNFCChangedSeEventPtr event( new EventNFCChangedSeEvent() );
-               event->setSeEvent(eventType);
-               m_SeEventEmitterPtr->emit(event);
-       }
-}
-
-void NFCManager::initialize() {
-       LogDebug("NFCManager::initialize Entered");
-       int result = -1;
-       result = nfc_manager_initialize();
-       if (result != NFC_ERROR_NONE) {
-               LogError("Could not initialize NFC.");
-               Throw(WrtDeviceApis::Commons::UnsupportedException);
-               m_initialized = false;
-       }
-       m_initialized = true;
-       return;
-}
-
-void *NFCManager::getCachedMessage() {
-       LogDebug("Entered");
-       nfc_ndef_message_h messageHandle;
-       int result = nfc_manager_get_cached_message(&messageHandle);
-       if (result == NFC_ERROR_INVALID_NDEF_MESSAGE)
-               return NULL;
-       if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get cached message");
-
-       return (void *)(messageHandle);
-}
-
-bool NFCManager::isValidHandle(void * handle) {
-       LogDebug("Entered");
-       if ((handle != NULL) && (handle == curHandle))
-               return TRUE;
-
-       return FALSE;
-}
-
-void NFCManager::updateCurrentHandle(void *handle) {
-       LogDebug("Updated!");
-       curHandle = handle;
-}
-
-}
-}
-}
index 6f89865..7f910af 100755 (executable)
@@ -20,6 +20,7 @@
 #include <dpl/log/log.h>
 
 #include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenException.h>
 
 #include "NFCTag.h"
 #include "NFCUtil.h"
@@ -29,7 +30,6 @@ namespace Platform {
 namespace NFC {
 
 using namespace Api::NFC;
-using namespace WrtDeviceApis;
 
 namespace
 {
@@ -53,19 +53,21 @@ namespace
        static void TagReadCallback(nfc_error_e result , nfc_ndef_message_h message , void * data) {
                LogDebug("Callback TagReadCallback.");
                if (data) {
-
-                       LogDebug("message handler :" << message);
-
-                       unsigned char *UrawData;
-                       int size;
-                       if (nfc_ndef_message_get_rawdata(message, &UrawData, &size) != NFC_ERROR_NONE) {
-                               LogError("Can't get record's rawdata");
-                               return;
+                       NFCTag *tagPtr = (NFCTag *)((EventNFCPtrs<EventTagActionRead> *)data)->getThisPtr();
+                       if (tagPtr) {
+                               EventTagActionReadPtr event = ((EventNFCPtrs<EventTagActionRead> *)data)->getEventPtrs();
+                               LogDebug("message handler :" << message);
+
+                               unsigned char *UrawData;
+                               int size;
+                               if (nfc_ndef_message_get_rawdata(message, &UrawData, &size) != NFC_ERROR_NONE) {
+                                       LogError("Can't get record's rawdata");
+                                       return;
+                               }
+
+                               NFCUtil Util;
+                               tagPtr->readNdefManualAnswer((int)result, Util.toVector(UrawData, size), event);
                        }
-
-                       NFCUtil Util;
-                       ((NFCTag *)data)->readNdefManualAnswer((int)result, Util.toVector(UrawData, size));
-
                
                } else {
                        LogDebug("Error! TagReadCallback is Null.");
@@ -107,6 +109,10 @@ NFCTag::NFCTag(void *tagHandle)
        LogDebug("entered");
 
        handle = (nfc_tag_h)tagHandle;
+
+       m_EventTagActionWritePtr.Reset();
+       m_EventTagActionTransceivePtr.Reset();
+       m_EventTagActionFormatPtr.Reset();
 }
 
 NFCTag::~NFCTag()
@@ -121,33 +127,43 @@ void *NFCTag::getHandle() {
 
 nfcTagType NFCTag::getTagType() {
        nfc_tag_type_e type = NFC_UNKNOWN_TARGET;
-       if (nfc_tag_get_type(handle, &type) != NFC_ERROR_NONE)
-               ThrowMsg(Commons::PlatformException, "Can't get tag Type");
-       
+       int result = nfc_tag_get_type(handle, &type);
+
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get tag Type");
+
        return Util.convertTonfcTagType(type);
 }
 
 bool NFCTag::isNDEFSupport() {
        bool isNDEF = FALSE;
-       if (nfc_tag_is_support_ndef(handle, &isNDEF) != NFC_ERROR_NONE)
-               ThrowMsg(Commons::PlatformException, "Can't get if Ndef is supported");
+       int result = nfc_tag_is_support_ndef(handle, &isNDEF);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get if Ndef is supported");
+
        return isNDEF;
 }
 long NFCTag::getNdefSize(){
        unsigned int ndefSize;
-       if (nfc_tag_get_ndef_size(handle, &ndefSize) != NFC_ERROR_NONE)
-               ThrowMsg(Commons::PlatformException, "Can't get Ndef size");
+       int result = nfc_tag_get_ndef_size(handle, &ndefSize);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get Ndef size");
 
        return static_cast<long>(ndefSize);
 }
 std::vector<NFCTagProperties> NFCTag::getProperties() {
        LogDebug("Enter");
        props.clear();
-       if(nfc_tag_foreach_information(handle, TagInformationCallback, this) != NFC_ERROR_NONE )
-       {
-               ThrowMsg(Commons::PlatformException, "call back set error");
-       }
+       int result = nfc_tag_foreach_information(handle, TagInformationCallback, this);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get Ndef Properties");
 
        return props;
 }
@@ -166,12 +182,20 @@ void NFCTag::readNdef(const EventTagActionReadPtr& event) {
 
 void NFCTag::writeNdef(const EventTagActionWritePtr& event) {
        LogDebug("Enter");
-       EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
+       
+       if (m_EventTagActionWritePtr.Get() != NULL)
+               EventTagActionWrites.push_back(event);
+       else
+               EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
 }
 
 void NFCTag::transceive(const EventTagActionTransceivePtr& event) {
        LogDebug("Enter");
-       EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
+
+       if (m_EventTagActionTransceivePtr.Get() != NULL)
+               EventTagActionTransceives.push_back(event);
+       else
+               EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
 }
 
 void NFCTag::format(const EventTagActionFormatPtr& event) {
@@ -179,51 +203,94 @@ void NFCTag::format(const EventTagActionFormatPtr& event) {
        EventRequestReceiver<EventTagActionFormat>::PostRequest(event);
 }
 
-void NFCTag::readNdefManualAnswer(int result , std::vector<unsigned char> data) 
+void NFCTag::readNdefManualAnswer(int result , std::vector<unsigned char> data, const EventTagActionReadPtr &event
 {
        LogDebug("Enter");
        if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagActionReadPtr->setResult(TRUE);
-               m_EventTagActionReadPtr->setReadNdefResult(data);
-
+               event->setResult(TRUE);
+               event->setReadNdefResult(data);
        } else {
-               m_EventTagActionReadPtr->setResult(FALSE);
+               NFCUtil Util;
+               event->setResult(FALSE);
+               event->setError(Util.getNFCErrorString(result));
+               event->setErrorMessage(Util.getNFCErrorMessage(result));
+       }
+       EventRequestReceiver<EventTagActionRead>::ManualAnswer(event);
+
+       std::vector<TagReadDataPtr>::iterator it;
+       for (it = EventTagActionsReads.begin(); it != EventTagActionsReads.end(); ++it) {
+               if ((*it)->getEventPtrs() == event) {
+                       EventTagActionsReads.erase(it);
+                       LogDebug("event is removed. (" << EventTagActionsReads.size() << ")");
+                       break;
+               }
        }
-       EventRequestReceiver<EventTagActionRead>::ManualAnswer(m_EventTagActionReadPtr);
 }
 
 void NFCTag::writeNdefManualAnswer(int result) 
 {
        LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagActionWritePtr->setResult(TRUE);
-       } else {
-               m_EventTagActionWritePtr->setResult(FALSE);
+       if (m_EventTagActionWritePtr.Get() != NULL) {
+               if ((nfc_error_e)result == NFC_ERROR_NONE) {
+                       m_EventTagActionWritePtr->setResult(TRUE);
+               } else {
+                       NFCUtil Util;
+                       m_EventTagActionWritePtr->setResult(FALSE);
+                       m_EventTagActionWritePtr->setError(Util.getNFCErrorString(result));
+                       m_EventTagActionWritePtr->setErrorMessage(Util.getNFCErrorMessage(result));
+               }
+               EventRequestReceiver<EventTagActionWrite>::ManualAnswer(m_EventTagActionWritePtr);
+
+               m_EventTagActionWritePtr.Reset();
+               if (EventTagActionWrites.size() > 0) {
+                       EventTagActionWritePtr event = EventTagActionWrites.front();
+                       EventTagActionWrites.erase(EventTagActionWrites.begin());
+                       LogDebug("EventTagActionWrites is removed. (" << EventTagActionWrites.size() << ")");
+                       EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
+               }
        }
-       EventRequestReceiver<EventTagActionWrite>::ManualAnswer(m_EventTagActionWritePtr);
 }
 
 void NFCTag::transceiveManualAnswer(int result , std::vector<unsigned char> data) 
 {
        LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagActionTransceivePtr->setResult(TRUE);
-               m_EventTagActionTransceivePtr->setTransceiveBuffer(data);
-       } else {
-               m_EventTagActionTransceivePtr->setResult(FALSE);
+       if (m_EventTagActionTransceivePtr.Get() != NULL) {
+               if ((nfc_error_e)result == NFC_ERROR_NONE) {
+                       m_EventTagActionTransceivePtr->setResult(TRUE);
+                       m_EventTagActionTransceivePtr->setTransceiveBuffer(data);
+               } else {
+                       NFCUtil Util;
+                       m_EventTagActionTransceivePtr->setResult(FALSE);
+                       m_EventTagActionTransceivePtr->setError(Util.getNFCErrorString(result));
+                       m_EventTagActionTransceivePtr->setErrorMessage(Util.getNFCErrorMessage(result));
+               }
+               EventRequestReceiver<EventTagActionTransceive>::ManualAnswer(m_EventTagActionTransceivePtr);
+
+               m_EventTagActionTransceivePtr.Reset();
+               if (EventTagActionTransceives.size() > 0) {
+                       EventTagActionTransceivePtr event = EventTagActionTransceives.front();
+                       EventTagActionTransceives.erase(EventTagActionTransceives.begin());
+                       LogDebug("EventTagActionWrites is removed. (" << EventTagActionTransceives.size() << ")");
+                       EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
+               }
        }
-       EventRequestReceiver<EventTagActionTransceive>::ManualAnswer(m_EventTagActionTransceivePtr);
 }
 
 void NFCTag::formatManualAnswer(int result ) 
 {
        LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagActionFormatPtr->setResult(TRUE);
-       } else {
-               m_EventTagActionFormatPtr->setResult(FALSE);
+       if (m_EventTagActionFormatPtr.Get() != NULL) {
+               if ((nfc_error_e)result == NFC_ERROR_NONE) {
+                       m_EventTagActionFormatPtr->setResult(TRUE);
+               } else {
+                       NFCUtil Util;
+                       m_EventTagActionFormatPtr->setResult(FALSE);
+                       m_EventTagActionFormatPtr->setError(Util.getNFCErrorString(result));
+                       m_EventTagActionFormatPtr->setErrorMessage(Util.getNFCErrorMessage(result));
+               }
+               EventRequestReceiver<EventTagActionFormat>::ManualAnswer(m_EventTagActionFormatPtr);
+               m_EventTagActionFormatPtr.Reset();
        }
-       EventRequestReceiver<EventTagActionFormat>::ManualAnswer(m_EventTagActionFormatPtr);
 }
 
 void NFCTag::OnRequestReceived(const EventTagActionReadPtr& event) {
@@ -232,14 +299,29 @@ void NFCTag::OnRequestReceived(const EventTagActionReadPtr& event) {
        try {
                event->switchToManualAnswer();
 
-               m_EventTagActionReadPtr = event;
+               TagReadDataPtr data( new EventNFCPtrs<EventTagActionRead>(event, this));
+               EventTagActionsReads.push_back(data);
+               int result = nfc_tag_read_ndef(handle, TagReadCallback, data.Get());
 
-               if( nfc_tag_read_ndef(handle, TagReadCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
+               NFCUtil Util;
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventTagActionRead>::ManualAnswer(event);
+
+                       std::vector<TagReadDataPtr>::iterator it;
+                       for (it = EventTagActionsReads.begin(); it != EventTagActionsReads.end(); ++it) {
+                               if ((*it)->getEventPtrs() == event) {
+                                       EventTagActionsReads.erase(it);
+                                       LogDebug("event is removed. (" << EventTagActionsReads.size() << ")");
+                                       break;
+                               }
+                       }
                }
        }
-       catch (const Commons::Exception& ex) {
+       catch (const WrtDeviceApis::Commons::Exception& ex) {
                LogError("Exception: " << ex.GetMessage());
                event->setResult(false);
        
@@ -254,16 +336,39 @@ void NFCTag::OnRequestReceived(const EventTagActionWritePtr& event) {
                event->switchToManualAnswer();
 
                m_EventTagActionWritePtr = event;
-               if( nfc_tag_write_ndef(handle, (nfc_ndef_message_h)event->getNdefForWriting(),TagWriteCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
+
+               int result = nfc_tag_write_ndef(handle, (nfc_ndef_message_h)event->getNdefForWriting(),TagWriteCallback, this);
+
+               NFCUtil Util;
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventTagActionWrite>::ManualAnswer(event);
+
+                       m_EventTagActionWritePtr.Reset();
+                       if (EventTagActionWrites.size() > 0) {
+                               EventTagActionWritePtr event = EventTagActionWrites.front();
+                               EventTagActionWrites.erase(EventTagActionWrites.begin());
+                               LogDebug("EventTagActionWrites is removed. (" << EventTagActionWrites.size() << ")");
+                               EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
+                       }
                }
        }
-       catch (const Commons::Exception& ex) {
+       catch (const WrtDeviceApis::Commons::Exception& ex) {
                LogError("Exception: " << ex.GetMessage());
                event->setResult(false);
-               
+
                EventRequestReceiver<EventTagActionWrite>::ManualAnswer(event);
+
+               m_EventTagActionWritePtr.Reset();
+               if (EventTagActionWrites.size() > 0) {
+                       EventTagActionWritePtr event = EventTagActionWrites.front();
+                       EventTagActionWrites.erase(EventTagActionWrites.begin());
+                       LogDebug("EventTagActionWrites is removed. (" << EventTagActionWrites.size() << ")");
+                       EventRequestReceiver<EventTagActionWrite>::PostRequest(event);
+               }
        }
        
 }
@@ -274,18 +379,39 @@ void NFCTag::OnRequestReceived(const EventTagActionTransceivePtr& event) {
                event->switchToManualAnswer();
                
                m_EventTagActionTransceivePtr = event;
-               
-               NFCUtil Util;
-               if( nfc_tag_transceive(handle, Util.toCharPtr(event->getTransceiveBuffer()), event->getTransceiveBufferSize(), TagTransceiveCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
+
+               NFCUtil Util;           
+               int result = nfc_tag_transceive(handle, Util.toCharPtr(event->getTransceiveBuffer()), event->getTransceiveBufferSize(), TagTransceiveCallback, this);
+
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventTagActionTransceive>::ManualAnswer(event);
+
+                       m_EventTagActionTransceivePtr.Reset();
+                       if (EventTagActionTransceives.size() > 0) {
+                               EventTagActionTransceivePtr event = EventTagActionTransceives.front();
+                               EventTagActionTransceives.erase(EventTagActionTransceives.begin());
+                               LogDebug("EventTagActionTransceives is removed. (" << EventTagActionTransceives.size() << ")");
+                               EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
+                       }
                }
        }
-       catch (const Commons::Exception& ex) {
+       catch (const WrtDeviceApis::Commons::Exception& ex) {
                LogError("Exception: " << ex.GetMessage());
                event->setResult(false);
                
                EventRequestReceiver<EventTagActionTransceive>::ManualAnswer(event);
+
+               m_EventTagActionTransceivePtr.Reset();
+               if (EventTagActionTransceives.size() > 0) {
+                       EventTagActionTransceivePtr event = EventTagActionTransceives.front();
+                       EventTagActionTransceives.erase(EventTagActionTransceives.begin());
+                       LogDebug("EventTagActionWrites is removed. (" << EventTagActionTransceives.size() << ")");
+                       EventRequestReceiver<EventTagActionTransceive>::PostRequest(event);
+               }
        }
        
 }
@@ -294,21 +420,36 @@ void NFCTag::OnRequestReceived(const EventTagActionFormatPtr& event) {
        
        try {
                event->switchToManualAnswer();
-               
+
+               if (m_EventTagActionFormatPtr.Get() != NULL) {
+                       event->setResult(false);
+                       event->setError(Commons::JSTizenException::SERVICE_NOT_AVAILABLE);
+                       event->setErrorMessage("Progressing Identical Operation");
+                       EventRequestReceiver<EventTagActionFormat>::ManualAnswer(event);
+                       return;
+               }
                m_EventTagActionFormatPtr = event;
                
                NFCUtil Util;
                LogDebug("key size :" <<  event->getKeySize());
-               if( nfc_tag_format_ndef(handle, Util.toCharPtr(event->getKey()), event->getKeySize(), TagFormatCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
+
+               int result = nfc_tag_format_ndef(handle, Util.toCharPtr(event->getKey()), event->getKeySize(), TagFormatCallback, this);
+
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventTagActionFormat>::ManualAnswer(event);
+                       m_EventTagActionFormatPtr.Reset();
                }
        }
-       catch (const Commons::Exception& ex) {
+       catch (const WrtDeviceApis::Commons::Exception& ex) {
                LogError("Exception: " << ex.GetMessage());
                event->setResult(false);
                
                EventRequestReceiver<EventTagActionFormat>::ManualAnswer(event);
+               m_EventTagActionFormatPtr.Reset();
        }
        
 }
index a7f87d8..ba1ddaa 100755 (executable)
@@ -27,6 +27,7 @@ using namespace TizenApis::Api::NFC;
 namespace TizenApis {
 namespace Platform {
 namespace NFC {
+typedef DPL::SharedPtr<EventNFCPtrs<EventTagActionRead>> TagReadDataPtr;
 
 class NFCTag : public INFCTag
 {
@@ -45,18 +46,21 @@ class NFCTag : public INFCTag
        virtual void transceive(const EventTagActionTransceivePtr& event);
        virtual void format(const EventTagActionFormatPtr& event);
 
-       virtual void readNdefManualAnswer(int result , std::vector<unsigned char> data);
-       virtual void writeNdefManualAnswer(int result );
-       virtual void transceiveManualAnswer(int result , std::vector<unsigned char> data);
-       virtual void formatManualAnswer(int result);
+       void readNdefManualAnswer(int result , std::vector<unsigned char> data, const EventTagActionReadPtr &event);
+       void writeNdefManualAnswer(int result );
+       void transceiveManualAnswer(int result , std::vector<unsigned char> data);
+       void formatManualAnswer(int result);
 
        void makeTagProperties(const char *key, std::vector<unsigned char> value);
     private:
-       EventTagActionReadPtr m_EventTagActionReadPtr;
        EventTagActionWritePtr m_EventTagActionWritePtr;
        EventTagActionTransceivePtr m_EventTagActionTransceivePtr;
        EventTagActionFormatPtr m_EventTagActionFormatPtr;
 
+       std::vector<TagReadDataPtr> EventTagActionsReads;
+       std::vector<EventTagActionWritePtr> EventTagActionWrites;
+       std::vector<EventTagActionTransceivePtr> EventTagActionTransceives;
+
     protected:
        nfc_tag_h handle;
        std::vector<NFCTagProperties> props;
diff --git a/src/platform/Tizen/NFC/NFCTagMifareClassic.cpp b/src/platform/Tizen/NFC/NFCTagMifareClassic.cpp
deleted file mode 100755 (executable)
index c14ac62..0000000
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-#include <dpl/log/log.h>
-
-#include <Commons/Exception.h>
-
-#include "NFCTagMifareClassic.h"
-#include "NFCUtil.h"
-
-#include <nfc.h>
-
-namespace TizenApis {
-namespace Platform {
-namespace NFC {
-
-using namespace Api::NFC;
-using namespace WrtDeviceApis;
-namespace
-{
-       /**
-       * Callback method called by platform as interval time.
-       * @param event_type Platform magnetic evet type
-       * @param event Platform sensor event data
-       * @param this_ User data pointer.
-       */
-       static void MifareClassicAuthenticateWithKeyACallback(nfc_error_e result , void * data) {
-               LogDebug("Callback MifareClassicAuthenticateWithKeyACallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->authenticateWithKeyAManualAnswer((int) result);
-               } else {
-                       LogDebug("Error! MifareClassicAuthenticateWithKeyACallback is Null.");
-               }
-       }
-
-       static void MifareClassicAuthenticateWithKeyBCallback(nfc_error_e result ,  void * data) {
-               LogDebug("Callback MifareClassicAuthenticateWithKeyBCallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->authenticateWithKeyBManualAnswer((int)result);
-               } else {
-                       LogDebug("Error! MifareClassicAuthenticateWithKeyBCallback is Null.");
-               }               
-       }
-
-       static void MifareClassicReadBlockCallback(nfc_error_e result , unsigned char * buffer, int buffer_size,  void * data) {
-               LogDebug("Callback MifareClassicReadBlockCallback. result : " << result);
-               if (data) {
-                       NFCUtil Util;
-                       
-                       ((NFCTagMifareClassic *)data)->readBlockManualAnswer((int)result, Util.toVector(buffer, buffer_size));                  
-               } else {
-                       LogDebug("Error! MifareClassicReadBlockCallback is Null.");
-               }               
-       }
-
-       static void MifareClassicWriteBlockCallback(nfc_error_e result , void * data) {
-               LogDebug("Callback MifareClassicAuthenticateWithKeyACallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->writeBlockManualAnswer((int)result);
-               } else {
-                       LogDebug("Error! MifareClassicAuthenticateWithKeyACallback is Null.");
-               }
-       }
-
-       static void MifareClassicIncrementBlockValueCallback(nfc_error_e result ,  void * data) {
-               LogDebug("Callback MifareClassicIncrementBlockValueCallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->incrementBlockValueManualAnswer((int)result);
-               } else {
-                       LogDebug("Error! MifareClassicIncrementBlockValueCallback is Null.");
-               }               
-       }
-
-       static void MifareClassicDecrementBlockValueCallback(nfc_error_e result , void * data) {
-               LogDebug("Callback MifareClassicDecrementBlockValueCallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->decrementBlockValueManualAnswer((int)result );
-               } else {
-                       LogDebug("Error! MifareClassicDecrementBlockValueCallback is Null.");
-               }               
-       }       
-
-       static void MifareClassicTransferManualAnswerCallback(nfc_error_e result , void * data) {
-               LogDebug("Callback MifareClassicTransferManualAnswerCallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->transferManualAnswer((int)result );
-               } else {
-                       LogDebug("Error! MifareClassicTransferManualAnswerCallback is Null.");
-               }
-       }
-
-       static void MifareClassicRestoreManualAnswerCallback(nfc_error_e result ,  void * data) {
-               LogDebug("Callback MifareClassicRestoreCallback. result : " << result);
-               if (data) {
-                       ((NFCTagMifareClassic *)data)->restoreManualAnswer((int)result );
-               } else {
-                       LogDebug("Error! MifareClassicRestoreCallback is Null.");
-               }               
-       }
-}//private namespace
-
-NFCTagMifareClassic::NFCTagMifareClassic(void *tagHandle)
-{
-       LogDebug("entered");
-
-       if (tagHandle == NULL)
-               ThrowMsg(Commons::PlatformException, "Tag Handler is Null Pointer.");
-
-       handle = (nfc_tag_h)tagHandle;
-}
-
-NFCTagMifareClassic::~NFCTagMifareClassic()
-{
-       LogDebug("entered");
-       handle = NULL;
-}
-
-void NFCTagMifareClassic::authenticateWithKeyA(const EventTagMifareClassicAuthenticateWithKeyAPtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyA>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::authenticateWithKeyB(const EventTagMifareClassicAuthenticateWithKeyBPtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyB>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::readBlock(const EventTagMifareClassicReadBlockPtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicReadBlock>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::writeBlock(const EventTagMifareClassicWriteBlockPtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicWriteBlock>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::incrementBlockValue(const EventTagMifareClassicIncrementBlockValuePtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicIncrementBlockValue>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::decrementBlockValue(const EventTagMifareClassicDecrementBlockValuePtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicDecrementBlockValue>::PostRequest(event);
-}
-void NFCTagMifareClassic::transfer(const EventTagMifareClassicTransferPtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicTransfer>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::restore(const EventTagMifareClassicRestorePtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareClassicRestore>::PostRequest(event);
-}
-
-void NFCTagMifareClassic::authenticateWithKeyAManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicAuthenticateWithKeyAPtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicAuthenticateWithKeyAPtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyA>::ManualAnswer(m_EventTagMifareClassicAuthenticateWithKeyAPtr);
-}
-
-void NFCTagMifareClassic::authenticateWithKeyBManualAnswer(int result  ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicAuthenticateWithKeyBPtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicAuthenticateWithKeyBPtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyB>::ManualAnswer(m_EventTagMifareClassicAuthenticateWithKeyBPtr);
-}
-
-void NFCTagMifareClassic::readBlockManualAnswer(int result , std::vector<unsigned char> data ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicReadBlockPtr->setResult(TRUE);
-               m_EventTagMifareClassicReadBlockPtr->setBlockData(data);
-       } else {
-               m_EventTagMifareClassicReadBlockPtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicReadBlock>::ManualAnswer(m_EventTagMifareClassicReadBlockPtr);
-}
-
-void NFCTagMifareClassic::writeBlockManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicWriteBlockPtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicWriteBlockPtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicWriteBlock>::ManualAnswer(m_EventTagMifareClassicWriteBlockPtr);
-}
-
-void NFCTagMifareClassic::incrementBlockValueManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicIncrementBlockValuePtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicIncrementBlockValuePtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicIncrementBlockValue>::ManualAnswer(m_EventTagMifareClassicIncrementBlockValuePtr);
-}
-
-void NFCTagMifareClassic::decrementBlockValueManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicDecrementBlockValuePtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicDecrementBlockValuePtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicDecrementBlockValue>::ManualAnswer(m_EventTagMifareClassicDecrementBlockValuePtr);
-}
-
-void NFCTagMifareClassic::transferManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicTransferPtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicTransferPtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicTransfer>::ManualAnswer(m_EventTagMifareClassicTransferPtr);
-}
-
-void NFCTagMifareClassic::restoreManualAnswer(int result ) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareClassicRestorePtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareClassicRestorePtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareClassicRestore>::ManualAnswer(m_EventTagMifareClassicRestorePtr);
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyAPtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicAuthenticateWithKeyAPtr = event;
-               NFCUtil Util;
-
-               if( nfc_mifare_authenticate_with_keyA(handle, event->getSectorIndex(), Util.toCharPtr(event->getKey()), MifareClassicAuthenticateWithKeyACallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyA>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyBPtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicAuthenticateWithKeyBPtr = event;
-               NFCUtil Util;
-               if( nfc_mifare_authenticate_with_keyB(handle, event->getSectorIndex(), Util.toCharPtr(event->getKey()),  MifareClassicAuthenticateWithKeyBCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicAuthenticateWithKeyB>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicReadBlockPtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicReadBlockPtr = event;
-
-               if( nfc_mifare_read_block(handle, event->getIndex(), MifareClassicReadBlockCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicReadBlock>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicWriteBlockPtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicWriteBlockPtr = event;
-
-               NFCUtil Util;
-               std::vector<unsigned char> data = event->getBlockData();
-               if( nfc_mifare_write_block(handle, event->getIndex(), Util.toCharPtr(data), data.size(), MifareClassicWriteBlockCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicWriteBlock>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicIncrementBlockValuePtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicIncrementBlockValuePtr = event;
-
-               if( nfc_mifare_increment(handle, event->getIndex(), event->getValue(), MifareClassicIncrementBlockValueCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicIncrementBlockValue>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicDecrementBlockValuePtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicDecrementBlockValuePtr = event;
-
-               NFCUtil Util;
-               if( nfc_mifare_decrement(handle, event->getIndex(), event->getValue(), MifareClassicDecrementBlockValueCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicDecrementBlockValue>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicTransferPtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicTransferPtr = event;
-
-               if( nfc_mifare_transfer(handle, event->getIndex(), MifareClassicTransferManualAnswerCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicTransfer>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareClassic::OnRequestReceived(const EventTagMifareClassicRestorePtr& event) {
-       try {
-               event->switchToManualAnswer();
-               
-               m_EventTagMifareClassicRestorePtr = event;
-
-               if( nfc_mifare_restore(handle, event->getIndex(), MifareClassicRestoreManualAnswerCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareClassicRestore>::ManualAnswer(event);
-       }
-       
-}
-
-}
-}
-}
diff --git a/src/platform/Tizen/NFC/NFCTagMifareClassic.h b/src/platform/Tizen/NFC/NFCTagMifareClassic.h
deleted file mode 100755 (executable)
index 114b77f..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-#ifndef _NFCTAGMIFARECLASSIC_H_
-#define _NFCTAGMIFARECLASSIC_H_
-
-#include <API/NFC/INFCTagMifareClassic.h>
-
-using namespace TizenApis::Api::NFC;
-
-namespace TizenApis {
-namespace Platform {
-namespace NFC {
-       
-class NFCTagMifareClassic : public INFCTagMifareClassic
-{
-       friend class  NFCFactory;
-    public:
-               NFCTagMifareClassic(void *tagHandle);
-       virtual  ~NFCTagMifareClassic();
-
-       virtual void authenticateWithKeyA(const EventTagMifareClassicAuthenticateWithKeyAPtr& event);
-       virtual void authenticateWithKeyB(const EventTagMifareClassicAuthenticateWithKeyBPtr& event);
-       virtual void readBlock(const EventTagMifareClassicReadBlockPtr& event);
-       virtual void writeBlock(const EventTagMifareClassicWriteBlockPtr& event);
-       virtual void incrementBlockValue(const EventTagMifareClassicIncrementBlockValuePtr& event);
-       virtual void decrementBlockValue(const EventTagMifareClassicDecrementBlockValuePtr& event);
-       virtual void transfer(const EventTagMifareClassicTransferPtr& event);
-       virtual void restore(const EventTagMifareClassicRestorePtr& event);
-       virtual void authenticateWithKeyAManualAnswer(int result);
-       virtual void authenticateWithKeyBManualAnswer(int result);
-       virtual void readBlockManualAnswer(int result , std::vector<unsigned char> data);
-       virtual void writeBlockManualAnswer(int result);
-       virtual void incrementBlockValueManualAnswer(int result);
-       virtual void decrementBlockValueManualAnswer(int result);
-       virtual void transferManualAnswer(int result);
-       virtual void restoreManualAnswer(int result);
-
-    protected:
-               virtual void OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyAPtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicAuthenticateWithKeyBPtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicReadBlockPtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicWriteBlockPtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicIncrementBlockValuePtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicDecrementBlockValuePtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicTransferPtr& event);
-               virtual void OnRequestReceived(const EventTagMifareClassicRestorePtr& event);
-    private:
-               EventTagMifareClassicAuthenticateWithKeyAPtr m_EventTagMifareClassicAuthenticateWithKeyAPtr;
-               EventTagMifareClassicAuthenticateWithKeyBPtr m_EventTagMifareClassicAuthenticateWithKeyBPtr;
-               EventTagMifareClassicReadBlockPtr m_EventTagMifareClassicReadBlockPtr;
-               EventTagMifareClassicWriteBlockPtr m_EventTagMifareClassicWriteBlockPtr;
-               EventTagMifareClassicIncrementBlockValuePtr m_EventTagMifareClassicIncrementBlockValuePtr;
-               EventTagMifareClassicDecrementBlockValuePtr m_EventTagMifareClassicDecrementBlockValuePtr;
-               EventTagMifareClassicTransferPtr m_EventTagMifareClassicTransferPtr;
-               EventTagMifareClassicRestorePtr m_EventTagMifareClassicRestorePtr;
-};
-
-}
-}
-}
-
-#endif /* _NFCTAGMIFARECLASSIC_H_ */
diff --git a/src/platform/Tizen/NFC/NFCTagMifareUltra.cpp b/src/platform/Tizen/NFC/NFCTagMifareUltra.cpp
deleted file mode 100755 (executable)
index 1054435..0000000
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-#include <dpl/log/log.h>
-
-#include <Commons/Exception.h>
-
-#include "NFCTagMifareUltra.h"
-#include "NFCUtil.h"
-#include <nfc.h>
-
-namespace TizenApis {
-namespace Platform {
-namespace NFC {
-
-using namespace Api::NFC;
-using namespace WrtDeviceApis;
-
-namespace
-{
-       /**
-       * Callback method called by platform as interval time.
-       * @param event_type Platform magnetic evet type
-       * @param event Platform sensor event data
-       * @param this_ User data pointer.
-       */
-       static void MifareUltraReadPageCallback(nfc_error_e result , unsigned char * buffer, int buffer_size,  void * data) {
-               LogDebug("Callback MifareUltraReadPageCallback.");
-               if (data) {
-                       NFCUtil Util;
-                       
-                       ((NFCTagMifareUltra *)data)->readPageManualAnswer((int)result , Util.toVector(buffer, buffer_size));
-               
-               } else {
-                       LogDebug("Error! MifareUltraReadPageCallback is Null.");
-               }               
-       }
-
-       static void MifareUltraWritePageCallback(nfc_error_e result , void * data) {
-               LogDebug("Callback MifareUltraWritePageCallback.");
-               if (data) {
-                       ((NFCTagMifareUltra *)data)->writePageManualAnswer((int)result);
-               } else {
-                       LogDebug("Error! MifareUltraAuthenticateWithKeyACallback is Null.");
-               }
-       }
-
-}//private namespace
-
-NFCTagMifareUltra::NFCTagMifareUltra(void *tagHandle)
-{
-       LogDebug("entered");
-       if (tagHandle == NULL)
-               ThrowMsg(Commons::PlatformException, "Tag Handler is Null Pointer.");
-       handle = (nfc_tag_h)tagHandle;
-}
-
-NFCTagMifareUltra::~NFCTagMifareUltra()
-{
-       LogDebug("entered");
-       handle = NULL;
-}
-
-void NFCTagMifareUltra::readPage(const EventTagMifareUltraReadPagePtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareUltraReadPage>::PostRequest(event);
-}
-
-void NFCTagMifareUltra::writePage(const EventTagMifareUltraWritePagePtr& event) {
-       LogDebug("Enter");
-       EventRequestReceiver<EventTagMifareUltraWritePage>::PostRequest(event);
-}
-
-void NFCTagMifareUltra::readPageManualAnswer(int result  , std::vector<unsigned char> data) 
-{
-       LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareUltraReadPagePtr->setResult(TRUE);
-               m_EventTagMifareUltraReadPagePtr->setReadPageResult(data);
-       } else {
-               m_EventTagMifareUltraReadPagePtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareUltraReadPage>::ManualAnswer(m_EventTagMifareUltraReadPagePtr);
-}
-
-void NFCTagMifareUltra::writePageManualAnswer(int result) 
-{
-       LogDebug("Enter result : " << result);
-
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTagMifareUltraWritePagePtr->setResult(TRUE);
-       } else {
-               m_EventTagMifareUltraWritePagePtr->setResult(FALSE);
-       }
-       EventRequestReceiver<EventTagMifareUltraWritePage>::ManualAnswer(m_EventTagMifareUltraWritePagePtr);
-}
-
-void NFCTagMifareUltra::OnRequestReceived(const EventTagMifareUltraReadPagePtr& event) {
-       LogDebug("EventTagMifareUltraReadPagePtr OnRequestReceived index : " << event->getIndex());
-       
-       try {
-               event->switchToManualAnswer();
-
-               m_EventTagMifareUltraReadPagePtr = event;
-
-               if( nfc_mifare_read_page(handle, event->getIndex(), MifareUltraReadPageCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareUltraReadPage>::ManualAnswer(event);
-       }
-       
-}
-
-void NFCTagMifareUltra::OnRequestReceived(const EventTagMifareUltraWritePagePtr& event) {
-       try {
-               event->switchToManualAnswer();
-
-               m_EventTagMifareUltraWritePagePtr = event;
-
-               NFCUtil Util;
-               std::vector<unsigned char> data = event->getPageForWriting();
-               if( nfc_mifare_write_page(handle, event->getIndex(), Util.toCharPtr(data), data.size(), MifareUltraWritePageCallback, this) != NFC_ERROR_NONE )
-               {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
-               }
-       }
-       catch (const Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
-               event->setResult(false);
-               
-               EventRequestReceiver<EventTagMifareUltraWritePage>::ManualAnswer(event);
-       }
-       
-}
-
-}
-}
-}
diff --git a/src/platform/Tizen/NFC/NFCTagMifareUltra.h b/src/platform/Tizen/NFC/NFCTagMifareUltra.h
deleted file mode 100755 (executable)
index 3b3c552..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-#ifndef _NFCTAGMIFAREULTRA_H_
-#define _NFCTAGMIFAREULTRA_H_
-
-#include <API/NFC/INFCTagMifareUltra.h>
-
-using namespace TizenApis::Api::NFC;
-
-namespace TizenApis {
-namespace Platform {
-namespace NFC {
-       
-class NFCTagMifareUltra : public INFCTagMifareUltra
-{
-       friend class  NFCFactory;
-    public:
-               NFCTagMifareUltra(void *tagHandle);
-       virtual  ~NFCTagMifareUltra();
-
-       virtual void readPage(const EventTagMifareUltraReadPagePtr& event);
-       virtual void writePage(const EventTagMifareUltraWritePagePtr& event);
-       virtual void readPageManualAnswer(int result , std::vector<unsigned char> data);
-       virtual void writePageManualAnswer(int result);
-
-    protected:
-               virtual void OnRequestReceived(const EventTagMifareUltraReadPagePtr& event);
-               virtual void OnRequestReceived(const EventTagMifareUltraWritePagePtr& event);
-    private:
-               EventTagMifareUltraReadPagePtr m_EventTagMifareUltraReadPagePtr;
-               EventTagMifareUltraWritePagePtr m_EventTagMifareUltraWritePagePtr;
-};
- }
-}
-}
-
-#endif /* _NFCTAGMIFAREULTRA_H_ */
index 5434aa0..f0e941b 100755 (executable)
@@ -61,7 +61,7 @@ namespace
        static void TargetSentCallback(nfc_error_e result, void *user_data) {
                LogDebug("Callback TargetSentCallback.");
                if (user_data) {
-                       ((NFCTarget *)user_data)->sendNDEFManualAnswer((unsigned int)result);
+                       ((NFCTarget *)user_data)->sendNDEFManualAnswer((unsigned int)result, user_data);
 
                } else {
                        LogDebug("Error! TargetSentCallback is Null.");
@@ -74,11 +74,12 @@ NFCTarget::NFCTarget(void *targetHandle)
        LogDebug("entered");
 
        if (targetHandle == NULL)
-               ThrowMsg(Commons::PlatformException, "Taretg Handler is Null Pointer.");
+               ThrowMsg(Commons::UnknownException, "Target Handler is Null Pointer.");
 
        handle = (nfc_p2p_target_h)targetHandle;
        LogDebug("handle:"<<targetHandle);
        m_isSetReceiveListenter = false;
+       m_EventTargetActionSendPtr.Reset();
 }
 
 NFCTarget::~NFCTarget()
@@ -99,15 +100,19 @@ void NFCTarget::setReceiveNDEFListener(const EventTargetActionReceiveEmitterPtr&
 
        m_emitter = event;
        m_isSetReceiveListenter = true;
-       if (nfc_p2p_set_data_received_cb (handle, TargetReceivedCallback, this) != NFC_ERROR_NONE) {
+
+       int result = nfc_p2p_set_data_received_cb(handle, TargetReceivedCallback, this);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE) {
                m_isSetReceiveListenter = false;
-               ThrowMsg(Commons::PlatformException, "Can't set Receive Ndef Listener");
+               Util.throwNFCException(result, "Can't set Receive Ndef Listener");
        }
 }
 
 void NFCTarget::receiveNdef(std::vector<unsigned char>messageData) {
        LogDebug("Enter");
-       if (m_isSetReceiveListenter == true) {
+       if ((m_isSetReceiveListenter == true) && (m_emitter.Get() != NULL)) {
                EventTargetActionReceivePtr event(new EventTargetActionReceive());
                event->setReadNdefResult(messageData);
                m_emitter->emit(event);
@@ -127,18 +132,36 @@ void NFCTarget::unsetReceiveNDEFListener() {
 
 void NFCTarget::sendNDEF(const EventTargetActionSendPtr& event) {
        LogDebug("Enter");
-       EventRequestReceiver<EventTargetActionSend>::PostRequest(event);
+       
+       if (m_EventTargetActionSendPtr.Get() != NULL)
+               m_EventTargetActionSends.push_back(event);
+       else
+               EventRequestReceiver<EventTargetActionSend>::PostRequest(event);
 }
 
-void NFCTarget::sendNDEFManualAnswer(unsigned int result) {
+void NFCTarget::sendNDEFManualAnswer(unsigned int result, void *user_data) {
        LogDebug("Enter");
-       if ((nfc_error_e)result == NFC_ERROR_NONE) {
-               m_EventTargetActionSendPtr->setResult(TRUE);
+       if (m_EventTargetActionSendPtr.Get() != NULL) {
+               if ((nfc_error_e)result == NFC_ERROR_NONE) {
+                       m_EventTargetActionSendPtr->setResult(TRUE);
 
-       } else {
-               m_EventTargetActionSendPtr->setResult(FALSE);
+               } else {
+                       NFCUtil Util;
+                       m_EventTargetActionSendPtr->setResult(FALSE);
+                       m_EventTargetActionSendPtr->setError(Util.getNFCErrorString(result));
+                       m_EventTargetActionSendPtr->setErrorMessage(Util.getNFCErrorMessage(result));
+               }
+               EventRequestReceiver<EventTargetActionSend>::ManualAnswer(m_EventTargetActionSendPtr);
+
+               m_EventTargetActionSendPtr.Reset();
+
+               if (m_EventTargetActionSends.size() > 0) {
+                       EventTargetActionSendPtr event = m_EventTargetActionSends.front();
+                       m_EventTargetActionSends.erase(m_EventTargetActionSends.begin());
+                       LogDebug("m_EventTargetActionSends is removed. (" << m_EventTargetActionSends.size() << ")");
+                       EventRequestReceiver<EventTargetActionSend>::PostRequest(event);
+               }
        }
-       EventRequestReceiver<EventTargetActionSend>::ManualAnswer(m_EventTargetActionSendPtr);
 }
 
 void NFCTarget::OnRequestReceived(const EventTargetActionSendPtr& event) {
@@ -146,15 +169,36 @@ void NFCTarget::OnRequestReceived(const EventTargetActionSendPtr& event) {
        try {
                event->switchToManualAnswer();
                m_EventTargetActionSendPtr = event;
+
                nfc_ndef_message_h message = (nfc_ndef_message_h)event->getMessageForSending();
-               if( nfc_p2p_send(handle, message, TargetSentCallback, this) != NFC_ERROR_NONE ) {
-                       ThrowMsg(Commons::UnknownException, "call back set error");
+               int result = nfc_p2p_send(handle, message, TargetSentCallback, this);
+
+               NFCUtil Util;
+               std::string error = Util.getNFCErrorString(result);
+               if (error != "") {
+                       event->setResult(false);
+                       event->setError(error);
+                       event->setErrorMessage(Util.getNFCErrorMessage(result));
+                       EventRequestReceiver<EventTargetActionSend>::ManualAnswer(event);
+                       m_EventTargetActionSendPtr.Reset();
+                       if (m_EventTargetActionSends.size() > 0) {
+                               EventTargetActionSendPtr event = m_EventTargetActionSends.front();
+                               m_EventTargetActionSends.erase(m_EventTargetActionSends.begin());
+                               LogDebug("m_EventTargetActionSends is removed. (" << m_EventTargetActionSends.size() << ")");
+                               EventRequestReceiver<EventTargetActionSend>::PostRequest(event);
+                       }
                }
        } catch (const Commons::Exception& ex) {
                LogError("Exception: " << ex.GetMessage());
                event->setResult(false);
-
                EventRequestReceiver<EventTargetActionSend>::ManualAnswer(event);
+               m_EventTargetActionSendPtr.Reset();
+               if (m_EventTargetActionSends.size() > 0) {
+                       EventTargetActionSendPtr event = m_EventTargetActionSends.front();
+                       m_EventTargetActionSends.erase(m_EventTargetActionSends.begin());
+                       LogDebug("m_EventTargetActionSends is removed. (" << m_EventTargetActionSends.size() << ")");
+                       EventRequestReceiver<EventTargetActionSend>::PostRequest(event);
+               }
        }
 }
 
index 1d1e9d4..95164b6 100755 (executable)
@@ -32,21 +32,21 @@ class NFCTarget : public INFCTarget
 {
        friend class  NFCFactory;
     public:
-
                NFCTarget(void *tagHandle);
        virtual  ~NFCTarget();
 
        virtual void *getHandle();
        virtual void setReceiveNDEFListener(const EventTargetActionReceiveEmitterPtr& event);
-       virtual void receiveNdef(std::vector<unsigned char>messageData);
+       void receiveNdef(std::vector<unsigned char>messageData);
        virtual void unsetReceiveNDEFListener();
        virtual void sendNDEF(const EventTargetActionSendPtr& event);
-       virtual void sendNDEFManualAnswer(unsigned int result);
+       void sendNDEFManualAnswer(unsigned int result, void *user_data);
     protected:
        nfc_p2p_target_h handle;
        EventTargetActionReceiveEmitterPtr m_emitter;
        bool m_isSetReceiveListenter;
        EventTargetActionSendPtr m_EventTargetActionSendPtr;
+       std::vector<EventTargetActionSendPtr> m_EventTargetActionSends;
        virtual void OnRequestReceived(const EventTargetActionSendPtr& event);
 };
 
index e8f834d..4d07737 100755 (executable)
@@ -17,6 +17,7 @@
 
 
 #include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenException.h>
 
 #include "NFCUtil.h"
 #include <dpl/log/log.h>
@@ -53,17 +54,22 @@ unsigned char *NFCUtil::toCharPtr(std::vector<unsigned char> vec) {
        return NULL;
 }
 
-char *NFCUtil::byteToString(std::vector<unsigned char> buffer){
-       static char localbuffer[255];
-       memset(localbuffer, 0, 255);
-       memcpy(localbuffer, toCharPtr(buffer), buffer.size());
+char *NFCUtil::byteToString(std::vector<unsigned char> *buffer){
+       static char localbuffer[256];
+       memset(localbuffer, 0, 256);
+       memcpy(localbuffer, toCharPtr(*buffer), buffer->size() > 255 ? 255 : buffer->size());
+       if (buffer->size() > 255)
+               LogDebug("size is " << buffer->size() << ". Too Big! It will copy some of data(255 bytes)");
        return localbuffer;     
 }
 
 char *NFCUtil::byteToString(const unsigned char* buffer, const int size){
-       static char localbuffer[255];
-       memset(localbuffer, 0, 255);
-       memcpy(localbuffer, buffer, size);
+       if (size > 255)
+               LogDebug("size is " << size << ". Too Big! It will copy some of data(255 bytes)");
+
+       static char localbuffer[256];
+       memset(localbuffer, 0, 256);
+       memcpy(localbuffer, buffer, size > 255 ? 255 : size);
        return localbuffer;     
 }
 
@@ -144,6 +150,129 @@ nfcTNF NFCUtil::convertTonfcTNF(unsigned short tnf) {
                        return NFC_TNF_EMPTY;
        }
 }
+NdefRecordData NFCUtil::getNDEFRecordData(void *handle) {
+       nfc_ndef_record_h recordHandle = static_cast<nfc_ndef_record_h>(handle);
+
+       NdefRecordData recordData;
+
+       nfc_record_tnf_e tnf;
+       unsigned char *typeName, *id, *payload;
+       int typeSize, idSize, payloadSize;
+
+       int result = nfc_ndef_record_get_tnf(recordHandle, &tnf);
+       throwNFCException(result, "Can't get record's tnf");
+
+       result = nfc_ndef_record_get_type(recordHandle, &typeName, &typeSize);
+       throwNFCException(result, "Can't get record's type");
+
+       result = nfc_ndef_record_get_id(recordHandle, &id, &idSize);
+       throwNFCException(result, "Can't get record's id");
+
+       result = nfc_ndef_record_get_payload(recordHandle, &payload, &payloadSize);
+       throwNFCException(result, "Can't get record's payload");
+
+       LogDebug("tnf : " <<tnf);
+       LogDebug("typeName : " << byteToString(typeName, typeSize));
+       LogDebug("payload : " << byteToString(payload, payloadSize));
+
+       recordData.properties.tnf = convertTonfcTNF(static_cast<unsigned short>(tnf));
+       recordData.properties.typeName = toVector(typeName, typeSize);
+       recordData.properties.id = toVector(id, idSize);
+       recordData.payload = toVector(payload, payloadSize);
+
+       return recordData;
+}
+
+bool NFCUtil::copyNDEFRecord(void **src, void **dest) {
+       nfc_ndef_record_h *srcHandle, *destHandle;
+       srcHandle = (nfc_ndef_record_h *)src;
+       destHandle = (nfc_ndef_record_h *)dest;
+
+       NdefRecordData recordData = getNDEFRecordData(*srcHandle);
+
+
+       if (nfc_ndef_record_create(destHandle, static_cast<nfc_record_tnf_e>(convertToTNF(recordData.properties.tnf)), toCharPtr(recordData.properties.typeName), recordData.properties.typeName.size(),
+               toCharPtr(recordData.properties.id), recordData.properties.id.size(), toCharPtr(recordData.payload), recordData.payload.size()) != NFC_ERROR_NONE)
+               return false;
+
+       return true;
+}
+std::string NFCUtil::getNFCErrorString(const int errorCode) {
+       LogDebug ("Errorcode : " << errorCode);
+       switch(errorCode) {
+               case NFC_ERROR_NONE:
+                       return "";
+               case NFC_ERROR_INVALID_PARAMETER:
+               case NFC_ERROR_INVALID_NDEF_MESSAGE:
+               case NFC_ERROR_INVALID_RECORD_TYPE:
+                       return Commons::JSTizenException::INVALID_VALUES_ERROR;
+               case NFC_ERROR_NO_DEVICE:
+               case NFC_ERROR_OUT_OF_MEMORY:
+               case NFC_ERROR_OPERATION_FAILED:
+               case NFC_ERROR_DEVICE_BUSY:
+                       return Commons::JSTizenException::UNKNOWN_ERROR;
+               case NFC_ERROR_NOT_ACTIVATED:
+                       return Commons::JSTizenException::SERVICE_NOT_AVAILABLE;
+               case NFC_ERROR_NOT_SUPPORTED:
+                       return Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+               case NFC_ERROR_TIMED_OUT:
+                       return Commons::JSTizenException::TIMEOUT_ERROR;
+       }
+       return Commons::JSTizenException::UNKNOWN_ERROR;
+}
+
+std::string NFCUtil::getNFCErrorMessage(const int errorCode) {
+       LogDebug ("Errorcode : " << errorCode);
+       switch(errorCode) {
+               case NFC_ERROR_NONE:
+                       return "";
+               case NFC_ERROR_INVALID_PARAMETER:
+                       return "Invalid Parameter";
+               case NFC_ERROR_INVALID_NDEF_MESSAGE:
+                       return "Invalid NDEF Message";
+               case NFC_ERROR_INVALID_RECORD_TYPE:
+                       return "Invalid Record Type";
+               case NFC_ERROR_NO_DEVICE:
+                       return "No Device";
+               case NFC_ERROR_OUT_OF_MEMORY:
+                       return "Out Of Memory";
+               case NFC_ERROR_NOT_SUPPORTED:
+                       return "NFC Not Supported";
+               case NFC_ERROR_OPERATION_FAILED:
+                       return "Operation Failed";
+               case NFC_ERROR_DEVICE_BUSY:
+                       return "Device Busy";
+               case NFC_ERROR_NOT_ACTIVATED:
+                       return "NFC Not Activated";
+               case NFC_ERROR_TIMED_OUT:
+                       return "Time Out";
+       }
+       return "UnknownError";
+}
+
+void NFCUtil::throwNFCException(const int errorCode, const std::string &message) {
+       LogDebug ("Errorcode : " << static_cast<unsigned int>(errorCode));
+       LogDebug ("Message : " << message);
+
+       switch(errorCode) {
+               case NFC_ERROR_INVALID_PARAMETER:
+               case NFC_ERROR_INVALID_NDEF_MESSAGE:
+               case NFC_ERROR_INVALID_RECORD_TYPE:
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, message);
+                       break;
+               case NFC_ERROR_NOT_SUPPORTED:
+               case NFC_ERROR_OPERATION_FAILED:
+               case NFC_ERROR_DEVICE_BUSY:
+               case NFC_ERROR_NO_DEVICE:
+               case NFC_ERROR_TIMED_OUT:
+               case NFC_ERROR_OUT_OF_MEMORY:
+                       ThrowMsg(WrtDeviceApis::Commons::UnknownException, message);
+                       break;
+               case NFC_ERROR_NOT_ACTIVATED:
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, message);
+                       break;
+       }
+}
 
 }
 }
index 296bfea..dc77449 100755 (executable)
@@ -38,11 +38,15 @@ class NFCUtil
        std::vector<unsigned char> toVector(const unsigned char *ch, const int size);
        unsigned char *toCharPtr(std::vector<unsigned char> vec) ;
        char *byteToString(const unsigned char* buffer, const int size);
-       char *byteToString(std::vector<unsigned char> buffer);
+       char *byteToString(std::vector<unsigned char> *buffer);
        nfcTagType convertTonfcTagType(const unsigned short type);
        unsigned short convertToTNF(nfcTNF tnf);
        nfcTNF convertTonfcTNF(unsigned short tnf);
-
+       NdefRecordData getNDEFRecordData(void *handle);
+       bool copyNDEFRecord(void **src, void **dest);
+       std::string getNFCErrorString(const int errorCode);
+       std::string getNFCErrorMessage(const int errorCode);
+       void throwNFCException(const int errorCode, const std::string &message);
 };
 
 }
index 424c967..0702375 100755 (executable)
@@ -32,9 +32,12 @@ using namespace WrtDeviceApis::Commons;
 NdefMessage::NdefMessage()
 {
        LogDebug("entered");
-       if (nfc_ndef_message_create(&handle) != NFC_ERROR_NONE) {
+       NFCUtil Util;
+       int result = nfc_ndef_message_create(&handle);
+
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Message");
+               Util.throwNFCException(result, "Can't create Ndef Message");
        }
 }
 
@@ -44,7 +47,7 @@ NdefMessage::NdefMessage(void *messageHandle)
 
        if (messageHandle == NULL) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Message Handler is Null Pointer.");
+               ThrowMsg(UnknownException, "Message Handler is Null Pointer.");
        }
 
        handle = static_cast<nfc_ndef_message_h>(messageHandle);
@@ -63,10 +66,12 @@ NdefMessage::NdefMessage(const std::vector<unsigned char> rawdata)
 
        NFCUtil Util;
        unsigned char *Urawdata = Util.toCharPtr(rawdata);
-       if (nfc_ndef_message_create_from_rawdata(&handle, Urawdata, rawdata.size()) != NFC_ERROR_NONE) {
+       int result = nfc_ndef_message_create_from_rawdata(&handle, Urawdata, rawdata.size());
+
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
                free(Urawdata);
-               ThrowMsg(PlatformException, "Can't create Ndef Message");
+               Util.throwNFCException(result, "Can't create Ndef Message");
        }
 
        free(Urawdata);
@@ -79,65 +84,54 @@ NdefMessage::~NdefMessage()
                nfc_ndef_message_destroy(handle);
 }
 
-void NdefMessage::_makeMessage(const std::vector<void *> ndefRcords) {
-       if (nfc_ndef_message_create(&handle) != NFC_ERROR_NONE) {
+void NdefMessage::_makeMessage(std::vector<void *> ndefRcords) {
+       NFCUtil Util;
+       int result = nfc_ndef_message_create(&handle);
+
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Message");
+               Util.throwNFCException(result, "Can't create Ndef Message");
        }
 
        for (int i = 0 ; i < static_cast<int>(ndefRcords.size()); i++) {
                nfc_ndef_record_h insertRecord;
-       
-               if (!_copyNDEFRecord((nfc_ndef_record_h*)&ndefRcords[i], &insertRecord)) {
+
+               if (!Util.copyNDEFRecord(&ndefRcords[i], (void **)(&insertRecord))) {
                        LogDebug("copyNDEFRecord fail!");
-                       ThrowMsg(PlatformException, "Can't copy Record");
+                       ThrowMsg(UnknownException, "Can't copy Record");
                }
 
-               if (nfc_ndef_message_append_record(handle, insertRecord) != NFC_ERROR_NONE) {
+               result = nfc_ndef_message_append_record(handle, insertRecord);
+
+               if (result != NFC_ERROR_NONE) {
                        LogError(i << " record can't be inserted. " << insertRecord << " : " << handle);
-                       ThrowMsg(PlatformException, "Can't insert record in Ndef Message");
+                       Util.throwNFCException(result, "Can't insert record in Ndef Message");
                }
        }
 }
 
-bool NdefMessage::_copyNDEFRecord(nfc_ndef_record_h *srcHandle, nfc_ndef_record_h *destHandle) {
-       nfc_record_tnf_e tnf;
-       unsigned char *typeName, *id, *payload;
-       int typeSize, idSize, payloadSize;
-
-       if (nfc_ndef_record_get_tnf(*srcHandle, &tnf) != NFC_ERROR_NONE)
-               return false;
-
-       if (nfc_ndef_record_get_type(*srcHandle, &typeName, &typeSize) != NFC_ERROR_NONE)
-               return false;
-
-       if (nfc_ndef_record_get_id(*srcHandle, &id, &idSize) != NFC_ERROR_NONE)
-               return false;
-
-       if (nfc_ndef_record_get_payload(*srcHandle, &payload, &payloadSize) != NFC_ERROR_NONE)
-               return false;
-
-       if (nfc_ndef_record_create(destHandle, tnf, typeName, typeSize, id, idSize, payload, payloadSize) != NFC_ERROR_NONE)
-               return false;
-
-       return true;
-}
-
 void *NdefMessage::getHandle() {
        return (void *)handle;
 }
 
 void *NdefMessage::getRecordHandle(const long index) {
        nfc_ndef_record_h recordHandle;
-       if (nfc_ndef_message_get_record(handle, static_cast<int>(index), &recordHandle) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get Ndef Record");   
+       int result = nfc_ndef_message_get_record(handle, static_cast<int>(index), &recordHandle);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get Ndef Record");
+
        return (void *)recordHandle;
 }
 
 long NdefMessage::getRecordCount() {
        int count;
-       if (nfc_ndef_message_get_record_count(handle, &count) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get Record Count");
+       int result = nfc_ndef_message_get_record_count(handle, &count);
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get Record Count");
 
        LogDebug("record Count : " << count);
        return static_cast<long>(count);
@@ -146,85 +140,78 @@ long NdefMessage::getRecordCount() {
 std::vector<unsigned char> NdefMessage::toByte() {
        unsigned char *UrawData;
        int size;
+       NFCUtil Util;
+
+       if (getRecordCount() == 0)
+               return Util.toVector(NULL, 0);
+
+       int result = nfc_ndef_message_get_rawdata(handle, &UrawData, &size);
 
-       if (nfc_ndef_message_get_rawdata(handle, &UrawData, &size) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get serial bytes of NDEF message");
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get serial bytes of NDEF message");
 
        LogDebug(UrawData);
-       NFCUtil Util;
        return Util.toVector(UrawData, size);
 }
 
 NdefRecordData NdefMessage::getNDEFRecord(const long index) {
        nfc_ndef_record_h recordHandle;
-       if (nfc_ndef_message_get_record(handle, static_cast<int>(index), &recordHandle) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get Ndef Record");
-
-       NdefRecordData recordData;
+       int result = nfc_ndef_message_get_record(handle, static_cast<int>(index), &recordHandle);
 
-       nfc_record_tnf_e tnf;
-       unsigned char *typeName, *id, *payload;
-       int typeSize, idSize, payloadSize;
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get Ndef Record");
 
-       if (nfc_ndef_record_get_tnf(recordHandle, &tnf) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's tnf");
-
-       if (nfc_ndef_record_get_type(recordHandle, &typeName, &typeSize) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's type");
-
-       if (nfc_ndef_record_get_id(recordHandle, &id, &idSize) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's id");
-
-       if (nfc_ndef_record_get_payload(recordHandle, &payload, &payloadSize) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's payload");
-
-       LogDebug("tnf : " <<tnf);
-       LogDebug("typeName : " << Util.byteToString(typeName, typeSize));
-       LogDebug("payload : " << Util.byteToString(payload, payloadSize));
-
-       recordData.properties.tnf = Util.convertTonfcTNF(static_cast<unsigned short>(tnf));
-       recordData.properties.typeName = Util.toVector(typeName, typeSize);
-       recordData.properties.id = Util.toVector(id, idSize);
-       recordData.payload = Util.toVector(payload, payloadSize);
+       NdefRecordData recordData;
 
-       return recordData;
+       return Util.getNDEFRecordData(recordHandle);
 }
 
-bool NdefMessage::insertNDEFRecord(const long index, const void *recordHandle) {
+bool NdefMessage::insertNDEFRecord(const long index, void *recordHandle) {
        nfc_ndef_record_h insertRecord;
-       if (!_copyNDEFRecord((nfc_ndef_record_h *)&recordHandle, &insertRecord)) {
+
+       NFCUtil Util;
+       if (!Util.copyNDEFRecord(&recordHandle, (void **)(&insertRecord))) {
                LogDebug("copyNDEFRecord fail!");
-               ThrowMsg(PlatformException, "Can't copy Record");
+               ThrowMsg(UnknownException, "Can't copy Record");
        }
 
-       if (nfc_ndef_message_insert_record(handle, static_cast<int>(index), insertRecord) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't insert ndef Record");
+       int result = nfc_ndef_message_insert_record(handle, static_cast<int>(index), insertRecord);
+
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't insert ndef Record");
 
        return TRUE;
 }
 
-bool NdefMessage::appendNDEFRecord(const void *recordHandle) {
+bool NdefMessage::appendNDEFRecord(void *recordHandle) {
        nfc_ndef_record_h appendRecord;
-       if (!_copyNDEFRecord((nfc_ndef_record_h *)&recordHandle, &appendRecord)) {
+
+       NFCUtil Util;
+       if (!Util.copyNDEFRecord(&recordHandle, (void **)(&appendRecord))) {
                LogDebug("copyNDEFRecord fail!");
-               ThrowMsg(PlatformException, "Can't copy Record");
+               ThrowMsg(UnknownException, "Can't copy Record");
        }
 
-       if (nfc_ndef_message_append_record(handle, appendRecord) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't append ndef Record");
+       int result = nfc_ndef_message_append_record(handle, appendRecord);
+
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't insert ndef Record");
 
        return TRUE;
 }
 
 bool NdefMessage::removeNDEFRecord(const long index) {
-       if (nfc_ndef_message_remove_record(handle, static_cast<int>(index)) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't remove ndef Record");
+       int result = nfc_ndef_message_remove_record(handle, static_cast<int>(index));
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't remove ndef Record");
 
        return TRUE;
 }
 
-void NdefMessage::changeAllRecords(const std::vector<void *> ndefRcords) {
+void NdefMessage::changeAllRecords(std::vector<void *> ndefRcords) {
        nfc_ndef_message_h newHandle = handle;
        handle = NULL;
 
index 39aa94f..78d9cae 100755 (executable)
@@ -43,13 +43,12 @@ class NdefMessage : public INdefMessage
        virtual std::vector<unsigned char> toByte();
        virtual long getRecordCount();
        virtual NdefRecordData getNDEFRecord(const long index);
-       virtual bool insertNDEFRecord(const long index, const void *recordHandle);
-       virtual bool appendNDEFRecord(const void *recordHandle);
+       virtual bool insertNDEFRecord(const long index, void *recordHandle);
+       virtual bool appendNDEFRecord( void *recordHandle);
        virtual bool removeNDEFRecord(const long index);
-       virtual void changeAllRecords(const std::vector<void *> ndefRcords);
+       virtual void changeAllRecords(std::vector<void *> ndefRcords);
     private:
        nfc_ndef_message_h handle;
-       bool _copyNDEFRecord(nfc_ndef_record_h *srcHandle, nfc_ndef_record_h *destHandle);
        void _makeMessage(const std::vector<void *> ndefRcords);
 };
 
index 9097886..70741c6 100755 (executable)
@@ -35,6 +35,47 @@ NdefRecord::NdefRecord()
        handle = NULL;
 }
 
+NdefRecord::NdefRecord(std::vector<unsigned char> data)
+{
+       LogDebug("entered");
+
+       nfc_ndef_message_h messageHandle;
+       NFCUtil Util;
+       unsigned char *Urawdata = Util.toCharPtr(data);
+       int result = nfc_ndef_message_create_from_rawdata(&messageHandle, Urawdata, data.size());
+
+       if (result != NFC_ERROR_NONE) {
+               messageHandle = NULL;
+               free(Urawdata);
+               Util.throwNFCException(result, "Can't create Ndef Record");
+       }
+
+       int count;
+       result = nfc_ndef_message_get_record_count(messageHandle, &count);
+       if ((result != NFC_ERROR_NONE) || (count != 1)) {
+               nfc_ndef_message_destroy(messageHandle);
+               messageHandle = NULL;
+               free(Urawdata);
+               Util.throwNFCException(result, "Can't create Ndef Record");
+       }
+
+       nfc_ndef_record_h recordHandle;
+       result = nfc_ndef_message_get_record(messageHandle, 0, &recordHandle);
+       if (result != NFC_ERROR_NONE) {
+               nfc_ndef_message_destroy(messageHandle);
+               messageHandle = NULL;
+               free(Urawdata);
+               Util.throwNFCException(result, "Can't create Ndef Record");
+       }
+
+       if (!Util.copyNDEFRecord((void **)&recordHandle, (void **)&handle)) {
+               ThrowMsg(UnknownException, "Can't copy Ndef Record");
+       }
+
+       nfc_ndef_message_destroy(messageHandle);
+       free(Urawdata);
+}
+
 NdefRecord::NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload)
 {
        LogDebug("entered");
@@ -55,7 +96,7 @@ NdefRecord::NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::ve
 
        if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Record");
+               Util.throwNFCException(result, "Can't create Ndef Record");
        }
 }
 
@@ -63,19 +104,25 @@ NdefRecord::NdefRecord(const std::string &text, const std::string &langCode, con
 {
        LogDebug("entered");
 
-       if (nfc_ndef_record_create_text(&handle, text.c_str(), langCode.c_str(), _convertToEncodeType(static_cast<nfcTextEncodeUTF>(encodeType))) != NFC_ERROR_NONE) {
+       int result = nfc_ndef_record_create_text(&handle, text.c_str(), langCode.c_str(), _convertToEncodeType(static_cast<nfcTextEncodeUTF>(encodeType)));
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Text Record");
-       }       
+               Util.throwNFCException(result, "Can't create Ndef Text Record");
+       }
 }
 
 NdefRecord::NdefRecord(const std::string &uri)
 {
        LogDebug("entered");
 
-       if (nfc_ndef_record_create_uri(&handle, uri.c_str()) != NFC_ERROR_NONE) {
+       int result = nfc_ndef_record_create_uri(&handle, uri.c_str());
+
+       NFCUtil Util;
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Uri Record");
+               Util.throwNFCException(result, "Can't create Ndef Uri Record");
        }
 }
 
@@ -85,9 +132,11 @@ NdefRecord::NdefRecord(const std::string &mimeType, const std::vector<unsigned c
 
        NFCUtil Util;
 
-       if (nfc_ndef_record_create_mime(&handle, mimeType.c_str(), Util.toCharPtr(data),static_cast<int>(data.size())) != NFC_ERROR_NONE) {
+       int result = nfc_ndef_record_create_mime(&handle, mimeType.c_str(), Util.toCharPtr(data),static_cast<int>(data.size()));
+
+       if (result != NFC_ERROR_NONE) {
                handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Mime Record");
+               Util.throwNFCException(result, "Can't create Ndef Mime Record");
        }
 }
 
@@ -129,39 +178,43 @@ NdefRecordProperties NdefRecord::getNDEFRecordProperties() {
        LogDebug("tnf : " << props.tnf);
        props.typeName = getTypeName();
        props.id = getID();
-       LogDebug("typeName : " << Util.byteToString(props.typeName));
+       LogDebug("typeName : " << Util.byteToString(&props.typeName));
 
        return props;
 }
 
 nfcTNF NdefRecord::getTNF() {
        nfc_record_tnf_e tnf;
-       if (nfc_ndef_record_get_tnf(handle, &tnf) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's tnf");
+       int result = nfc_ndef_record_get_tnf(handle, &tnf);
 
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get record's tnf");
+
        return Util.convertTonfcTNF(static_cast<unsigned short>(tnf));
 }
 
 std::vector<unsigned char> NdefRecord::getTypeName() {
        unsigned char *typeName;
        int typeSize;
-
-       if (nfc_ndef_record_get_type(handle, &typeName, &typeSize) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's type");
+       int result = nfc_ndef_record_get_type(handle, &typeName, &typeSize);
 
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get record's type");
+
        return Util.toVector(typeName, typeSize);
 }
 
 std::vector<unsigned char> NdefRecord::getID() {
        unsigned char *id;
        int idSize;
-
-       if (nfc_ndef_record_get_id(handle, &id, &idSize) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's id");
+       int result = nfc_ndef_record_get_id(handle, &id, &idSize);
 
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get record's id");
+
        return Util.toVector(id, idSize);
 }
 
@@ -171,8 +224,10 @@ bool NdefRecord::getText(char **text) {
        int result = nfc_ndef_record_get_text(handle, text);
        if (result == NFC_ERROR_INVALID_RECORD_TYPE)
                return false;
+
+       NFCUtil Util;
        if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get text of record");
+               Util.throwNFCException(result, "Can't get text of record");
 
        LogDebug("text : " << *text);
        return true;
@@ -184,8 +239,10 @@ bool NdefRecord::getLangCode(char **landCode) {
        int result = nfc_ndef_record_get_langcode(handle, landCode);
        if (result == NFC_ERROR_INVALID_RECORD_TYPE)
                return false;
+
+       NFCUtil Util;
        if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get langcode of record");
+               Util.throwNFCException(result, "Can't get langcode of record");
 
        LogDebug("landCode : " << *landCode);
        return true;
@@ -197,8 +254,10 @@ bool NdefRecord::getEncodeType(nfcTextEncodeUTF *encodeType) {
        int result = nfc_ndef_record_get_encode_type(handle, &type);
        if (result == NFC_ERROR_INVALID_RECORD_TYPE)
                return false;
+
+       NFCUtil Util;
        if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get encode type of record");
+               Util.throwNFCException(result, "Can't get encode type of record");
 
        *encodeType = _convertToNfcEncodeType(type);
        LogDebug("encodeType : " << *encodeType);
@@ -210,8 +269,10 @@ bool NdefRecord::getUri(char **uri) {
        int result = nfc_ndef_record_get_uri(handle, uri);
        if (result == NFC_ERROR_INVALID_RECORD_TYPE)
                return false;
+
+       NFCUtil Util;
        if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get uri of record");
+               Util.throwNFCException(result, "Can't get uri of record");
 
        LogDebug("uri : " << *uri);
        return true;
@@ -222,8 +283,10 @@ bool NdefRecord::getMimeType(char **mimeType) {
        int result = nfc_ndef_record_get_mime_type(handle, mimeType);
        if (result == NFC_ERROR_INVALID_RECORD_TYPE)
                return false;
+
+       NFCUtil Util;
        if (result != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get text of record");
+               Util.throwNFCException(result, "Can't get mime type of record");
 
        LogDebug("mimeType : " << *mimeType);
        return true;
@@ -232,15 +295,64 @@ std::vector<unsigned char> NdefRecord::getPayload() {
        LogDebug("entered");
        int size;
        unsigned char *recordbuffer;
-
-       if (nfc_ndef_record_get_payload(handle, &recordbuffer, &size) != NFC_ERROR_NONE)
-               ThrowMsg(PlatformException, "Can't get record's payload");
+       int result = nfc_ndef_record_get_payload(handle, &recordbuffer, &size);
 
        NFCUtil Util;
+       if (result != NFC_ERROR_NONE)
+               Util.throwNFCException(result, "Can't get record's payload");
+
        LogDebug("payload : " << Util.byteToString(recordbuffer, size));
        return Util.toVector(recordbuffer, size);
 }
 
+std::vector<unsigned char> NdefRecord::toByte() {
+       LogDebug("entered");
+
+       nfc_ndef_record_h copy_record;
+       nfc_ndef_message_h temp_message;
+       NFCUtil Util;
+
+       if (!Util.copyNDEFRecord((void **)&handle, (void **)(&copy_record))) {
+               ThrowMsg(UnknownException, "Can't copy Ndef Record");
+       }
+
+       int result = nfc_ndef_message_create(&temp_message);
+
+       if (result != NFC_ERROR_NONE) {
+               if (copy_record != NULL)
+                       nfc_ndef_record_destroy(copy_record);
+               Util.throwNFCException(result, "Can't create Ndef Message");
+       }
+
+       result = nfc_ndef_message_append_record(temp_message, copy_record);
+       if (result != NFC_ERROR_NONE) {
+               if (temp_message != NULL)
+                       nfc_ndef_message_destroy(temp_message);
+               else if (copy_record != NULL)
+                       nfc_ndef_record_destroy(copy_record);
+               Util.throwNFCException(result, "Can't append ndef Record");
+       }
+
+       unsigned char *UrawData;
+       int size;
+
+       result = nfc_ndef_message_get_rawdata(temp_message, &UrawData, &size);
+       if (result != NFC_ERROR_NONE) {
+               if (temp_message != NULL)
+                       nfc_ndef_message_destroy(temp_message);
+               else if (copy_record != NULL)
+                       nfc_ndef_record_destroy(copy_record);
+               Util.throwNFCException(result, "Can't get serial bytes of NDEF message");
+       }
+
+       if (temp_message != NULL)
+               nfc_ndef_message_destroy(temp_message);
+       else if (copy_record != NULL)
+               nfc_ndef_record_destroy(copy_record);
+       
+       return Util.toVector(UrawData, size);
+}
+
 }
 }
 }
index f3f0481..126e068 100755 (executable)
@@ -35,6 +35,7 @@ class NdefRecord : public INdefRecord
     public:
                NdefRecord();
                NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
+               NdefRecord(std::vector<unsigned char> data);
                NdefRecord(const std::string &text, const std::string &langCode, const short encodeType);
                NdefRecord(const std::string &uri);
                NdefRecord(const std::string &mimeType, const std::vector<unsigned char> data);
@@ -45,6 +46,7 @@ class NdefRecord : public INdefRecord
        virtual std::vector<unsigned char> getTypeName();
        virtual std::vector<unsigned char> getID();
        virtual std::vector<unsigned char> getPayload();
+       virtual std::vector<unsigned char> toByte();
        virtual bool getText(char **text);
        virtual bool getLangCode(char **landCode);
        virtual bool getEncodeType(nfcTextEncodeUTF *encodeType);
index 4bc85b2..22da648 100755 (executable)
@@ -13,10 +13,8 @@ set(LIBS_PLATFORM_IMPLEMENTATION_NFC
 )
 
 set(SRCS_PLATFORM_IMPLEMENTATION_NFC
-  ${CURRENT_PATH}/NFCManager.cpp
+  ${CURRENT_PATH}/NFCAdapter.cpp
   ${CURRENT_PATH}/NFCTag.cpp
-  ${CURRENT_PATH}/NFCTagMifareClassic.cpp
-  ${CURRENT_PATH}/NFCTagMifareUltra.cpp
   ${CURRENT_PATH}/NdefMessage.cpp
   ${CURRENT_PATH}/NdefRecord.cpp
   ${CURRENT_PATH}/NFCTarget.cpp
index 5dfdeae..c57643b 100644 (file)
@@ -22,6 +22,8 @@
 #include <pcrecpp.h>
 #include <dpl/log/log.h>
 #include <network-cm-intf.h>
+#include <TapiCommon.h>
+#include <ITapiMisc.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/PrivateObject.h>
@@ -41,7 +43,7 @@ namespace {
 void PowerValueCallback(keynode_t *node, void *event_ptr)
 {
     if(event_ptr) {
-        ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TPYE_POWER);
+        ((Systeminfo*)event_ptr)->getWatchValue(WATCH_TYPE_POWER);
     }
 }
 
@@ -111,13 +113,12 @@ bool Systeminfo::isPropertyValid(JSContextRef context, JSValueRef property)
     Converter converter(context);
     
     std::string l_property = converter.toString(property);
+    LogDebug("l_property : " << l_property);
     mapProperties::iterator it = (*m_Property).find(l_property);
     if (it == (*m_Property).end()) {
-        LogError("not existing property");
-        Throw(InvalidArgumentException);        
+        Throw(InvalidArgumentException);
         return false;
     }
-
     return true;
 }
 
@@ -128,8 +129,9 @@ void Systeminfo::get(const EventGetSysteminfoPtr& event)
 
 void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
 {
-    if(event->getWatchType() == WATCH_TPYE_UNKNOWN) {
+    if(event->getWatchType() == WATCH_TYPE_UNKNOWN) {
         LogDebug("watch method is not supported");
+        event->setId(-1);
         return;
     }
 
@@ -139,45 +141,50 @@ void Systeminfo::watch(const EventWatchSysteminfoPtr& event)
     EventRequestReceiver<EventWatchSysteminfo>::PostRequest(event);
 }
 
-void Systeminfo::clearWatch(const int id)
+void Systeminfo::clearWatch(const long id)
 {
-    int watchType = m_EventMgrPtr->getWatchType(id);
-    switch(watchType) {
-        case WATCH_TPYE_POWER:
-            if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
-                vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback);
-                vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback);
-            }                
-            break;
-        case WATCH_TYPE_DISPLAY:
-            if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {                        
-                vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
-            }                
-            break;
-        case WATCH_TPYE_WIFINETWORK:
-            if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {                        
-                vconf_ignore_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback);
-            if (m_networkRegist == REGIST_WIFI) {
-                    vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
-                m_networkRegist = REGIST_NOT;
-            } else if (m_networkRegist== REGIST_ALL) {
-                m_networkRegist = REGIST_CELLULAR;
-            }            
-            }                
-            break;
-        case WATCH_TPYE_CELLULARNETWORK:
-            if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {                        
-            if (m_networkRegist == REGIST_CELLULAR) {
-                    vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
-                m_networkRegist = REGIST_NOT;
-            } else if (m_networkRegist== REGIST_ALL) {
-                m_networkRegist = REGIST_WIFI;
-            }            
-            }                
-            break;
+    if (id < 1) {
+        Throw(InvalidArgumentException);
+    } else {
+        int watchType = m_EventMgrPtr->getWatchType(id);
+        switch(watchType) {
+            case WATCH_TYPE_POWER:
+                if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
+                    vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback);
+                    vconf_ignore_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback);
+                }                
+                break;
+            case WATCH_TYPE_DISPLAY:
+                if ((m_EventMgrPtr->getEventDisplayList()).size() == 1) {                        
+                    vconf_ignore_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback);
+                }                
+                break;
+            case WATCH_TYPE_WIFINETWORK:
+                if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {                        
+                if (m_networkRegist == REGIST_WIFI) {
+                        vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
+                    m_networkRegist = REGIST_NOT;
+                } else if (m_networkRegist== REGIST_ALL) {
+                    m_networkRegist = REGIST_CELLULAR;
+                }            
+                }                
+                break;
+            case WATCH_TYPE_CELLULARNETWORK:
+                if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {                        
+                if (m_networkRegist == REGIST_CELLULAR) {
+                        vconf_ignore_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback);
+                    m_networkRegist = REGIST_NOT;
+                } else if (m_networkRegist== REGIST_ALL) {
+                    m_networkRegist = REGIST_WIFI;
+                }            
+                }                
+                break;
+            case WATCH_TYPE_UNKNOWN:
+                Throw(InvalidArgumentException);
+                break;
+        }
+        m_EventMgrPtr->removeEvent(id, watchType);    
     }
-
-    m_EventMgrPtr->removeEvent(id, watchType);
 }
 
 BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef property)
@@ -196,7 +203,7 @@ BasePropertyPtr Systeminfo::getBasePropertyPtr(JSContextRef context, JSValueRef
             
 void Systeminfo::getWatchValue(const int watchType)
 {
-    if (watchType == WATCH_TPYE_POWER) {
+    if (watchType == WATCH_TYPE_POWER) {
         EventPowerList eventList = m_EventMgrPtr->getEventPowerList();
         for (EventPowerList::iterator it = eventList.begin(); it != eventList.end(); it++) {
                 (*it)->getWatchValue();
@@ -235,7 +242,7 @@ void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
     event->setCancelAllowed(true);
 
     switch(event->getWatchType()) {
-        case WATCH_TPYE_POWER:
+        case WATCH_TYPE_POWER:
             if ((m_EventMgrPtr->getEventPowerList()).size() == 1) {
                 vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CAPACITY, PowerValueCallback, (void *)this);
                 vconf_notify_key_changed(VCONFKEY_SYSMAN_BATTERY_CHARGE_NOW, PowerValueCallback, (void *)this);
@@ -246,9 +253,8 @@ void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
                 vconf_notify_key_changed(VCONFKEY_SETAPPL_LCD_BRIGHTNESS, DisplayValueCallback, (void *)this);
             }                
             break;
-        case WATCH_TPYE_WIFINETWORK:
+        case WATCH_TYPE_WIFINETWORK:
             if ((m_EventMgrPtr->getEventWifiNetworkList()).size() == 1) {
-                vconf_notify_key_changed(VCONFKEY_WIFI_STRENGTH, NetworkValueCallback, (void *)this);
             if (m_networkRegist == REGIST_NOT) {
                     vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
                 m_networkRegist = REGIST_WIFI;
@@ -257,7 +263,7 @@ void Systeminfo::OnRequestReceived(const EventWatchSysteminfoPtr& event)
             }
             }                
             break;
-        case WATCH_TPYE_CELLULARNETWORK:
+        case WATCH_TYPE_CELLULARNETWORK:
             if ((m_EventMgrPtr->getEventCellularNetworkList()).size() == 1) {            
             if (m_networkRegist == REGIST_NOT) {
                     vconf_notify_key_changed(VCONFKEY_NETWORK_CONFIGURATION_CHANGE_IND, NetworkValueCallback, (void *)this);
@@ -319,16 +325,16 @@ void Systeminfo::EventMgr::addEvent(const EventWatchSysteminfoPtr& arg, const in
 {
     DPL::Mutex::ScopedLock lock(&m_synchro);
 
-    if (watchType == WATCH_TPYE_POWER) {
+    if (watchType == WATCH_TYPE_POWER) {
         m_eventPowerList.push_back(arg);
         LogDebug("Event power list size=" << m_eventPowerList.size());
     } else if (watchType == WATCH_TYPE_DISPLAY) {
         m_eventDisplayList.push_back(arg);
         LogDebug("Event display list size=" << m_eventDisplayList.size());
-    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+    } else if (watchType == WATCH_TYPE_WIFINETWORK) {
         m_eventWifiNetworkList.push_back(arg);
         LogDebug("Event wifi network list size=" << m_eventWifiNetworkList.size());
-    } else if (watchType == WATCH_TPYE_CELLULARNETWORK) {
+    } else if (watchType == WATCH_TYPE_CELLULARNETWORK) {
         m_eventCelluarNetworkList.push_back(arg);
         LogDebug("Event cellular network list size=" << m_eventCelluarNetworkList.size());
     }
@@ -343,7 +349,7 @@ void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
 
     LogDebug("trying to delete event, id=" << id);
 
-    if (watchType == WATCH_TPYE_POWER) {
+    if (watchType == WATCH_TYPE_POWER) {
         for (EventPowerList::iterator it = m_eventPowerList.begin(); it != m_eventPowerList.end(); it++) {
             if (id == (*it)->getId()) {
                 event = *it;
@@ -373,7 +379,7 @@ void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
         LogDebug("event display list size=" << m_eventDisplayList.size());
         m_eventDisplayList.remove(event);
         LogDebug( "event removed, event display list size=" << m_eventDisplayList.size());
-    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+    } else if (watchType == WATCH_TYPE_WIFINETWORK) {
         for (EventWifiNetworkList::iterator it = m_eventWifiNetworkList.begin(); it != m_eventWifiNetworkList.end(); it++) {
         if (id == (*it)->getId()) {
             event = *it;
@@ -388,7 +394,7 @@ void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
         LogDebug("event wifi network list size=" << m_eventWifiNetworkList.size());
         m_eventWifiNetworkList.remove(event);
         LogDebug( "event removed, event wifi network list size=" << m_eventCelluarNetworkList.size());
-    } else if (watchType == WATCH_TPYE_WIFINETWORK) {
+    } else if (watchType == WATCH_TYPE_WIFINETWORK) {
         for (EventCellularNetworkList::iterator it = m_eventCelluarNetworkList.begin(); it != m_eventCelluarNetworkList.end(); it++) {
             if (id == (*it)->getId()) {
                 event = *it;
@@ -406,7 +412,7 @@ void Systeminfo::EventMgr::removeEvent(WatchId id, const int watchType)
     }
 }    
 
-const int Systeminfo::EventMgr::getWatchType(const int id)
+const int Systeminfo::EventMgr::getWatchType(const long id)
 {
     DPL::Mutex::ScopedLock lock(&m_synchro);
     
@@ -442,7 +448,7 @@ const int Systeminfo::EventMgr::getWatchType(const int id)
     
     if (!event) {
         LogError("event id not in the list, nothing to do");
-        return WATCH_TPYE_UNKNOWN;
+        return WATCH_TYPE_UNKNOWN;
     }
 
     return event->getWatchType();
@@ -573,7 +579,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Storage) {
                if (statfs(STORAGE_USBHOST_PATH, &fs) < 0)      {
                 return JSValueMakeNull(context);
                }
-            units[storageCnt].type = "USBHOST";
+            units[storageCnt].type = "USB_HOST";
                units[storageCnt].capacity = (unsigned long)(fs.f_bsize * fs.f_blocks);
                units[storageCnt].availableCapacity = (unsigned long)(fs.f_bsize * fs.f_bavail);
                units[storageCnt].isRemoveable = true;                    
@@ -634,13 +640,17 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(Display) {
 PROPERTY_GET_SYSTEMINFO_DEFINITION(Device) {
     Converter converter(context);
     DeviceProperties device;
+    
+    TelMiscSNIndexType_t type = TAPI_MISC_ME_IMEI;
+    TelMiscSNInformation sn;
 
-    char* value = NULL;
-    value = vconf_get_str(VCONFKEY_TELEPHONY_IMEI);
-    if (value == NULL) {
-        LogDebug("vconf_get_str failed");
-    } else {
-        device.imei = value;
+    memset(&sn, 0, sizeof(TelMiscSNInformation));
+    if(tel_init() == TAPI_API_SUCCESS) {
+        if(tel_get_misc_me_sn(type, &sn) == TAPI_API_SUCCESS) {
+            device.imei = (char *)sn.szNumber;
+        }
+        tel_deinit();
     }
 
     std::ifstream file("/usr/etc/info.ini");
@@ -685,12 +695,10 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(WifiNetwork) {
             memset(&ProfInfo, 0, sizeof(net_profile_info_t));
             if (net_get_active_net_info(&ProfInfo) == NET_ERR_NONE) {
                 if(ProfInfo.profile_type == NET_DEVICE_WIFI) {
+                    int wifiVal;
                     wifiNetwork.ssid = ProfInfo.ProfileInfo.Wlan.essid;
-                    if (vconf_get_int(VCONFKEY_WIFI_STRENGTH, &strength) != 0) {
-                        LogDebug("vconf_get_int failed");
-                    } else {
-                        wifiNetwork.signalStrength = (double)(strength/4);
-                    }
+                    wifiVal = ProfInfo.ProfileInfo.Wlan.Strength;
+                    wifiNetwork.signalStrength = (double)wifiVal/100;
                 }
             }
         } else {
@@ -753,7 +761,7 @@ PROPERTY_GET_SYSTEMINFO_DEFINITION(CellularNetwork) {
                     LogDebug("cellularNetwork.type : " << cellularNetwork.serviceType);
 
                     if (vconf_get_int(VCONFKEY_TELEPHONY_CELLID, &cellid) == 0) {
-                        cellularNetwork.cellid = cellid;
+                        cellularNetwork.cellId = cellid;
                     }
 
                     if (vconf_get_int(VCONFKEY_TELEPHONY_LAC, &lac) != 0) {
index 1eb5f48..deaa058 100644 (file)
@@ -42,11 +42,11 @@ namespace Platform {
 namespace Systeminfo {
 
 enum {
-    WATCH_TPYE_UNKNOWN = 0,
-    WATCH_TPYE_POWER = 1,
+    WATCH_TYPE_UNKNOWN = 0,
+    WATCH_TYPE_POWER = 1,
     WATCH_TYPE_DISPLAY = 2,
-    WATCH_TPYE_WIFINETWORK = 3,
-    WATCH_TPYE_CELLULARNETWORK = 4,
+    WATCH_TYPE_WIFINETWORK = 3,
+    WATCH_TYPE_CELLULARNETWORK = 4,
     WATCH_TYPE_NETWORK = 5
 };
 
@@ -78,13 +78,13 @@ typedef DPL::Atomic::ValueType WatchId;
 #define PROPERTY_GET_SYSTEMINFO_DEFINITION(className) JSValueRef className::getValue( \
         JSContextRef context) const
 
-PROPERTY_DECLARATION(Power, "Power", WATCH_TPYE_POWER)
-PROPERTY_DECLARATION(Cpu, "Cpu", WATCH_TPYE_UNKNOWN)
-PROPERTY_DECLARATION(Storage, "Storage", WATCH_TPYE_UNKNOWN)
+PROPERTY_DECLARATION(Power, "Power", WATCH_TYPE_POWER)
+PROPERTY_DECLARATION(Cpu, "Cpu", WATCH_TYPE_UNKNOWN)
+PROPERTY_DECLARATION(Storage, "Storage", WATCH_TYPE_UNKNOWN)
 PROPERTY_DECLARATION(Display, "Display", WATCH_TYPE_DISPLAY)
-PROPERTY_DECLARATION(Device, "Device", WATCH_TPYE_UNKNOWN)
-PROPERTY_DECLARATION(WifiNetwork, "WifiNetwork", WATCH_TPYE_WIFINETWORK)
-PROPERTY_DECLARATION(CellularNetwork, "CellularNetwork", WATCH_TPYE_CELLULARNETWORK)
+PROPERTY_DECLARATION(Device, "Device", WATCH_TYPE_UNKNOWN)
+PROPERTY_DECLARATION(WifiNetwork, "WifiNetwork", WATCH_TYPE_WIFINETWORK)
+PROPERTY_DECLARATION(CellularNetwork, "CellularNetwork", WATCH_TYPE_CELLULARNETWORK)
 
 typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventPowerList;
 typedef std::list<Api::Systeminfo::EventWatchSysteminfoPtr> EventDisplayList;
@@ -103,7 +103,7 @@ class Systeminfo : public Api::Systeminfo::ISysteminfo
     virtual void get(const Api::Systeminfo::EventGetSysteminfoPtr& event);
     virtual void watch(const Api::Systeminfo::EventWatchSysteminfoPtr& event);    
        virtual Api::Systeminfo::BasePropertyPtr getBasePropertyPtr(JSContextRef context, JSValueRef property);
-       virtual void clearWatch(const int id);
+       virtual void clearWatch(const long id);
        void getWatchValue(const int watchType);
        
        class EventMgr
@@ -115,7 +115,7 @@ class Systeminfo : public Api::Systeminfo::ISysteminfo
            void clearAllEvent();
            void addEvent(const Api::Systeminfo::EventWatchSysteminfoPtr& arg, const int watchType);
            void removeEvent(WatchId id, const int watchType);
-           const int getWatchType(const int id);
+           const int getWatchType(const long id);
            EventPowerList getEventPowerList();
            EventDisplayList getEventDisplayList();
            EventWifiNetworkList getEventWifiNetworkList();
old mode 100755 (executable)
new mode 100644 (file)
index 0a02bce..42d5548
@@ -1,16 +1,19 @@
 get_current_path()
 
 pkg_search_module(network REQUIRED network)
+pkg_search_module(network REQUIRED tapi)
 pkg_search_module(devman REQUIRED devman)
 
 set(INCLUDES_PLATFORM_IMPLEMENTATION_SYSTEMINFO
   ${network_INCLUDE_DIRS}
+  ${tapi_INCLUDE_DIRS}  
   ${devman_INCLUDE_DIRS}
   PARENT_SCOPE
 )
 
 set(LIBS_PLATFORM_IMPLEMENTATION_SYSTEMINFO
   ${network_LIBRARIES}
+  ${tapi_LIBRARIES}  
   ${devman_LIBRARIES}
   PARENT_SCOPE
 )
index 82858ca..9bd9f07 100755 (executable)
@@ -146,7 +146,7 @@ std::string TZDate::_getTimezoneName(Calendar *cal)
        TimeUtilTools Util;
        
        cal->getTimeZone().getID(ID);
-        std::string s_result = Util.toString(ID);
+       std::string s_result = Util.toString(ID);
        LogDebug(s_result);
        return s_result;        
 }
@@ -442,7 +442,7 @@ double TZDate::getTime() {
        UnicodeString str;
        TimeUtilTools Util;
        
-       DateFormat *fmt = new SimpleDateFormat(UnicodeString("EEE MMM dd yyyy"), (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
+       DateFormat *fmt = new SimpleDateFormat(Util.getDateTimeFormat(TimeUtilTools::DATE_FORMAT, bLocale), (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
        if (U_SUCCESS(ec)) {
                fmt->setCalendar(*myCalendar);
                fmt->format(myCalendar->getTime(ec), str);
@@ -467,7 +467,7 @@ double TZDate::getTime() {
        UnicodeString str;
        TimeUtilTools Util;
        
-       DateFormat *fmt = new SimpleDateFormat(UnicodeString("HH:mm:ss ZZZZ"), (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
+       DateFormat *fmt = new SimpleDateFormat(Util.getDateTimeFormat(TimeUtilTools::TIME_FORMAT, bLocale), (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
        if (U_SUCCESS(ec)) {
                fmt->setCalendar(*myCalendar);
                fmt->format(myCalendar->getTime(ec), str);
@@ -475,11 +475,7 @@ double TZDate::getTime() {
 
                if (U_SUCCESS(ec)) {
                        std::string result = Util.toString(str);
-                       if ((result.at(result.length() - 3) > 0) && (result.at(result.length() - 3) == ':'))
-                               result.erase(result.length() - 3, 1); //GMT +XX:XX -> delete ':'
-
                        str.remove();
-
                        LogDebug (result);
                        return result;
                }
@@ -495,8 +491,8 @@ double TZDate::getTime() {
        UErrorCode ec = U_ZERO_ERROR;
        UnicodeString str;
        TimeUtilTools Util;
-
-       DateFormat *fmt = new SimpleDateFormat(UnicodeString("EEE MMM dd yyyy HH:mm:ss ZZZZ"),(bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
+       
+       DateFormat *fmt = new SimpleDateFormat(Util.getDateTimeFormat(TimeUtilTools::DATETIME_FORMAT, bLocale), (bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
        if (U_SUCCESS(ec)) {
                fmt->setCalendar(*myCalendar);
                fmt->format(myCalendar->getTime(ec), str);
@@ -504,12 +500,8 @@ double TZDate::getTime() {
 
                if (U_SUCCESS(ec)) {
                        std::string result = Util.toString(str);
-                       if ((result.at(result.length() - 3) > 0) && (result.at(result.length() - 3) == ':'))
-                               result.erase(result.length() - 3, 1); //GMT +XX:XX -> delete ':'
                        str.remove();
-
                        LogDebug (result);
-
                        return result;
                }
        }
@@ -586,6 +578,7 @@ TZDateProperties TZDate::getDSTTransition(DSTTransition trans) {
        UErrorCode ec = U_ZERO_ERROR;
        TZDateProperties props;
        UDate DSTTransitionDate = myCalendar->getTime(ec);
+       UBool result = false;
 
        if (U_SUCCESS(ec)) {
                UnicodeString *ID = Util.toUnicodeString(getTimezone());
@@ -595,7 +588,6 @@ TZDateProperties TZDate::getDSTTransition(DSTTransition trans) {
 
                TimeZoneTransition tzTrans;
                if (Vtz->useDaylightTime() == TRUE) {
-                       UBool result = false;
                        if (trans == NEXT_TRANSITION)
                                result = Vtz->getNextTransition(DSTTransitionDate, FALSE,  tzTrans);
                        else
@@ -607,6 +599,9 @@ TZDateProperties TZDate::getDSTTransition(DSTTransition trans) {
                }
                delete Vtz;
 
+               if (result == false)
+                       return props;
+
                Calendar *DSTTransCalendar = myCalendar->clone();
                DSTTransCalendar->setTime(DSTTransitionDate, ec);
                if (U_SUCCESS(ec)) {
index 850ebd7..eb9e09a 100755 (executable)
@@ -165,18 +165,48 @@ std::vector<std::string> TimeUtil::getAvailableTimezones(){
 
 std::string TimeUtil::getDateFormat(const bool b_shortFormat) {
        LogDebug("entered");
+       TimeUtilTools Util;
+       UnicodeString timeFormat = Util.getDateTimeFormat((b_shortFormat ? TimeUtilTools::DATE_SHORT_FORMAT : TimeUtilTools::DATE_FORMAT), true);
+       timeFormat = timeFormat.findAndReplace("E", "D");
+
+       if (timeFormat.indexOf("MMM") > 0) {
+               if (timeFormat.indexOf("MMMM") > 0)
+                       timeFormat = timeFormat.findAndReplace("MMMM", "M");
+               else
+                       timeFormat = timeFormat.findAndReplace("MMM", "M");
+       } else {
+               timeFormat = timeFormat.findAndReplace("M", "m");
+       }
 
-       if (b_shortFormat)
-               return "d/m/y";
-       else 
-               return "D, M d y";
+       int32_t i = 0;
+       
+       while (i < timeFormat.length()) {
+               if (timeFormat[i] == timeFormat[i+1])
+                       timeFormat.remove(i, 1);
+               else
+                       i++;
+       }
+       LogDebug("result : " << Util.toString(timeFormat));
+       return Util.toString(timeFormat);
 }
 
 std::string TimeUtil::getTimeFormat(){
        LogDebug("entered");
+       TimeUtilTools Util;
+       UnicodeString timeFormat = Util.getDateTimeFormat(TimeUtilTools::TIME_FORMAT, true);
+       timeFormat = timeFormat.findAndReplace("H", "h");
+       timeFormat = timeFormat.findAndReplace("a", "ap");
 
-       return "h:m:s ap";
-
+       int32_t i = 0;
+       
+       while (i < timeFormat.length()) {
+               if (timeFormat[i] == timeFormat[i+1])
+                       timeFormat.remove(i, 1);
+               else
+                       i++;
+       }
+       LogDebug("result : " << Util.toString(timeFormat));
+       return Util.toString(timeFormat);
 }
 
 }
index 30d9faa..2867744 100755 (executable)
 
 #include <unicode/ustring.h>
 #include <unicode/udat.h>
+#include <unicode/dtptngen.h>
+
 #include <string.h>
+#include <vconf.h>
 
 #include <Commons/Exception.h>
 
@@ -138,6 +141,43 @@ TimeZone *TimeUtilTools::makeTimeZone(const std::string &name)
        return tz;
 }
 
+UnicodeString TimeUtilTools::getDateTimeFormat(DateTimeFormatType type, bool bLocale) {
+       UErrorCode ec = U_ZERO_ERROR;
+       DateTimePatternGenerator *dateTimepatten = DateTimePatternGenerator::createInstance((bLocale ? Locale::getDefault() : Locale::getEnglish()), ec);
+       if (U_SUCCESS(ec)) {
+               UnicodeString patten;
+               LogDebug("Type : " << type);
+               if (type == DATE_FORMAT)
+                       patten = dateTimepatten->getBestPattern(UDAT_YEAR_MONTH_WEEKDAY_DAY, ec);
+               else if (type == DATE_SHORT_FORMAT)
+                       patten = dateTimepatten->getBestPattern(UDAT_YEAR_NUM_MONTH_DAY, ec);
+               else {
+                       int ret = 0;
+                       int value = 0;
+                       ret = vconf_get_int(VCONFKEY_REGIONFORMAT_TIME1224, &value);
+                       // if failed, set default time format
+                       if (-1 == ret) {
+                               value = VCONFKEY_TIME_FORMAT_12;
+                       }
+
+                       std::string skeletone;
+                       if (type != TIME_FORMAT) 
+                               skeletone = UDAT_YEAR_MONTH_WEEKDAY_DAY;
+                       if (value == VCONFKEY_TIME_FORMAT_12)
+                               skeletone += "hhmmss";
+                       else
+                               skeletone += "HHmmss";
+                       patten = dateTimepatten->getBestPattern(*(toUnicodeString(skeletone)), ec);
+                       if (!bLocale)
+                               patten += " 'GMT'Z v'";
+               }
+       LogDebug("pattern : " << toString(patten));
+       return patten;
+
+       }
+
+       return "";
+}
 
 void TimeUtilTools::printDate(Calendar *cal)
 {
index 9142dae..ffbfee6 100755 (executable)
@@ -35,6 +35,12 @@ class TimeUtilTools
 {
 
     public:
+       enum DateTimeFormatType {
+               TIME_FORMAT,
+               DATE_FORMAT,
+               DATE_SHORT_FORMAT,
+               DATETIME_FORMAT
+       };
                TimeUtilTools() {}
        virtual  ~TimeUtilTools() {}
        UChar* uastrcpy(const char *chars);
@@ -47,7 +53,7 @@ class TimeUtilTools
        std::string toString(UnicodeString uniStr);
        TimeZone *makeTimeZone(const std::string &name);
        void printDate(Calendar *cal);
-
+       UnicodeString getDateTimeFormat(DateTimeFormatType type, bool bLocale);
 };
 
 }
index ff1c7cb..5dd1fe8 100755 (executable)
@@ -2,7 +2,6 @@ include_config_file(DBus)
 include_config_file(Mediacontent)
 include_config_file(Calendar)
 include_config_file(Contact)
-include_config_file(Geocoder)
 include_config_file(Call)
 include_config_file(Bluetooth)
 include_config_file(Application)
@@ -11,8 +10,9 @@ include_config_file(TimeUtil)
 include_config_file(Systeminfo)
 include_config_file(NFC)
 include_config_file(Filesystem)
-include_config_file(Account)
 
+#include_config_file(Account)
+#include_config_file(SecureElement)
 #include_config_file(Accelerometer)
 #include_config_file(Orientation)
 #include_config_file(Gyroscope)
diff --git a/src/standards/Tizen/Account/AccountConverter.cpp b/src/standards/Tizen/Account/AccountConverter.cpp
deleted file mode 100755 (executable)
index 8373cb8..0000000
+++ /dev/null
@@ -1,374 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @file        EventFilterConverter.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <Commons/RegexUtils.h>
-#include "JSAccount.h"
-#include "AccountConverter.h"
-//#include "JSAccountService.h"
-#include "JSAccountServiceType.h"
-#include "JSAccountManager.h"
-#include "JSFeatureArray.h"
-#include "JSAccountServices.h"
-#include "JSAccountServiceProvider.h"
-
-#define ACCOUNT_SERVICES_NAME "serviceName"
-#define ACCOUNT_SERVICES_TYPE "serviceType"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace {
-const int DEFAULT_EVENT_INTERVAL = 1;
-}
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-
-std::vector<std::string> AccountConverter::m_allowedAttributes;
-std::vector<std::string> AccountConverter::m_allowedCreateProperties;
-
-AccountConverter::AccountConverter(JSContextRef context) : Converter(context)
-{
-    LogDebug("entered");
-    if (m_allowedAttributes.size() == 0) {
-        m_allowedAttributes.push_back("id");
-        m_allowedAttributes.push_back("iconPath");
-    }
-    if (m_allowedCreateProperties.size() == 0) {
-               m_allowedCreateProperties.push_back("id");
-               m_allowedCreateProperties.push_back("iconPath");
-    }
-}
-
-AccountConverter::~AccountConverter()
-{
-
-}
-
-JSValueRef AccountConverter::toJSValueRefAccount(const EventAccountPtr& arg)
-{
-    LogDebug("<<<");
-    return JSAccount::createJSAccount(m_context, arg);
-}
-
-JSValueRef AccountConverter::toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg)
-{
-    LogDebug("<<<");
-    return JSAccountServiceType::createJSObject(m_context, arg);
-}
-
-JSValueRef AccountConverter::toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg)
-{
-       LogDebug("<<<");
-       return JSAccountServiceProvider::createJSObject(m_context, arg);
-}
-
-
-
-
-JSValueRef AccountConverter::toJSValueRef(
-        const std::vector<EventAccountPtr> &arg)
-{
-    LogDebug("entered");
-    return toJSValueRef_(arg, &AccountConverter::toJSValueRefAccount, this);
-}
-
-JSValueRef AccountConverter::toJSValueRef(const EventAccountListPtr &arg){
-       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
-       if(arg){
-               if (NULL == jsResult) {
-                       ThrowMsg(NullPointerException, "Could not create js array object");
-               }
-
-//             for(unsigned int i = 0; i < arg->size(); i++) {
-//                     if (!JSSetArrayElement(m_context, jsResult, i, JSAccountServiceType::createJSObject(m_context, arg->at(i)))) {
-//                             ThrowMsg(UnknownException, "Could not insert value into js array");
-//                     }
-//             }// for
-
-       }
-               LogDebug(">>>");
-               return jsResult;
-}
-
-JSValueRef AccountConverter::toFunctionOrNull(const JSValueRef& arg)
-{
-    LogDebug("entered");
-    if (Validator(m_context).isCallback(arg)) {
-        return arg;
-    } else if (!JSValueIsNull(m_context,
-                              arg) && !JSValueIsUndefined(m_context, arg)) {
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-
-JSValueRef AccountConverter::toFunction(const JSValueRef& arg)
-{
-    LogDebug("entered");
-    if (Validator(m_context).isCallback(arg)) {
-        return arg;
-    } else if (JSValueIsNull(m_context,
-                             arg) || JSValueIsUndefined(m_context, arg)) {
-        ThrowMsg(ConversionException, "JS null passed as function.");
-    }
-    ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-}
-
-AccountServicesPtr AccountConverter::toService(const JSValueRef jsValue)
-{
-       const ScopedJSStringRef serviceNameStr(JSStringCreateWithUTF8CString(ACCOUNT_SERVICES_NAME));
-       const ScopedJSStringRef serviceTypeStr(JSStringCreateWithUTF8CString(ACCOUNT_SERVICES_TYPE));
-
-       JSObjectRef jsObject = toJSObjectRef(jsValue);
-
-       JSValueRef serviceNameData = JSObjectGetProperty(m_context, jsObject, serviceNameStr.get(), NULL);
-       JSValueRef serviceTypeData = JSObjectGetProperty(m_context, jsObject, serviceTypeStr.get(), NULL);
-
-       std::string serviceName;
-       std::string serviceTypeId;
-
-       AccountServicesPtr result = AccountServicesPtr(new AccountServices());
-       if (!result) {
-               Throw(ConversionException);
-       }
-
-       if (!JSValueIsUndefined(m_context, serviceNameData)) {
-               serviceName = toString(serviceNameData);
-               result->setName(serviceName);
-       }
-
-       if (!JSValueIsUndefined(m_context, serviceTypeData)) {
-               serviceTypeId = toString(serviceTypeData);
-               result->setServiceTypeId(serviceTypeId);
-       }
-
-       return result;
-}
-
-AccountServicesArrayPtr AccountConverter::toAccountServiceArray(const JSValueRef jsValue)
-{
-       AccountServicesArrayPtr result(new AccountServicesArray());
-
-       std::vector<AccountServicesPtr> resultVector;
-       JSObjectRef objArg = toJSObjectRef(jsValue);
-       LogDebug("array length "<<JSGetArrayLength(m_context, objArg));
-       for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
-               JSValueRef element = JSGetArrayElement(m_context, objArg, i);
-               resultVector.push_back(toService(element));
-       }
-
-       *result = resultVector;
-       return result;
-}
-
-std::vector<std::string> AccountConverter::toTags(const JSValueRef jsValue){
-       std::vector<std::string> tags;
-
-       JSObjectRef objArg = toJSObjectRef(jsValue);
-       LogDebug("array length:" << JSGetArrayLength(m_context, objArg));
-
-       for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
-               JSValueRef element = JSGetArrayElement(m_context, objArg, i);
-               tags.push_back(toString(element));
-       }
-
-       return tags;
-}
-
-
-AccountServiceFilterPropertyPtr AccountConverter::toAccountServiceFilterProperty(const JSValueRef jsValue){
-       AccountServiceFilterPropertyPtr filterPropertyPtr(new AccountServiceFilterProperty());
-
-       JSValueRef serviceTypeIdRef = JSUtils::getJSProperty(m_context, jsValue, "serviceTypeId");
-       if(serviceTypeIdRef!=NULL){
-               std::string serviceType = toString(serviceTypeIdRef);
-               LogDebug("serviceType:[" << serviceType << "]");
-               filterPropertyPtr->setServiceTypeId(serviceType);
-       }else{
-               AccountLogWarning("serviceTypeIdRef is NULL");
-       }
-
-       JSValueRef tagsRef = JSUtils::getJSProperty(m_context, jsValue, "tags");
-       if(tagsRef != NULL){
-               std::vector<std::string> tags = toTags(tagsRef);
-               LogDebug("tags length:" << tags.size());
-               filterPropertyPtr->setTags(tags);
-       }else{
-               AccountLogWarning("tagsRef is NULL");
-       }
-
-       JSValueRef providerRef = JSUtils::getJSProperty(m_context, jsValue, "provider");
-       if(providerRef != NULL){
-               std::string provider = toString(providerRef);
-               LogDebug("provider:[" << provider << "]");
-               filterPropertyPtr->setProvider(provider);
-       }else{
-               AccountLogWarning("providerRef is NULL");
-       }
-
-       return filterPropertyPtr;
-}
-
-void AccountConverter::setProvider(const JSValueRef jsValue)
-{
-    LogDebug("entered");
-/*
-    const ScopedJSStringRef providerStr(JSStringCreateWithUTF8CString("providerId"));
-    JSObjectRef arg = toJSObjectRef(jsValue);
-    JSValueRef providerData = JSObjectGetProperty(m_context, arg, providerStr.get(), NULL);
-
-    if (!JSValueIsUndefined(m_context, providerData)) {
-        m_provider = toString(providerData);
-           LogDebug("m_provider : " << m_provider);
-    }
-*/
-    m_provider = toString(jsValue);
-}
-
-std::string AccountConverter::convertTostring(const JSValueRef jsValue)
-{
-       std::string string;
-    LogDebug("entered");
-    string = toString(jsValue);
-       return string;
-}
-
-EventAccountPtr AccountConverter::toAccount(const std::string& accountServiceProviderId){
-       LogDebug("<<<");
-       EventAccountPtr result(new EventAccount());
-
-       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
-       const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
-
-       //TODO set displayName
-       //TODO set iconPath
-//     JSValueRef displayNameData = JSObjectGetProperty(m_context, arg, displayNameStr.get(), NULL);
-//     JSValueRef iconPathData = JSObjectGetProperty(m_context, arg, iconPathStr.get(), NULL);
-
-//     if (!JSValueIsUndefined(m_context, displayNameData)) {
-//             result->setDisplayName(toString(displayNameData));
-//     }
-
-//     if (!JSValueIsUndefined(m_context, iconPathData)) {
-//             result->setIconPath(toString(iconPathData));
-//     }
-
-       result->setProviderName(accountServiceProviderId);
-
-       return result;
-}
-
-
-EventAccountPtr AccountConverter::toAccount(const JSValueRef account)
-{
-       LogDebug("<<<");
-       EventAccountPtr result(new EventAccount());
-
-       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
-       const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
-       const ScopedJSStringRef providerIdStr(JSStringCreateWithUTF8CString("providerId"));
-
-       JSObjectRef arg = toJSObjectRef(account);
-
-       JSValueRef displayNameData = JSObjectGetProperty(m_context, arg, displayNameStr.get(), NULL);
-       JSValueRef iconPathData    = JSObjectGetProperty(m_context, arg, iconPathStr.get(),    NULL);
-       JSValueRef providerIdData  = JSObjectGetProperty(m_context, arg, providerIdStr.get(),  NULL);
-
-       if (!JSValueIsUndefined(m_context, displayNameData)) {
-               result->setDisplayName(toString(displayNameData));
-       }
-
-       if (!JSValueIsUndefined(m_context, iconPathData)) {
-               result->setIconPath(toString(iconPathData));
-       }
-
-       if (!JSValueIsUndefined(m_context, providerIdData)) {
-               result->setProviderId(toString(providerIdData));
-       }
-
-       return result;
-}
-
-void AccountConverter::toEventFilterConvertId(
-        const AccountFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef idStr(JSStringCreateWithUTF8CString("id"));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, idStr.get())) {
-        LogDebug("converting id");
-        JSValueRef value = JSObjectGetProperty(m_context, filterObj, idStr.get(), NULL);
-        result->setIdFilter(toString(value));
-    }
-}
-
-AccountFilterPtr AccountConverter::toAccountFilter(const JSValueRef &filters)
-{
-    LogDebug("entered");
-    AccountFilterPtr result(new AccountFilter());
-    Validator validator(m_context);
-    if (!JSValueIsObject(m_context, filters)) {
-        LogError("Wrong filter parameter");
-        Throw(InvalidArgumentException);
-    }
-    if (!validator.checkArrayKeys(m_allowedAttributes, filters)) {
-        LogError("Wrong filter's attribue");
-        Throw(ConversionException);
-    }
-
-    toEventFilterConvertId(result, filters);
-    return result;
-}
-
-EventAccountListPtr AccountConverter::toVectorOfAccounts(JSValueRef events)
-{
-    LogDebug("entered");
-    EventAccountListPtr result(new EventAccountList());
-
-    std::vector<EventAccountPtr> resultVector;
-    JSObjectRef objArg = toJSObjectRef(events);
-    LogDebug("array length " + JSGetArrayLength(m_context, objArg));
-    for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
-        JSValueRef element = JSGetArrayElement(m_context, objArg, i);
-        resultVector.push_back(toAccount(element));
-    }
-
-    *result = resultVector;
-    return result;
-}
-
-JSValueRef AccountConverter::toJSONString(const std::string& arg){
-       return JSValueMakeFromJSONString(m_context, toJSStringRef(arg));
-}
-
-}
-}
-}
diff --git a/src/standards/Tizen/Account/AccountConverter.h b/src/standards/Tizen/Account/AccountConverter.h
deleted file mode 100755 (executable)
index 97fee19..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @file        Converter.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _JS_TIZEN_ACCOUNT_CONVERTER_H_
-#define _JS_TIZEN_ACCOUNT_CONVERTER_H_
-
-#include <vector>
-#include <string>
-#include <API/Account/AccountFilter.h>
-#include <API/Account/IAccountService.h>
-#include <API/Account/AccountServices.h>
-
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-class AccountConverter : public Converter
-{
-  public:
-    using Converter::toJSValueRef;
-  public:
-    explicit AccountConverter(JSContextRef context);
-    virtual ~AccountConverter();
-    AccountFilterPtr toAccountFilter(const JSValueRef &filters);
-    EventAccountPtr toAccount(const JSValueRef account);
-    EventAccountPtr toAccount(const std::string& accountServiceProviderId);
-    EventAccountListPtr toVectorOfAccounts(JSValueRef accounts);
-
-       AccountServicesArrayPtr toAccountServiceArray(const JSValueRef jsValue);
-       AccountServicesPtr toService(JSValueRef jsValue);
-
-       AccountServiceFilterPropertyPtr toAccountServiceFilterProperty(const JSValueRef jsValue);
-
-       std::vector<std::string> toTags(const JSValueRef jsValue);
-
-       void setProvider(const JSValueRef jsValue);
-       std::string convertTostring(const JSValueRef jsValue);
-
-    JSValueRef toJSValueRefAccount(const EventAccountPtr& arg);
-    JSValueRef toJSValueRef(const std::vector<EventAccountPtr> &arg);
-//    JSValueRef toJSValueRefAccountService(const IAccountServicePtr& arg);
-    JSValueRef toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg);
-    JSValueRef toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg);
-//    JSValueRef toJSValueRef(const std::vector<IAccountServicePtr> &arg);
-    JSValueRef toJSValueRef(const EventAccountListPtr &arg);
-
-    JSValueRef toJSONString(const std::string& arg);
-
-    /**
-     * @throw InvalidArgumentException If not a callback nor JS null.
-     */
-    JSValueRef toFunctionOrNull(const JSValueRef& arg);
-
-    /**
-     * @throw ConversionException If JS null.
-     * @throw InvalidArgumentException If not a callback nor JS null.
-     */
-    JSValueRef toFunction(const JSValueRef& arg);
-
-  private:
-       void toEventFilterConvertId(const AccountFilterPtr &result, const JSValueRef &filters);
-
-    static std::vector<std::string> m_allowedAttributes;
-    static std::vector<std::string> m_allowedCreateProperties;
-
-    std::string m_provider;
-
-};
-
-typedef ConverterFactory<AccountConverter> AccountConverterFactory;
-}
-}
-}
-
-#endif /* _JS_TIZEN_ACCOUNT_CONVERTER_H_ */
diff --git a/src/standards/Tizen/Account/AccountManagerController.cpp b/src/standards/Tizen/Account/AccountManagerController.cpp
deleted file mode 100755 (executable)
index 1d81455..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file               AccountManagerController.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief
- */
-
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include "AccountManagerController.h"
-#include "JSAccountService.h"
-#include "AccountConverter.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-       
-AccountManagerController::AccountManagerController(JSContextRef context,
-        IAccountManagerPtr accountManager) :
-    GetAccountServicesEventAnswerReceiver(ThreadEnum::NULL_THREAD),
-    AccountManagerPrivObject(context, accountManager)
-{
-    LogDebug("entered");
-}
-
-AccountManagerController::~AccountManagerController()
-{
-    LogDebug("entered");
-}
-
-void AccountManagerController::OnAnswerReceived(
-        const IEventGetAccountServicesPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("no callback manager");
-        return;
-    }
-    Try
-    {
-        if (event->getResult()) {
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(cbm->getContext());
-            const std::vector<IAccountServicePtr> &results = event->getAccountServices();
-            LogDebug("found accounts: " << results.size());
-            JSValueRef result = converter->toJSValueRef(results);
-            cbm->callOnSuccess(result);
-            return;
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("error during processing answer");
-    }
-    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
-            cbm->getContext());
-    cbm->callOnError(errorObject);
-}
-
-
-}
-}
-}
diff --git a/src/standards/Tizen/Account/CMakeLists.txt b/src/standards/Tizen/Account/CMakeLists.txt
deleted file mode 100755 (executable)
index 2fbef2c..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-set(TARGET_NAME "wrt-plugins-tizen-1.0-account")
-set(DESTINATION_NAME  "tizen-1.0-account")
-set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-account-impl")
-
-include_directories(
-  ${INCLUDES_PLATFORM_IMPLEMENTATION_ACCOUNT}
-)
-
-set(CMAKE_INSTALL_RPATH
-  ${CMAKE_INSTALL_RPATH}
-  ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
-)
-
-set(SRCS_IMPL
-  ${SRCS_PLATFORM_API_ACCOUNT}
-  ${SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT}
-  ResponseDispatcher.cpp
-  AccountConverter.cpp
-  JSAccount.cpp
-#  JSAccountService.cpp
-  JSAccountManager.cpp
-  JSFeatureArray.cpp
-  JSAccountServices.cpp
-  JSAccountServiceType.cpp
-  JSAccountServiceProvider.cpp
-  plugin_config.cpp
-)
-
-add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
-target_link_libraries(${TARGET_IMPL_NAME}
-  ${LIBS_PLATFORM_IMPLEMENTATION_ACCOUNT}
-  ${LIBS_COMMON}
-)
-
-set(SRCS
-  plugin_initializer.cpp
-)
-
-add_library(${TARGET_NAME} SHARED ${SRCS})
-target_link_libraries(${TARGET_NAME}
-  ${TARGET_IMPL_NAME}
-)
-
-INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
diff --git a/src/standards/Tizen/Account/JSAccount.cpp b/src/standards/Tizen/Account/JSAccount.cpp
deleted file mode 100755 (executable)
index e8ab4e8..0000000
+++ /dev/null
@@ -1,413 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @file        JSAccount.cpp
- *
- * @version     0.1
- */
-
-#include "JSAccount.h"
-#include "JSFeatureArray.h"
-#include "JSAccountServices.h"
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSUtils.h>
-
-#include "AccountConverter.h"
-#include "plugin_config.h"
-
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/SecurityExceptions.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-
-namespace {
-
-#define ACCOUNT_ATTRIBUTE_NAME  "Account"
-
-#define ACCOUNT_ATTRIBUTE_ACCOUNT_ID  "id"
-#define ACCOUNT_ATTRIBUTE_DISPLAY_NAME  "displayName"
-#define ACCOUNT_ATTRIBUTE_ICON_PATH  "icon"
-#define ACCOUNT_ATTRIBUTE_ENABLED  "enabled"
-#define ACCOUNT_ATTRIBUTE_PROVIDER_ID  "providerId"
-#define ACCOUNT_ATTRIBUTE_CREDENTIAL_ID  "credentialId"
-#define ACCOUNT_ATTRIBUTE_SERVICES  "services"
-#define ACCOUNT_ATTRIBUTE_SETTINGS  "settings"
-
-}
-
-JSClassDefinition JSAccount::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    ACCOUNT_ATTRIBUTE_NAME,
-    0,
-    m_property,
-    NULL, //m_function,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL, //getProperty,
-    NULL, //setProperty,
-    NULL, //deleteProperty,
-    NULL, //getPropertyNames,
-    NULL, //callAsFunction,
-    constructor, //callAsConstructor,
-    hasInstance, //hasInstance,
-    NULL, //convertToType,
-};
-
-JSStaticValue JSAccount::m_property[] = {
-    { ACCOUNT_ATTRIBUTE_ACCOUNT_ID,     getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_DISPLAY_NAME,   getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_ICON_PATH,      getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_ENABLED,        getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_PROVIDER_ID,    getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_CREDENTIAL_ID,  getProperty, setProperty, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_SERVICES,       getServices, setServices, kJSPropertyAttributeNone },
-    { ACCOUNT_ATTRIBUTE_SETTINGS,       getProperty, setProperty, kJSPropertyAttributeNone },
-    { 0, 0, 0, 0 }
-};
-
-JSClassRef JSAccount::m_jsClassRef = JSClassCreate(
-        JSAccount::getClassInfo());
-
-const JSClassDefinition* JSAccount::getClassInfo()
-{
-    return &(m_classInfo);
-}
-
-JSClassRef JSAccount::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-EventAccountPtr JSAccount::getIEvent(JSObjectRef object)
-{
-    LogDebug("entered");
-    AccountPrivateObject *priv =
-        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    EventAccountPtr result = priv->getObject();
-    if (!result) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    return result;
-}
-
-void JSAccount::setIEvent(const EventAccountPtr &event,
-        JSContextRef ctx,
-        const JSObjectRef object)
-{
-    LogDebug("entered");
-    Try
-    {
-        AccountPrivateObject *priv =
-            static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-        delete priv;
-        priv = new AccountPrivateObject(ctx, event);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            delete priv;
-        }
-    }
-    Catch(Exception)
-    {
-        AccountLogError("Error during replacing account object");
-    }
-}
-
-
-bool JSAccount::validate(JSContextRef ctx,
-        const JSObjectRef object,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    AccountPrivateObject *priv =
-        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-    if (priv == NULL) {
-        return false;
-    }
-    EventAccountPtr account = priv->getObject();
-    if (!account) {
-        return false;
-    }
-    return account->validate();
-}
-
-
-JSObjectRef JSAccount::createJSAccount(JSContextRef context, EventAccountPtr account)
-{
-       LogDebug("<<< ");
-       AccountPrivateObject *priv = new AccountPrivateObject(context, account);
-       JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
-       return jsValueRef;
-}
-
-void JSAccount::initialize(JSContextRef context, JSObjectRef object)
-{
-       LogDebug("<<< ");
-
-       AccountPrivateObject *privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-       if (NULL == privateObject) {
-               AccountLogWarning("privateObject is NULL");
-               EventAccountPtr accountPtr(new EventAccount());
-               AccountPrivateObject *priv = new AccountPrivateObject(context, accountPtr);
-               if (!JSObjectSetPrivate(object, priv)) {
-                       delete priv;
-               }
-       }
-}
-
-void JSAccount::finalize(JSObjectRef object)
-{
-    LogDebug("enter");
-    AccountPrivateObject* priv =
-        static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
-}
-
-
-JSValueRef JSAccount::getProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-       Try{
-               AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-               if (!priv) {
-                       Throw(NullPointerException);
-               }
-               EventAccountPtr account = priv->getObject();
-
-               if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ACCOUNT_ID)) {
-                       return converter->toJSValueRef(account->getAccountId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_DISPLAY_NAME)) {
-                       return converter->toJSValueRef(account->getDisplayName());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ICON_PATH)) {
-                       return converter->toJSValueRef(account->getIconPath());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ENABLED)) {
-                       return converter->toJSValueRef(account->getEnabled());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_PROVIDER_ID)) {
-                       return converter->toJSValueRef(account->getProviderId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_CREDENTIAL_ID)) {
-                       return converter->toJSValueRef(account->getCredentailId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_SETTINGS)) {
-                       std::string settingsString = account->getSettings();
-                       LogDebug("settingsString:[" << settingsString << "]");
-                       return converter->toJSONString(settingsString);
-               }
-       }Catch(Exception){
-               AccountLogError("invalid property");
-       }
-
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAccount::setProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-       Try{
-               AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-               if (!priv) {
-                       Throw(NullPointerException);
-               }
-               EventAccountPtr account = priv->getObject();
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-
-               if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_DISPLAY_NAME)) {
-                       std::string displayname = converter->toString(value);
-                       account->setDisplayName(displayname);
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ICON_PATH)) {
-                       std::string iconPath = converter->toString(value);
-                       account->setIconPath(iconPath);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ENABLED)) {
-                       bool enabled = converter->toBool(value);
-                       account->setEnabled(enabled);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_CREDENTIAL_ID)) {
-                       std::string credentialId = converter->toString(value);
-                       account->setCredentailId(credentialId);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_SETTINGS)) {
-                       JSStringRef jsonStringRef = JSValueCreateJSONString(context, value, 0, exception);
-
-                       std::string settingString = converter->toString(jsonStringRef);
-                       account->setSettings(settingString);
-                       return true;
-               }
-       }Catch(Exception){
-       AccountLogWarning("trying to set incorrect value");
-}
-       JSTizenExceptionFactory::postException(context, exception,
-                      JSTizenException::TYPE_MISMATCH_ERROR, "Trying to set incorrect value");
-       return false;
-}
-
-JSValueRef JSAccount::getServices(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-       Try{
-               AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-               if (!priv) {
-                       Throw(NullPointerException);
-               }
-               EventAccountPtr account = priv->getObject();
-
-               AccountServicesArrayPtr services = account->getService();
-               if (services) {
-                       JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-                       if (NULL == jsResult) {
-                               ThrowMsg(NullPointerException, "Could not create js array object");
-                       }
-                       for(unsigned int i = 0; i < services->size(); i++) {
-                               if (!JSSetArrayElement(context, jsResult, i, JSAccountServices::createJSObject(context, services->at(i)))) {
-                                       ThrowMsg(UnknownException, "Could not insert value into js array");
-                               }
-                       }
-
-                       LogDebug(">>> jsResult");
-                       return jsResult;
-               }
-       }       Catch(Exception)        {
-               AccountLogWarning("trying to get incorrect value");
-       }
-
-       LogDebug(">>> undefined");
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAccount::setServices(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-       Try{
-               AccountPrivateObject* priv = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-               if (!priv) {
-                       Throw(NullPointerException);
-               }
-               EventAccountPtr account = priv->getObject();
-               account->setService(converter->toAccountServiceArray(value));
-               return true;
-       }Catch(Exception){
-               AccountLogWarning("trying to set incorrect value");
-       }
-
-       JSTizenExceptionFactory::postException(context, exception,
-              JSTizenException::TYPE_MISMATCH_ERROR, "Trying to set incorrect value");
-       return false;
-}
-
-bool JSAccount::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSObjectRef JSAccount::constructor(JSContextRef context,
-               JSObjectRef object,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountPrivateObject* privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
-       if (!privateObject) {
-               AccountLogError(">>> NULL POINTER EXCEPTION !");
-               Throw(NullPointerException);
-       }
-
-       if (argumentCount > 2) {
-               AccountLogError("Wrong argument count:" << argumentCount);
-               JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count");
-       }
-
-       Try{
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-
-               std::string accountServiceProviderId;
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                       AccountLogError(">>> invalid value argument 0");
-                       JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-               }
-
-               accountServiceProviderId = converter->toString(arguments[0]);
-               LogDebug("accountServiceProviderId:[" << accountServiceProviderId << "]");
-
-               EventAccountPtr account = converter->toAccount(accountServiceProviderId);
-
-               if(argumentCount == 2){
-                       JSValueRef displayNameRef = JSUtils::getJSProperty(context, arguments[1], "displayName");
-                       if(displayNameRef != NULL){
-                               std::string displayName = converter->toString(displayNameRef);
-                               LogDebug("displayName:[" << displayName << "]");
-                               account->setDisplayName(displayName);
-                       }
-
-                       JSValueRef iconPathRef = JSUtils::getJSProperty(context, arguments[1], "iconPath");
-                       if(iconPathRef != NULL){
-                               std::string iconPath = converter->toString(iconPathRef);
-                               LogDebug("iconPath:[" << iconPath << "]");
-                               account->setIconPath(iconPath);
-                       }
-               }
-
-               LogDebug(">>>");
-               return JSAccount::createJSAccount(context, account);
-       }Catch(Exception){
-               AccountLogError("UNKNOWN EXCEPTION");
-               JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN_ERROR");
-       }
-
-       AccountLogWarning(">>> return NULL");
-       return NULL;
-}
-
-}
-}
-}
diff --git a/src/standards/Tizen/Account/JSAccount.h b/src/standards/Tizen/Account/JSAccount.h
deleted file mode 100755 (executable)
index e94fefd..0000000
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * @file        JSAttendee.h
- *
- * @version     0.1
- */
-
-#ifndef _JS_ACCOUNT_H_
-#define _JS_ACCOUNT_H_
-
-#include <string>
-#include <vector>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/EventAccount.h>
-#include <API/Account/log.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<EventAccountPtr>::Type AccountPrivateObject;
-
-class JSAccount
-{
-  public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static JSClassRef getClassRef();
-
-   //TODO: check if createJSAccount is necessary.
-    static JSObjectRef createJSAccount(JSContextRef context, EventAccountPtr event);
-
-
-    static EventAccountPtr getIEvent(JSObjectRef object);
-
-    static void setIEvent(const EventAccountPtr &account,
-            JSContextRef ctx,
-            const JSObjectRef object);
-
-    static bool validate(JSContextRef ctx,
-            const JSObjectRef object,
-            JSValueRef* exception);
-
-  private:
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context, JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    static JSValueRef getProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-    static bool setProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef value,
-            JSValueRef* exception);
-
-       static JSValueRef getServices(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception);
-
-       static bool setServices(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception);
-
-       static JSObjectRef constructor(JSContextRef context,
-                       JSObjectRef object,
-                       size_t argumentCount,
-                       const JSValueRef arguments[],
-                       JSValueRef* exception);
-
-       /**
-                * The callback invoked when an object is used as the target of an 'instanceof' expression.
-                */
-               static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
-
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * This structure contains properties and callbacks that define a type of object.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This member variable contains the initialization values for the static properties of this class.
-     * The values are given according to the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-};
-}
-}
-}
-
-#endif /* _JS_ATTENDEE_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountManager.cpp b/src/standards/Tizen/Account/JSAccountManager.cpp
deleted file mode 100755 (executable)
index 7269eae..0000000
+++ /dev/null
@@ -1,895 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        JSAccountManager.cpp
-* @author              Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include <dpl/log/log.h>
-
-#include <string>
-#include <API/Account/IAccountService.h>
-#include <API/Account/IAccountManager.h>
-#include <API/Account/AccountFactory.h>
-#include <API/Account/IEventCreateAccount.h>
-#include <API/Account/IEventDeleteAccount.h>
-#include <API/Account/IEventFindAccounts.h>
-#include <API/Account/IEventUpdateAccount.h>
-#include <API/Account/IEventFindServiceTypes.h>
-#include <API/Account/IEventFindProviders.h>
-#include <API/Account/IEventGetServiceByName.h>
-#include <API/Account/IEventGetServiceById.h>
-
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/Converter.h>
-
-
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/SecurityExceptions.h>
-
-#include "JSAccount.h"
-#include "JSAccountManager.h"
-#include "JSAccountServiceType.h"
-#include "JSAccountServices.h"
-#include "JSAccountServiceProvider.h"
-
-#include "AccountConverter.h"
-#include "ResponseDispatcher.h"
-#include "plugin_config.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Commons;
-
-namespace {
-#define TIZEN_ACCOUNT_MANAGER_ATTRIBUTENAME  "account"
-
-#define TIZEN_ACCOUNT_PROP_TYPE_NONE  "TYPE_NONE"
-#define TIZEN_ACCOUNT_PROP_TYPE_INTERNET "TYPE_INTERNET"
-}
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-JSClassDefinition JSAccountManager::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    TIZEN_ACCOUNT_MANAGER_ATTRIBUTENAME,
-    0,
-    m_property,
-    m_function,
-    initialize,
-    finalize,
-    NULL, //HasProperty,
-    NULL, //GetProperty,
-    NULL, //SetProperty,
-    NULL, //DeleteProperty,
-    NULL, //GetPropertyNames,
-    NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    NULL, //HasInstance,
-    NULL  //ConvertToType
-};
-
-JSStaticValue JSAccountManager::m_property[] = {
-    //event properties - recurence
-    { TIZEN_ACCOUNT_PROP_TYPE_NONE, getTypeProperty,NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_ACCOUNT_PROP_TYPE_INTERNET, getTypeProperty,NULL, kJSPropertyAttributeReadOnly },
-    { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSAccountManager::m_function[] = {
-       { ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,             getAccountById,            kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,         getServiceTypeById,        kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,            getProviderById,           kJSPropertyAttributeNone },
-//     { ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,  findAccountsByServiceType, kJSPropertyAttributeNone },
-//     { ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,         findAccountsByTags,        kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_FIND_ACCOUNTS,                 findAccounts,              kJSPropertyAttributeNone },
-//     { ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,         findServicesByTags,        kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_FIND_SERVICES,                 findServices,              kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_FIND_PROVIDERS,                findProviders,             kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,             findServiceTypes,          kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_ADD_ACCOUNT,                   addAccount,                kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,         addAccountlistener,        kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,      removeAccountlistener,     kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,             getServiceById,            kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,           getServiceByName,          kJSPropertyAttributeNone },
-       { 0, 0, 0 }
-};
-
-JSClassRef JSAccountManager::m_jsClassRef = JSClassCreate(
-        JSAccountManager::getClassInfo());
-
-void JSAccountManager::initialize(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("entered");
-    AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(object));
-    if (NULL == privateObject) {
-        IAccountManagerPtr accountManager = AccountFactory::getInstance().createAccountManagerObject();
-        privateObject = new AccountManagerPrivObject(context, accountManager);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject))) {
-            delete privateObject;
-        }
-    }
-}
-
-void JSAccountManager::finalize(JSObjectRef object)
-{
-    AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(object));
-    delete privateObject;
-}
-
-/**
- *     definition
- * void addAccount(Account account)
- */
-JSValueRef JSAccountManager::addAccount(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_ADD_ACCOUNT);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       Try{
-               if (argumentCount != 1) {
-                       AccountLogError("Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                       JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count:"+argumentCount);
-               }
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])){
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-               }
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-               EventAccountPtr account = converter->toAccount(arguments[0]);
-
-               if (!account) {
-                       AccountLogError("Failed to get an event.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                       JSTizenException::UNKNOWN_ERROR, "Failed to get an event");
-               }
-
-               IEventAddAccountPtr dplEvent(new IEventAddAccount());
-               dplEvent->setEvent(account);
-               dplEvent->setForSynchronousCall();
-               privateObject->getObject()->addAccount(dplEvent);
-
-               if (dplEvent->getResult()){
-                       LogDebug(">>>");
-                       return converter->toJSValueRefAccount(dplEvent->getEvent());
-               }else{
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                       JSTizenException::UNKNOWN_ERROR, "Unknown error");
-               }
-       }       Catch(InvalidArgumentException){
-               LogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }       Catch(Exception)        {
-               LogError("Unexpected error during adding account");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::UNKNOWN_ERROR, "Unexpected error during adding account");
-       }
-
-       return JSValueMakeNull(context);
-}
-
-
-/**
- * @throw InvalidArgumentException If not a callback nor JS null nor JS undefined.
- */
-JSValueRef getFunctionOrNull(JSContextRef ctx,
-        JSValueRef arg)
-{
-    if (Validator(ctx).isCallback(arg))
-       {
-               LogDebug("isCallback");
-        return arg;
-    }else if(!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg))
-    {
-               LogDebug("not Callback");
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-
-JSValueRef JSAccountManager::addAccountlistener(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSDOMExceptionFactory::UnknownException.make(context, exception);
-}
-
-JSValueRef JSAccountManager::removeAccountlistener(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSDOMExceptionFactory::UnknownException.make(context, exception);
-}
-
-JSValueRef JSAccountManager::getAccountById(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       Try{
-               if (argumentCount != 1) {
-                       LogError(">>> Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong argument count:"+argumentCount);
-               }
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                       JSTizenException::INVALID_VALUES_ERROR, "Invlid value");
-               }
-
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-               EventAccountPtr account(new EventAccount());
-               std::string accountId = converter->convertTostring(arguments[0]);
-               account->setAccountId(accountId);
-               if (!account) {
-                       AccountLogError(">>> Failed to get an event.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN ERROR");
-               }
-
-               IEventGetAccountByIdPtr dplEvent(new IEventGetAccountById());
-               dplEvent->setEvent(account);
-               dplEvent->setForSynchronousCall();
-               privateObject->getObject()->getAccountById(dplEvent);
-
-               if (dplEvent->getResult()){
-                       LogDebug(">>>");
-                       return converter->toJSValueRefAccount(dplEvent->getEvent());
-               }else{
-                       AccountLogError("Unexpected error");
-                       return JSDOMExceptionFactory::UnknownException.make(context, exception);
-               }
-       }       Catch(InvalidArgumentException){
-               AccountLogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }Catch(Exception){
-               AccountLogError("Unexpected error");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                                               JSTizenException::UNKNOWN_ERROR, "Unexpected error");
-       }
-
-       AccountLogWarning(">>> return NULL");
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::getServiceTypeById(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       Try{
-               if (argumentCount != 1) {
-                       AccountLogError(">>> Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-               }
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                       AccountLogError(">>> invalid value argument 0");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                       JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-               }
-
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-               EventAccountPtr account(new EventAccount());
-               std::string serviceTypeId = converter->convertTostring(arguments[0]);
-               LogDebug("serviceTypeId:[" << serviceTypeId << "]");
-               account->setServiceTypeId(serviceTypeId);
-               if (!account) {
-                       AccountLogError(">>> Failed to get an event.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::UNKNOWN_ERROR, "Failed to get an event.");
-               }
-
-               IEventGetServiceTypeByIdPtr dplEvent(new IEventGetServiceTypeById());
-               dplEvent->setEvent(account);
-               dplEvent->setForSynchronousCall();
-               privateObject->getObject()->getServiceTypeById(dplEvent);
-
-               if (dplEvent->getResult()){
-                       JSValueRef retVal = converter->toJSValueRefAccountServiceType(dplEvent->getAccountServiceTypeProperty());
-                       LogDebug(">>> RESULT");
-                       return retVal;
-               }       else{
-                       AccountLogError(">>> Get result fail");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                       JSTizenException::UNKNOWN_ERROR, "Get result fail");
-               }
-       }       Catch(InvalidArgumentException) {
-               AccountLogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }       Catch(Exception)        {
-               AccountLogError("Unexpected error during adding account");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
-       }
-
-       AccountLogWarning(">>> return NULL");
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::getProviderById(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       Try{
-               if (argumentCount != 1) {
-                       AccountLogError(">>> Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-             JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-               }
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                       AccountLogError(">>> invalid value argument 0");
-                       return JSTizenExceptionFactory::postException(context, exception,
-             JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-               }
-
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-               EventAccountPtr account(new EventAccount());
-               std::string accountServiceProviderId = converter->convertTostring(arguments[0]);
-               LogDebug("accountServiceProviderId:[" << accountServiceProviderId << "]");
-
-               account->setProviderId(accountServiceProviderId);
-               if (!account) {
-                       AccountLogError(">>> Failed to get an event.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-             JSTizenException::UNKNOWN_ERROR, "Failed to get an event.");
-               }
-
-               IEventGetProviderByIdPtr dplEvent(new IEventGetProviderById());
-               dplEvent->setEvent(account);
-               dplEvent->setForSynchronousCall();
-               privateObject->getObject()->getProviderById(dplEvent);
-
-               if (dplEvent->getResult()){
-                       JSValueRef retVal = converter->toJSValueRefAccountServiceProvider(dplEvent->getAccountServiceProviderProperty());
-                       LogDebug(">>>");
-                       return retVal;
-               }else{
-                       AccountLogError(">>> Get result fail");
-                       return JSTizenExceptionFactory::postException(context, exception,
-             JSTizenException::UNKNOWN_ERROR, "Get result fail");
-               }
-       }Catch(InvalidArgumentException){
-               AccountLogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-           JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }       Catch(Exception)        {
-               AccountLogError("Unexpected error during adding account");
-               return JSTizenExceptionFactory::postException(context, exception,
-           JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
-       }
-
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::findAccountsByServiceType(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSDOMExceptionFactory::UnknownException.make(context, exception);
-}
-
-JSValueRef JSAccountManager::findAccounts(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_ACCOUNTS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if (argumentCount > 2) {
-               AccountLogError(">>> Wrong number of parameters.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-       }
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-       IEventFindAccountsPtr eventFindAccountPtr(new IEventFindAccounts());
-
-       if(argumentCount == 1){
-               Try{
-                       //arguments[0] is filter
-                       AccountServiceFilterPropertyPtr filterPropertyPtr = converter->toAccountServiceFilterProperty(arguments[0]);
-                       eventFindAccountPtr->setFilterProperty(filterPropertyPtr);
-               }Catch(Exception){
-                       AccountLogWarning("Excpetion occur");
-               }
-       }
-
-       if(argumentCount == 2){
-               //arguments[1] is enable
-               Try{
-                       bool enable = converter->toBool(arguments[1]);
-                       eventFindAccountPtr->setEnable(enable);
-               }Catch(Exception){
-                       AccountLogError(">>> Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                        JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-               }
-       }
-
-       eventFindAccountPtr->setForSynchronousCall();
-       privateObject->getObject()->findAccounts(eventFindAccountPtr);
-
-       if (eventFindAccountPtr->getResult()){
-               EventAccountListPtr accountList = eventFindAccountPtr->getAccountLists();
-               if(accountList){
-                       JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-                       if(jsResult == NULL){
-                               ThrowMsg(NullPointerException, "Could not create js array object");
-                       }
-
-                       for(unsigned int i = 0; i < accountList->size(); i++) {
-                               if (!JSSetArrayElement(context, jsResult, i, JSAccount::createJSAccount(context, accountList->at(i)))) {
-                                               ThrowMsg(UnknownException, "Could not insert value into js array");
-                                       }
-                       }
-                       LogDebug(">>> jsResult");
-                       return jsResult;
-               }
-       }else{
-               AccountLogError(">>> Get result fail");
-               return JSTizenExceptionFactory::postException(context, exception,
-                JSTizenException::UNKNOWN_ERROR, "Get result fail");
-       }
-
-       AccountLogWarning(">>> return undefined");
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::findServices(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_SERVICES);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if (argumentCount > 2) {
-               AccountLogError(">>> Wrong number of parameters.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-       }
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-       IEventFindServicesPtr eventFindServicesPtr(new IEventFindServices());
-
-       if(argumentCount == 1){
-               Try{
-                       //arguments[0] is filter
-                       AccountServiceFilterPropertyPtr filterPropertyPtr = converter->toAccountServiceFilterProperty(arguments[0]);
-                       eventFindServicesPtr->setFilterProperty(filterPropertyPtr);
-               }Catch(Exception){
-                       AccountLogWarning("Excpetion occur");
-               }
-       }
-
-       if(argumentCount == 2){
-               //arguments[1] is enable
-               Try{
-                       bool enable = converter->toBool(arguments[1]);
-                       eventFindServicesPtr->setEnable(enable);
-               }Catch(Exception){
-                       AccountLogError(">>> Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                        JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-               }
-       }
-
-       eventFindServicesPtr->setForSynchronousCall();
-       privateObject->getObject()->findServices(eventFindServicesPtr);
-
-       if (eventFindServicesPtr->getResult()){
-               AccountServicesArrayPtr serviceList = eventFindServicesPtr->getAccountServiceList();
-               if(serviceList){
-                       JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-                       if(jsResult == NULL){
-                               ThrowMsg(NullPointerException, "Could not create js array object");
-                       }
-
-                       for(unsigned int i = 0; i < serviceList->size(); i++) {
-                               if (!JSSetArrayElement(context, jsResult, i, JSAccountServices::createJSObject(context, serviceList->at(i)))) {
-                                               ThrowMsg(UnknownException, "Could not insert value into js array");
-                                       }
-                       }
-                       LogDebug(">>> jsResult");
-                       return jsResult;
-               }
-       }else{
-               AccountLogError(">>> Get result fail");
-               return JSTizenExceptionFactory::postException(context, exception,
-                JSTizenException::UNKNOWN_ERROR, "Get result fail");
-       }
-
-       AccountLogWarning(">>> return Null");
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::findProviders(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_SERVICETYPES);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if (argumentCount > 1) {
-               AccountLogError(">>> Wrong number of parameters.");
-               return JSTizenExceptionFactory::postException(context, exception,
-                JSTizenException::TYPE_MISMATCH_ERROR, "Wrong number of parameters.");
-       }
-
-       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-
-       Try{
-               IEventFindProvidersPtr eventFindProvidersPtr(new IEventFindProviders());
-
-               if (!JSValueIsNull(context, arguments[0])){
-                       if(JSValueIsString(context, arguments[0])){
-                               std::string value = converter->convertTostring(arguments[0]);
-                               eventFindProvidersPtr->setServiceTypeId(value);
-                       }else{
-                               AccountLogError(">>> invalid value argument 0");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-                       }
-               }
-               eventFindProvidersPtr->setForSynchronousCall();
-               privateObject->getObject()->FindProviders(eventFindProvidersPtr);
-
-               if (eventFindProvidersPtr->getResult()){
-                       AccountServiceProviderPropertyArrayPtr providerPropertiesPtr = eventFindProvidersPtr->getAccountServiceProviderProperties();
-                       if(providerPropertiesPtr){
-                               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-                               if(jsResult == NULL){
-                                       ThrowMsg(NullPointerException, "Could not create js array object");
-                               }
-
-                               for(unsigned int i = 0; i < providerPropertiesPtr->size(); i++) {
-                                       if (!JSSetArrayElement(context, jsResult, i, JSAccountServiceProvider::createJSObject(context, providerPropertiesPtr->at(i)))) {
-                                                       ThrowMsg(UnknownException, "Could not insert value into js array");
-                                               }
-                               }
-                               LogDebug(">>> jsResult");
-                               return jsResult;
-                       }
-               }else{
-                       AccountLogError(">>> Get result fail");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                        JSTizenException::UNKNOWN_ERROR, "Get result fail");
-               }
-       }       Catch(InvalidArgumentException) {
-               AccountLogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }       Catch(Exception)        {
-               AccountLogError("Unexpected error during adding account");
-               return JSTizenExceptionFactory::postException(context, exception,
-            JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
-       }
-
-       return JSValueMakeNull(context);
-}
-
-/**
- * AccountServiceType[]? findServiceTypes(DOMString? prefix)
- */
-JSValueRef JSAccountManager::findServiceTypes(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("<<<");
-
-       AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       assert(privateObject);
-
-       JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       Try{
-               IEventFindServiceTypesPtr eventPtr(new IEventFindServiceTypes());
-
-               if (argumentCount == 1) {
-                       if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                               AccountLogError(">>> invalid value argument 0");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-                       }
-
-                       //TODO input argument
-                       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-                       std::string prefix = converter->convertTostring(arguments[0]);
-                       LogDebug("prefix:[" << prefix << "]");
-                       eventPtr->setPrefix(prefix);
-               }
-
-               eventPtr->setForSynchronousCall();
-               privateObject->getObject()->findServiceTypes(eventPtr);
-
-               if (eventPtr->getResult()){
-                       AccountServiceTypePropertyArrayPtr properties = eventPtr->getAccountServiceTypeProperties();
-                       if(properties){
-                               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
-                               if (NULL == jsResult) {
-                                       ThrowMsg(NullPointerException, "Could not create js array object");
-                               }
-
-                               for(unsigned int i = 0; i < properties->size(); i++) {
-                                       if (!JSSetArrayElement(context, jsResult, i, JSAccountServiceType::createJSObject(context, properties->at(i)))) {
-                                               ThrowMsg(UnknownException, "Could not insert value into js array");
-                                       }
-                               }// for
-
-                               LogDebug(">>>");
-                               return jsResult;
-                       }// if(properties)
-               }else{
-                       AccountLogError(">>> Get result fail");
-                       return JSTizenExceptionFactory::postException(context, exception,
-               JSTizenException::UNKNOWN_ERROR, "Get result fail");
-               }
-       }       Catch(InvalidArgumentException) {
-               AccountLogError("Invalid argument");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Invalid argument");
-       }       Catch(Exception)        {
-               AccountLogError("Unexpected error during adding account");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                                                                       JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
-       }
-
-       AccountLogWarning(">>> return null");
-       return JSValueMakeNull(context);
-}
-
-const JSClassRef JSAccountManager::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-const JSClassDefinition* JSAccountManager::getClassInfo()
-{
-    return &m_classInfo;
-}
-
-JSValueRef JSAccountManager::getTypeProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter conveter(context);
-        std::string property = conveter.toString(propertyName);
-               if (property == TIZEN_ACCOUNT_PROP_TYPE_NONE) {
-                       return conveter.toJSValueRef(JSAccountManager::TYPE_NONE);
-               }else if(property == TIZEN_ACCOUNT_PROP_TYPE_INTERNET) {
-                       return conveter.toJSValueRef(JSAccountManager::TYPE_INTERNET);
-               }
-    }
-    Catch(Exception)
-    {
-        LogWarning("conversion error");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAccountManager::getServiceById(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-       Try{
-               AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-                       assert(privateObject);
-
-                       JSContextRef globalContext = privateObject->getContext();
-                       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-                       if (argumentCount!=1) {
-                               AccountLogError("Wrong number of parameters.");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                               JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count:"+argumentCount);
-                       }
-
-                       if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                       JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-                       }
-
-                       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-                       std::string serviceId = converter->convertTostring(arguments[0]);
-                       LogDebug("<<< serviceId:[" << serviceId << "]");
-
-                       IEventGetServiceByIdPtr eventGetServiceByIdPtr(new IEventGetServiceById());
-                       eventGetServiceByIdPtr->setServiceId(serviceId);
-                       eventGetServiceByIdPtr->setForSynchronousCall();
-                       privateObject->getObject()->getServiceById(eventGetServiceByIdPtr);
-
-                       if (eventGetServiceByIdPtr->getResult()){
-                               LogDebug(">>> ");
-                               return JSAccountServices::createJSObject(context, eventGetServiceByIdPtr->getAccountService());
-                       }else{
-                               AccountLogError(">>> Get result fail");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                JSTizenException::UNKNOWN_ERROR, "Get result fail");
-                       }
-               }Catch(Exception){
-                       AccountLogError(">>> UNKNOWN EXCEPTION");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                       JSTizenException::UNKNOWN_ERROR, "UNKNOWN EXCEPTION");
-               }
-
-               LogDebug(">>> return null");
-               return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountManager::getServiceByName(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-       Try{
-               AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-               assert(privateObject);
-
-               JSContextRef globalContext = privateObject->getContext();
-               AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (argumentCount!=1) {
-                       AccountLogError("Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                       JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count:"+argumentCount);
-               }
-
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) || !JSValueIsString(context, arguments[0])){
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::INVALID_VALUES_ERROR, "invalid value argument 0");
-               }
-
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-               std::string serviceName = converter->convertTostring(arguments[0]);
-               LogDebug("<<< serviceName:[" << serviceName << "]");
-
-               IEventGetServiceByNamePtr eventGetServicesByNamePtr(new IEventGetServiceByName());
-               eventGetServicesByNamePtr->setServiceName(serviceName);
-               eventGetServicesByNamePtr->setForSynchronousCall();
-               privateObject->getObject()->getServiceByName(eventGetServicesByNamePtr);
-
-               if (eventGetServicesByNamePtr->getResult()){
-                       LogDebug(">>> ");
-                       return JSAccountServices::createJSObject(context, eventGetServicesByNamePtr->getAccountService());
-               }else{
-                       AccountLogError(">>> Get result fail");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                        JSTizenException::UNKNOWN_ERROR, "Get result fail");
-               }
-       }Catch(Exception){
-               AccountLogError(">>> UNKNOWN EXCEPTION");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN EXCEPTION");
-       }
-
-       LogDebug(">>> return null");
-       return JSValueMakeNull(context);
-}
-
-
-}
-}
-}
-
diff --git a/src/standards/Tizen/Account/JSAccountManager.h b/src/standards/Tizen/Account/JSAccountManager.h
deleted file mode 100755 (executable)
index 06c99a8..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file               JSAccountManager.h
-* @author              Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _JS_TIZEN_ACCOUNT_MANAGER_H_
-#define _JS_TIZEN_ACCOUNT_MANAGER_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/IAccountManager.h>
-#include <API/Account/IAccountService.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-typedef PrivateObject<IAccountManagerPtr, NoOwnership> AccountManagerPrivObject;
-
-class JSAccountManager
-{
-  public:
-
-    enum AccountType
-    {
-        TYPE_NONE,      //0
-     //   TYPE_SIM,   //1
-        TYPE_INTERNET,  //2//1
-        INVALID_TYPE = 10000
-    };
-
-    static const JSClassDefinition* getClassInfo();
-    static const JSClassRef getClassRef();
-
-  private:
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This member variable contains the initialization values for the
-     * properties of this class. The values are given according to
-     * the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-
-    /**
-     * This structure contains properties and callbacks
-     * that define a type of object.
-     */
-    static JSClassDefinition m_classInfo;
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context,
-            JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    /**
-     * Get Accounts.
-     */
-
-    static JSValueRef addAccount(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-       static JSValueRef addAccountlistener(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef removeAccountlistener(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef getAccountById(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef getServiceTypeById(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef getProviderById(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef findAccountsByServiceType(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef findAccounts(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef findServices(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef findProviders(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-       static JSValueRef findServiceTypes(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef getTypeProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-       static JSValueRef getServiceById(JSContextRef context,
-                       JSObjectRef object,
-                       JSObjectRef thisObject,
-                       size_t argumentCount,
-                       const JSValueRef arguments[],
-                       JSValueRef* exception);
-
-       static JSValueRef getServiceByName(JSContextRef context,
-                               JSObjectRef object,
-                               JSObjectRef thisObject,
-                               size_t argumentCount,
-                               const JSValueRef arguments[],
-                               JSValueRef* exception);
-
-};
-}
-}
-}
-#endif /* _JS_TIZEN_ACCOUNT_MANAGER_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountServiceProvider.cpp b/src/standards/Tizen/Account/JSAccountServiceProvider.cpp
deleted file mode 100755 (executable)
index b74d78f..0000000
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-/*
- * JSAccountServiceProvider.cpp
- *
- *  Created on: 2012. 2. 1.
- *      Author: sangtai
- */
-
-#include "JSAccountServiceProvider.h"
-
-#include <CommonsJavaScript/Converter.h>
-#include "AccountConverter.h"
-
-namespace TizenApis {
-       namespace Tizen1_0{
-               namespace Account {
-                       namespace {
-                               #define ACCOUNT_SERVICE_PROVIDER               "AccountServiceProvider"
-                               #define ACCOUNT_SERVICE_PROVIDER_ID            "id"
-                               #define ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME  "displayName"
-                               #define ACCOUNT_SERVICE_PROVIDER_ICON_PATH     "icon"
-                       }
-
-                       JSClassDefinition JSAccountServiceProvider::m_classInfo = {
-                               0,
-                               kJSClassAttributeNone,
-                               ACCOUNT_SERVICE_PROVIDER,
-                               0,
-                               m_property,
-                               NULL, //m_function,
-                               initialize,
-                               finalize,
-                               NULL, //hasProperty,
-                               NULL, //getProperty,
-                               NULL, //setProperty,
-                               NULL, //deleteProperty,
-                               NULL, //getPropertyNames,
-                               NULL, //callAsFunction,
-                               NULL, //callAsConstructor,
-                               NULL, //hasInstance,
-                               NULL, //convertToType,
-                       };
-
-                       JSStaticValue JSAccountServiceProvider::m_property[] = {
-                               { ACCOUNT_SERVICE_PROVIDER_ID,           getProperty, NULL, kJSPropertyAttributeNone },
-                               { ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeNone },
-                               { ACCOUNT_SERVICE_PROVIDER_ICON_PATH,    getProperty, NULL, kJSPropertyAttributeNone },
-                               { 0, 0, 0, 0 }
-                       };
-
-                       JSClassRef JSAccountServiceProvider::m_jsClassRef = JSClassCreate(
-                                       JSAccountServiceProvider::getClassInfo());
-
-                       const JSClassDefinition* JSAccountServiceProvider::getClassInfo(){
-                               return &(m_classInfo);
-                       }
-
-                       JSClassRef JSAccountServiceProvider::getClassRef()                      {
-                               if (!m_jsClassRef) {
-                                       m_jsClassRef = JSClassCreate(&m_classInfo);
-                               }
-                               return m_jsClassRef;
-                       }
-
-                       JSObjectRef JSAccountServiceProvider::createJSObject(JSContextRef context, AccountServiceProviderPropertyPtr propertyPtr){
-                               LogDebug("<<<");
-
-                               AccountServiceProviderPrivateObject *priv = new AccountServiceProviderPrivateObject(context, propertyPtr);
-
-                               JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
-                               LogDebug(">>>");
-                               return jsValueRef;
-                       }
-
-                       void JSAccountServiceProvider::initialize(JSContextRef context, JSObjectRef object) {
-                               LogDebug("<<< ");
-                               AccountServiceProviderPrivateObject *privateObject = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
-                               if (NULL == privateObject) {
-                                       AccountLogWarning("privateObject is NULL");
-                               }
-                       }
-
-                       void JSAccountServiceProvider::finalize(JSObjectRef object) {
-                               LogDebug("<<<");
-                               AccountServiceProviderPrivateObject* priv = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
-                               delete priv;
-                               JSObjectSetPrivate(object, NULL);
-                       }
-
-                               JSValueRef JSAccountServiceProvider::getProperty(JSContextRef context,
-                                       JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
-                               LogDebug("<<<");
-                               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-                               Try{
-                                       AccountServiceProviderPrivateObject* priv = static_cast<AccountServiceProviderPrivateObject*>(JSObjectGetPrivate(object));
-                                       if (!priv) {
-                                               Throw(NullPointerException);
-                                       }
-                                       AccountServiceProviderPropertyPtr accountServicePropertyProperty = priv->getObject();
-
-                                       if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_ID)) {
-                                               return converter->toJSValueRef(accountServicePropertyProperty->getId());
-                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_DISPLAY_NAME)) {
-                                               return converter->toJSValueRef(accountServicePropertyProperty->getDisplayName());
-                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_PROVIDER_ICON_PATH)) {
-                                               return converter->toJSValueRef(accountServicePropertyProperty->getIconPath());
-                                       }
-                               }       Catch(Exception){
-                                       AccountLogError("invalid property");
-                               }
-
-                               AccountLogWarning(">>> return undefined");
-                               return JSValueMakeUndefined(context);
-                       }
-
-               } /* namespace Account */
-       } /* namespace Tizen1_0 */
-} /* namespace TizenApis */
diff --git a/src/standards/Tizen/Account/JSAccountServiceProvider.h b/src/standards/Tizen/Account/JSAccountServiceProvider.h
deleted file mode 100755 (executable)
index b8f1ee8..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-
-/*
- * JSAccountServiceProvider.h
- *
- *  Created on: 2012. 2. 1.
- *      Author: sangtai
- */
-
-#ifndef JSACCOUNTSERVICEPROVIDER_H_
-#define JSACCOUNTSERVICEPROVIDER_H_
-
-#include <string>
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/AccountServiceProviderProperty.h>
-#include <API/Account/log.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-       namespace Tizen1_0 {
-               namespace Account {
-
-                       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<AccountServiceProviderPropertyPtr>::Type AccountServiceProviderPrivateObject;
-
-                       class JSAccountServiceProvider {
-
-                               public:
-                                       static const JSClassDefinition* getClassInfo();
-
-                                       static JSClassRef getClassRef();
-                                       static JSObjectRef createJSObject(JSContextRef context, AccountServiceProviderPropertyPtr propertyPtr);
-
-                               private:
-                                       /**
-                                        * The callback invoked when an object is first created.
-                                        */
-                                       static void initialize(JSContextRef context, JSObjectRef object);
-
-                                       /**
-                                        * The callback invoked when an object is finalized.
-                                        */
-                                       static void finalize(JSObjectRef object);
-
-                                       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-
-                                       static JSClassRef m_jsClassRef;
-
-                                       /**
-                                        * This structure contains properties and callbacks that define a type of object.
-                                        */
-                                       static JSClassDefinition m_classInfo;
-
-                                       /**
-                                        * This member variable contains the initialization values for the static properties of this class.
-                                        * The values are given according to the data structure JSPropertySpec
-                                        */
-                                       static JSStaticValue m_property[];
-                       };
-
-               } /* namespace Account */
-       } /* namespace Api */
-} /* namespace Tizen1_0 */
-#endif /* JSACCOUNTSERVICEPROVIDER_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountServiceType.cpp b/src/standards/Tizen/Account/JSAccountServiceType.cpp
deleted file mode 100755 (executable)
index 82b9990..0000000
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- * JSServiceType.cpp
- *
- *  Created on: 2012. 1. 30.
- *      Author: sangtai
- */
-
-#include "JSAccountServiceType.h"
-
-#include <CommonsJavaScript/Converter.h>
-#include "AccountConverter.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-//using namespace TizenApis::Commons;
-
-namespace TizenApis {
-       namespace Tizen1_0 {
-               namespace Account {
-
-                       namespace {
-                               #define ACCOUNT_SERVICE_TYPE               "AccountServiceType"
-                               #define ACCOUNT_SERVICE_TYPE_ID            "id"
-                               #define ACCOUNT_SERVICE_TYPE_DISPLAY_NAME  "displayName"
-                               #define ACCOUNT_SERVICE_TYPE_ICON_PATH     "icon"
-                               #define ACCOUNT_SERVICE_TYPE_TAGS          "tags"
-                       }
-
-                       JSClassDefinition JSAccountServiceType::m_classInfo = {
-                               0,
-                               kJSClassAttributeNone,
-                               ACCOUNT_SERVICE_TYPE,
-                               0,
-                               m_property,
-                               NULL, //m_function,
-                               initialize,
-                               finalize,
-                               NULL, //hasProperty,
-                               NULL, //getProperty,
-                               NULL, //setProperty,
-                               NULL, //deleteProperty,
-                               NULL, //getPropertyNames,
-                               NULL, //callAsFunction,
-                               NULL, //callAsConstructor,
-                               NULL, //hasInstance,
-                               NULL, //convertToType,
-                       };
-
-                       JSStaticValue JSAccountServiceType::m_property[] = {
-                               { ACCOUNT_SERVICE_TYPE_ID,           getProperty, NULL, kJSPropertyAttributeNone },
-                               { ACCOUNT_SERVICE_TYPE_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeNone },
-                               { ACCOUNT_SERVICE_TYPE_ICON_PATH,    getProperty, NULL, kJSPropertyAttributeNone },
-                               { ACCOUNT_SERVICE_TYPE_TAGS,         getProperty, NULL, kJSPropertyAttributeNone },
-                               { 0, 0, 0, 0 }
-                       };
-
-
-                       JSClassRef JSAccountServiceType::m_jsClassRef = JSClassCreate(
-                                       JSAccountServiceType::getClassInfo());
-
-                       const JSClassDefinition* JSAccountServiceType::getClassInfo(){
-                               return &(m_classInfo);
-                       }
-
-                       JSClassRef JSAccountServiceType::getClassRef()                  {
-                               if (!m_jsClassRef) {
-                                       m_jsClassRef = JSClassCreate(&m_classInfo);
-                               }
-                               return m_jsClassRef;
-                       }
-
-                       JSObjectRef JSAccountServiceType::createJSObject(JSContextRef context, AccountServiceTypePropertyPtr account){
-                               LogDebug("<<<");
-
-                               AccountServiceTypePrivateObject *priv = new AccountServiceTypePrivateObject(context, account);
-
-                               JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
-                               LogDebug(">>>");
-                               return jsValueRef;
-                       }
-
-                       void JSAccountServiceType::initialize(JSContextRef context, JSObjectRef object) {
-                               LogDebug("<<< ");
-                               AccountServiceTypePrivateObject *privateObject = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
-                               if (NULL == privateObject) {
-                                       LogDebug("privateObject is NULL");
-                               }
-                       }
-
-                       void JSAccountServiceType::finalize(JSObjectRef object) {
-                               LogDebug("<<<");
-                               AccountServiceTypePrivateObject* priv = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
-                               delete priv;
-                               JSObjectSetPrivate(object, NULL);
-                       }
-
-                       JSValueRef JSAccountServiceType::getProperty(JSContextRef context,
-                                       JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
-                               LogDebug("<<<");
-                               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-                               Try{
-                                       AccountServiceTypePrivateObject* priv = static_cast<AccountServiceTypePrivateObject*>(JSObjectGetPrivate(object));
-                                       if (!priv) {
-                                               Throw(NullPointerException);
-                                       }
-                                       AccountServiceTypePropertyPtr accountServiceTypeProperty = priv->getObject();
-
-                                       if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_ID)) {
-                                               return converter->toJSValueRef(accountServiceTypeProperty->getId());
-                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_DISPLAY_NAME)) {
-                                               return converter->toJSValueRef(accountServiceTypeProperty->getDisplayName());
-                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_ICON_PATH)) {
-                                               return converter->toJSValueRef(accountServiceTypeProperty->getIconPath());
-                                       } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICE_TYPE_TAGS)) {
-                                                       return converter->toJSValueRef(accountServiceTypeProperty->getTags());
-                                       }
-                               }       Catch(Exception){
-                                       LogError("invalid property");
-                               }
-
-                               return JSValueMakeUndefined(context);
-                       }
-
-JSAccountServiceType::~JSAccountServiceType() {
-       // TODO Auto-generated destructor stub
-}
-
-               } //namespace Account
-       } //namespace Tizen1_0
-} //namespace TizenApis
diff --git a/src/standards/Tizen/Account/JSAccountServiceType.h b/src/standards/Tizen/Account/JSAccountServiceType.h
deleted file mode 100755 (executable)
index d6d3519..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/*
- * JSServiceType.h
- *
- *  Created on: 2012. 1. 30.
- *      Author: sangtai
- */
-
-#ifndef JSACCOUNTSERVICETYPE_H_
-#define JSACCOUNTSERVICETYPE_H_
-
-#include <string>
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/AccountServiceTypeProperty.h>
-#include <API/Account/log.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-       namespace Tizen1_0 {
-               namespace Account {
-
-                       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<AccountServiceTypePropertyPtr>::Type AccountServiceTypePrivateObject;
-
-                       class JSAccountServiceType {
-                               public:
-                                       static const JSClassDefinition* getClassInfo();
-
-                                       static JSClassRef getClassRef();
-                                       static JSObjectRef createJSObject(JSContextRef context, AccountServiceTypePropertyPtr propertyPtr);
-
-                               private:
-                                       /**
-                                        * The callback invoked when an object is first created.
-                                        */
-                                       static void initialize(JSContextRef context, JSObjectRef object);
-
-                                       /**
-                                        * The callback invoked when an object is finalized.
-                                        */
-                                       static void finalize(JSObjectRef object);
-
-                                       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-
-                                       virtual ~JSAccountServiceType();
-
-                                       static JSClassRef m_jsClassRef;
-
-                                       /**
-                                        * This structure contains properties and callbacks that define a type of object.
-                                        */
-                                       static JSClassDefinition m_classInfo;
-
-                                       /**
-                                        * This member variable contains the initialization values for the static properties of this class.
-                                        * The values are given according to the data structure JSPropertySpec
-                                        */
-                                       static JSStaticValue m_property[];
-                       };
-
-               } //namespace Account
-       } //namespace Tizen1_0
-} //namespace TizenApis
-
-#endif /* JSACCOUNTSERVICETYPE_H_ */
diff --git a/src/standards/Tizen/Account/JSAccountServices.cpp b/src/standards/Tizen/Account/JSAccountServices.cpp
deleted file mode 100755 (executable)
index 02f5b40..0000000
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        JSAccountServices.cpp
- * @author      Jihwa park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief       Implementation of the JSAccountServices class
- */
-
-#include <dpl/shared_ptr.h>
-#include <CommonsJavaScript/Converter.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-#include "AccountConverter.h"
-#include "JSAccountServices.h"
-
-namespace {
-#define TIZEN_ACCOUNT_CLASS_ACCOUNT_SERVICE    "service"
-
-#define ACCOUNT_SERVICES_ATTR_SERVICE_ID                "id"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_NAME              "name"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID    "applicationId"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME      "displayName"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_ICON              "icon"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID        "accountId"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID   "serviceTypeId"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID       "providerId"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_TAGS              "tags"
-#define ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS          "settings"
-
-}
-
-namespace TizenApis {
-namespace Api {
-namespace Account {
-
-using namespace TizenApis::Commons;
-using namespace TizenApis::Api::Account;
-using namespace TizenApis::Tizen1_0::Account;
-
-JSClassRef JSAccountServices::m_classRef = NULL;
-
-JSClassDefinition JSAccountServices::m_classInfo =
-{
-       0,
-       kJSClassAttributeNone,
-       TIZEN_ACCOUNT_CLASS_ACCOUNT_SERVICE,
-       NULL,
-       m_property,
-       NULL,
-       Initialize,
-       Finalize,
-       NULL, //hasProperty,
-       NULL, //GetProperty,
-       NULL, //SetProperty,
-       NULL, //DeleteProperty,
-       NULL, //getPropertyNames,
-       NULL,
-       NULL,
-       NULL,
-       NULL, //ConvertToType,
-};
-
-JSStaticValue JSAccountServices::m_property[] = {
-       { ACCOUNT_SERVICES_ATTR_SERVICE_ID,              getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_NAME,            getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID,  getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME,    getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_ICON,            getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID,      getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID, getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID,     getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_TAGS,            getProperty, setProperty, kJSPropertyAttributeNone },
-       { ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS,        getProperty, setProperty, kJSPropertyAttributeNone },
-       { 0, 0, 0, 0 }
-};
-
-
-JSClassRef JSAccountServices::getClassRef()
-{
-       if (!m_classRef) {
-               m_classRef = JSClassCreate(&m_classInfo);
-       }
-       return m_classRef;
-}
-
-JSObjectRef JSAccountServices::createJSObject(JSContextRef context, AccountServicesPtr service)
-{
-    AccountServicesPrivObj *priv = new AccountServicesPrivObj(context, service);
-    return JSObjectMake(context, getClassRef(), priv);
-}
-
-bool JSAccountServices::isObjectOfClass(JSContextRef context, JSValueRef value)
-{
-       return JSValueIsObjectOfClass(context, value, getClassRef());
-}
-
-AccountServicesPtr JSAccountServices::getAccountServices(JSContextRef context, JSValueRef value)
-{
-       if (!isObjectOfClass(context, value)) {
-               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-       }
-
-       JSObjectRef object = JSValueToObject(context, value, NULL);
-       if (!object) {
-               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-       }
-
-       AccountServicesPrivObj *priv = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
-       if (!priv) {
-               Throw(WrtDeviceApis::Commons::NullPointerException);
-       }
-
-       return priv->getObject();
-}
-
-void JSAccountServices::Initialize(JSContextRef context, JSObjectRef object)
-{
-       LogDebug("entered");
-}
-
-void JSAccountServices::Finalize(JSObjectRef object)
-{
-    AccountServicesPrivObj *privateObject = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
-    delete privateObject;
-}
-
-AccountServicesPtr JSAccountServices::getPrivData(JSObjectRef object)
-{
-       LogDebug("entered");
-       AccountServicesPrivObj *priv = static_cast<AccountServicesPrivObj*>(JSObjectGetPrivate(object));
-       if (!priv) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
-       }
-
-       AccountServicesPtr result = priv->getObject();
-       if (!result) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
-       }
-
-       return result;
-}
-
-JSValueRef JSAccountServices::getProperty(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       LogDebug("<<<");
-       Try{
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-               AccountServicesPtr accountServicePtr = getPrivData(object);
-
-               if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ID)) {
-                       return converter->toJSValueRef(accountServicePtr->getId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_NAME)) {
-                       return converter->toJSValueRef(accountServicePtr->getName());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID)) {
-                       return converter->toJSValueRef(accountServicePtr->getApplicationId());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME)) {
-                       return converter->toJSValueRef(accountServicePtr->getDisplayName());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ICON)) {
-                       return converter->toJSValueRef(accountServicePtr->getIcon());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ACCOUNT_ID)) {
-                       return converter->toJSValueRef(accountServicePtr->getAccountId());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID)) {
-                       return converter->toJSValueRef(accountServicePtr->getServiceTypeId());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_PROVIDER_ID)) {
-                       return converter->toJSValueRef(accountServicePtr->getProviderId());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_TAGS)) {
-//                     return converter->toJSValueRef(accountServicePtr->getTags());
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS)) {
-                       std::string settingsString = accountServicePtr->getSettings();
-                       return converter->toJSONString(settingsString);
-               }
-       }Catch(WrtDeviceApis::Commons::Exception){
-               AccountLogWarning("trying to get incorrect value");
-       }
-
-       LogDebug(">>> return UNDEFINED");
-       return JSValueMakeUndefined(context);
-}
-
-bool JSAccountServices::setProperty(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception)
-{
-       LogDebug("<<<");
-       Try{
-               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-               AccountServicesPtr accountServicePtr = getPrivData(object);
-
-               if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_APPLICATION_ID)) {
-                       std::string applicationId = converter->toString(value);
-                       accountServicePtr->setApplicationId(applicationId);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_DISPLAY_NAME)) {
-                       std::string displayName = converter->toString(value);
-                       accountServicePtr->setDisplayName(displayName);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_ICON)) {
-                       std::string icon = converter->toString(value);
-                       accountServicePtr->setIcon(icon);
-                       return true;
-               }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS)) {
-                       JSStringRef jsonStringRef = JSValueCreateJSONString(context, value, 0, exception);
-                       std::string settingString = converter->toString(jsonStringRef);
-                       accountServicePtr->setSettings(settingString);
-                       return true;
-               }
-       }       Catch(WrtDeviceApis::Commons::Exception){
-               AccountLogWarning("trying to set incorrect value");
-       }
-
-       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
-       return false;
-}
-
-} // Account
-} // Api
-} // TizenApis
-
diff --git a/src/standards/Tizen/Account/JSAccountServices.h b/src/standards/Tizen/Account/JSAccountServices.h
deleted file mode 100755 (executable)
index fb14537..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        JSAccountServices.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- * @brief       Declaration of the JSAccountServices class
- */
-
-#ifndef _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
-#define _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <dpl/shared_ptr.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <Commons/IEvent.h>
-#include <API/Account/AccountServices.h>
-#include <API/Account/log.h>
-
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace WrtDeviceApis::Commons;
-using namespace TizenApis::Api::Account;
-
-namespace TizenApis {
-namespace Api {
-namespace Account {
-
-typedef PrivateObject<AccountServicesPtr, NoOwnership> AccountServicesPrivObj;
-
-class JSAccountServices {
-public:
-       /*
-       * This initializes this JS class in the JS Engine.
-       */
-       static JSClassRef getClassRef();
-
-       static JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Account::AccountServicesPtr service);
-
-       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
-
-       static AccountServicesPtr getAccountServices(JSContextRef context, JSValueRef value);
-
-private:
-   /**
-       * The callback invoked when an object is first created.
-       */
-       static void Initialize(JSContextRef context, JSObjectRef object);
-
-   /**
-       * The callback invoked when an object is finalized.
-       */
-       static void Finalize(JSObjectRef object);
-
-   /**
-       * This structure contains properties and callbacks that define a type of object.
-       */
-       static JSClassDefinition m_classInfo;
-
-   /**
-       * This structure describes a statically declared function property.
-       */
-       static JSStaticFunction m_functions[];
-
-       /**
-        * This member variable contains the initialization values for the static properties of this class.
-        * The values are given according to the data structure JSPropertySpec
-        */
-       static JSStaticValue m_property[];
-
-       static JSClassRef m_classRef;
-
-       static AccountServicesPtr getPrivData(JSObjectRef object);
-
-       static JSValueRef getProperty(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setProperty(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef value,
-                       JSValueRef* exception);
-
-};
-
-} // Account
-} // Tizen1_0
-} // TizenApis
-
-#endif // _TIZEN_ACCOUNT_JS_ACCOUNT_SERVICES_H_
-
diff --git a/src/standards/Tizen/Account/JSFeatureArray.cpp b/src/standards/Tizen/Account/JSFeatureArray.cpp
deleted file mode 100755 (executable)
index b5277da..0000000
+++ /dev/null
@@ -1,574 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file        JSFeatureArray.cpp
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include "JSFeatureArray.h"
-#include <algorithm>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <CommonsJavaScript/Converter.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace {
-
-#define FUNCTION_CONCAT  "concat"
-#define FUNCTION_JOIN  "join"
-#define FUNCTION_POP  "pop"
-#define FUNCTION_PUSH  "push"
-#define FUNCTION_REVERSE  "reverse"
-#define FUNCTION_SHIFT  "shift"
-#define FUNCTION_SLICE  "slice"
-#define FUNCTION_SORT  "sort"
-#define FUNCTION_SPLICE  "splice"
-#define FUNCTION_TOSTRING  "toString"
-#define FUNCTION_UNSHIFT  "unshift"
-#define FUNCTION_VALUEOF  "valueOf"
-#define ARRAY  "Array"
-#define ATTRIBUTE_LENGTH  "length"
-
-}
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-JSClassDefinition JSFeatureArray::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    ARRAY,
-    0,
-    m_property,
-    m_function,
-    initialize,
-    finalize,
-    hasProperty,
-    getProperty,
-    setProperty,
-    NULL, //deleteProperty,
-    NULL, //getPropertyNames,
-    NULL, //callAsFunction,
-    NULL, //callAsConstructor,
-    NULL, //hasInstance,
-    NULL, //convertToType,
-};
-
-JSStaticValue JSFeatureArray::m_property[] = {
-    { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly },
-    { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSFeatureArray::m_function[] = {
-    { FUNCTION_CONCAT, concat, kJSPropertyAttributeNone },
-    { FUNCTION_JOIN, join, kJSPropertyAttributeNone },
-    { FUNCTION_POP, pop, kJSPropertyAttributeNone },
-    { FUNCTION_PUSH, push, kJSPropertyAttributeNone },
-    { FUNCTION_REVERSE, reverse, kJSPropertyAttributeNone },
-    { FUNCTION_SHIFT, shift, kJSPropertyAttributeNone },
-    { FUNCTION_SLICE, slice, kJSPropertyAttributeNone },
-    { FUNCTION_SORT, sort, kJSPropertyAttributeNone },
-    { FUNCTION_SPLICE, splice, kJSPropertyAttributeNone },
-    { FUNCTION_TOSTRING, toString, kJSPropertyAttributeNone },
-    { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeNone },
-    { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeNone },
-    { 0, 0, 0 }
-};
-
-JSClassRef JSFeatureArray::m_jsClassRef = JSClassCreate(
-        JSFeatureArray::getClassInfo());
-
-JSValueRef JSFeatureArray::getLength(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Try
-    {
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        FeatureListPtr categories = priv->getObject();
-        if (categories) {
-            Converter converter(context);
-            return converter.toJSValueRef(categories->size());
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("invalid conversion");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-FeatureListPtr JSFeatureArray::getFeatures(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("enter");
-    JSFeatureArrayPrivate* priv =
-        static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        Throw(NullPointerException);
-    }
-    return priv->getObject();
-}
-
-JSObjectRef JSFeatureArray::createArray(JSContextRef context,
-        const FeatureListPtr &features)
-{
-       LogDebug("entered");
-       JSFeatureArrayPrivate *priv = new JSFeatureArrayPrivate(context,features);
-       return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSFeatureArray::getClassInfo()
-{
-    return &(m_classInfo);
-}
-
-JSClassRef JSFeatureArray::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-void JSFeatureArray::initialize(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("enter");
-}
-
-void JSFeatureArray::finalize(JSObjectRef object)
-{
-    LogDebug("enter");
-    JSFeatureArrayPrivate* priv =
-        static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
-}
-
-bool JSFeatureArray::hasProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName)
-{
-    LogDebug("enter");
-    Converter converter(context);
-    Try
-    {
-        size_t index = converter.toSizeT(propertyName);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        FeatureListPtr categories = priv->getObject();
-        if (index < categories->size()) {
-            return true;
-        }
-    }
-    Catch(Exception)
-    {
-        //not reporting error is intended
-    }
-    return false;
-}
-
-JSValueRef JSFeatureArray::getProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Converter converter(context);
-    Try
-    {
-        size_t index = converter.toSizeT(propertyName);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        FeatureListPtr categories = priv->getObject();
-        if (index < categories->size()) {
-            std::string result = categories->at(index);
-            if (!result.empty()) {
-                return converter.toJSValueRef(result);
-            }
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("invalid property");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-bool JSFeatureArray::setProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Converter converter(context);
-    Try
-    {
-        size_t index = converter.toSizeT(propertyName);
-        std::string category;
-        if (!JSValueIsUndefined(context, value)) {
-            category = converter.toString(value);
-        }
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        FeatureListPtr categories = priv->getObject();
-        if (!categories) {
-            Throw(NullPointerException);
-        }
-        if (categories->size() <= index) {
-            categories->resize(index + 1);
-        }
-        (*categories)[index] = category;
-        return true;
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-        JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-    }
-    return false;
-}
-
-JSValueRef JSFeatureArray::concat(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Try
-    {
-        FeatureListPtr categories = FeatureListPtr(new FeatureList());
-        JSFeatureArrayPrivate *newPrivateObject = new JSFeatureArrayPrivate(
-                context,
-                categories);
-        JSValueRef result = JSObjectMake(context,
-                                         getClassRef(), newPrivateObject);
-
-        //copy current categories
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        for (size_t i = 0; i < currentCategories->size(); ++i) {
-            categories->push_back(currentCategories->at(i));
-        }
-
-        //copy submitted arrays
-        Converter converter(context);
-        for (size_t i = 0; i < argumentCount; ++i) {
-            if (!JSIsArrayValue(context, arguments[i])) {
-                Throw(ConversionException);
-            }
-            // process array of strings
-            JSObjectRef arrayObj = converter.toJSObjectRef(arguments[i]);
-            unsigned int len = JSGetArrayLength(context, arrayObj);
-            for (unsigned int e = 0; e < len; ++e) {
-                JSValueRef att = JSGetArrayElement(context, arrayObj, e);
-                categories->push_back(converter.toString(att));
-            }
-        }
-        return result;
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-}
-
-JSValueRef JSFeatureArray::join(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        std::string result;
-        std::string separator(",");
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
-            separator = converter.toString(arguments[0]);
-        }
-        for (size_t i = 0; i < currentCategories->size(); ++i) {
-            if (i != 0) {
-                result += separator;
-            }
-            result += currentCategories->at(i);
-        }
-        return converter.toJSValueRef(result);
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-}
-
-JSValueRef JSFeatureArray::pop(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        if (currentCategories->size() > 0) {
-            std::string result = currentCategories->at(
-                    currentCategories->size() - 1);
-            currentCategories->pop_back();
-            return converter.toJSValueRef(result);
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::push(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        for (size_t i = 0; i < argumentCount; ++i) {
-            currentCategories->push_back(converter.toString(arguments[i]));
-        }
-        return converter.toJSValueRef(currentCategories->size());
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-}
-
-JSValueRef JSFeatureArray::reverse(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        std::reverse(currentCategories->begin(), currentCategories->end());
-        return thisObject;
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::shift(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        if (currentCategories->size() > 0) {
-            std::string result = currentCategories->at(0);
-            currentCategories->erase(currentCategories->begin());
-            return converter.toJSValueRef(result);
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::slice(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Try
-    {
-        if (argumentCount < 1) {
-            return JSValueMakeUndefined(context);
-        }
-        Converter converter(context);
-        FeatureListPtr categories = FeatureListPtr(new FeatureList());
-        JSFeatureArrayPrivate *newPrivateObject = new JSFeatureArrayPrivate(
-                context,
-                categories);
-        JSValueRef result = JSObjectMake(context,
-                                         getClassRef(), newPrivateObject);
-
-        //copy current categories
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        std::size_t first = converter.toSizeT(arguments[0]);
-        std::size_t last = currentCategories->size() - 1;
-        if (argumentCount > 1) {
-            last = converter.toSizeT(arguments[1]);
-            if (last >= currentCategories->size()) {
-                last = currentCategories->size() - 1;
-            }
-        }
-        if (first < 0) {
-            first = 0;
-        }
-        for (size_t i = first; i <= last; ++i) {
-            categories->push_back(currentCategories->at(i));
-        }
-
-        return result;
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-}
-
-JSValueRef JSFeatureArray::sort(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        Converter converter(context);
-        JSFeatureArrayPrivate* priv =
-            static_cast<JSFeatureArrayPrivate*>(JSObjectGetPrivate(thisObject));
-        FeatureListPtr currentCategories = priv->getObject();
-        std::sort(currentCategories->begin(), currentCategories->end());
-        return thisObject;
-    }
-    Catch(Exception)
-    {
-        LogError("error occured");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::splice(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::toString(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return join(context, function, thisObject, 0, arguments, exception);
-}
-
-JSValueRef JSFeatureArray::unshift(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSFeatureArray::valueOf(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    return JSValueMakeUndefined(context);
-}
-}
-}
-}
diff --git a/src/standards/Tizen/Account/JSFeatureArray.h b/src/standards/Tizen/Account/JSFeatureArray.h
deleted file mode 100755 (executable)
index 0ce1f20..0000000
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file        JSFeatureArray.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _JS_FEATURE_ARRAY_H_
-#define _JS_FEATURE_ARRAY_H_
-
-#include <string>
-#include <vector>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/EventAccount.h>
-
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-typedef PrivateObjectT<FeatureListPtr>::Type
-JSFeatureArrayPrivate;
-
-class JSFeatureArray
-{
-  public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static JSClassRef getClassRef();
-
-    static JSObjectRef createArray(JSContextRef context,
-            const FeatureListPtr &categories);
-
-    static FeatureListPtr getFeatures(JSContextRef context,
-            JSObjectRef object);
-
-  private:
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context,
-            JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    static JSValueRef getLength(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-    static bool hasProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName);
-
-    static JSValueRef getProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-    static bool setProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef value,
-            JSValueRef* exception);
-
-    static JSValueRef concat(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef join(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef pop(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef push(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef reverse(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef shift(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef slice(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef sort(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef splice(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef toString(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef unshift(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-    static JSValueRef valueOf(JSContextRef context,
-            JSObjectRef function,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    static JSClassRef m_jsClassRef;
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This structure contains properties and callbacks that define a type of object.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This member variable contains the initialization values for the static properties of this class.
-     * The values are given according to the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-};
-}
-}
-}
-
-#endif /* _JS_ARRAY_H_ */
\ No newline at end of file
diff --git a/src/standards/Tizen/Account/ResponseDispatcher.cpp b/src/standards/Tizen/Account/ResponseDispatcher.cpp
deleted file mode 100755 (executable)
index 9172d79..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "ResponseDispatcher.h"
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include "AccountConverter.h"
-
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-AccountResponseDispatcher& AccountResponseDispatcher::getInstance()
-{
-    static AccountResponseDispatcher instance;
-    return instance;
-}
-
-AccountResponseDispatcher::AccountResponseDispatcher() :
-    AccountEventAnswerReceiverCreate(ThreadEnum::NULL_THREAD),
-    AccountEventAnswerReceiverAdd(ThreadEnum::NULL_THREAD),
-    AccountEventAnswerReceiverDelete(ThreadEnum::NULL_THREAD),
-    AccountEventAnswerReceiverUpdate(ThreadEnum::NULL_THREAD),
-    AccountEventAnswerReceiverFind(ThreadEnum::NULL_THREAD),
-    GetAccountServicesEventAnswerReceiver(ThreadEnum::NULL_THREAD)
-{
-    LogDebug("entered");
-}
-
-AccountResponseDispatcher::~AccountResponseDispatcher()
-{
-    LogDebug("entered");
-}
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventCreateAccountPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    Try
-    {
-        if (!cbm) {
-            LogDebug("no callback manager");
-            return;
-        }
-        if (event->getResult()) {
-            LogDebug("result success");
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(cbm->getContext());
-            cbm->callOnSuccess(converter->toJSValueRefAccount(event->getEvent()));
-            return;
-        }
-        LogDebug("result fail");
-    }
-    Catch(ConversionException)
-    {
-        LogError("cannot convert event");
-    }
-    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
-            cbm->getContext());
-    cbm->callOnError(errorObject);
-}
-
-
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventAddAccountPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    Try
-    {
-        if (!cbm) {
-            LogDebug("no callback manager");
-            return;
-        }
-        if (event->getResult()) {
-            LogDebug("result success");
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(cbm->getContext());
-            cbm->callOnSuccess(converter->toJSValueRefAccount(event->getEvent()));
-            return;
-        }
-        LogDebug("result fail");
-    }
-    Catch(ConversionException)
-    {
-        LogError("cannot convert event");
-    }
-    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
-            cbm->getContext());
-    cbm->callOnError(errorObject);
-}
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventDeleteAccountPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogDebug("no callback manager");
-        return;
-    }
-    if (event->getResult()) {
-        cbm->callOnSuccess();
-    } else {
-        JSValueRef errorObject;
-        if (event->getExceptionCode() ==
-            ExceptionCodes::NotFoundException) {
-            errorObject = JSDOMExceptionFactory::NotFoundException.make(
-                    cbm->getContext());
-        } else {
-            errorObject = JSDOMExceptionFactory::UnknownException.make(
-                    cbm->getContext());
-        }
-        cbm->callOnError(errorObject);
-    }
-}
-
-
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventUpdateAccountPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogDebug("no callback manager");
-        return;
-    }
-    if (event->getResult()) {
-        cbm->callOnSuccess();
-    } else {
-        JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
-                cbm->getContext());
-        cbm->callOnError(errorObject);
-    }
-}
-
-
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventFindAccountsPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("no callback manager");
-        return;
-    }
-    Try
-    {
-        if (event->getResult()) {
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(cbm->getContext());
-            const std::vector<EventAccountPtr> &results = event->getEvents();
-            JSValueRef result = converter->toJSValueRef(results);
-            cbm->callOnSuccess(result);
-            return;
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("error during processing answer");
-    }
-    JSValueRef errorObject =
-        JSDOMExceptionFactory::UnknownException.make(cbm->getContext());
-    cbm->callOnError(errorObject);
-}
-
-void AccountResponseDispatcher::OnAnswerReceived(
-        const IEventGetAccountServicesPtr &event)
-{
-    LogDebug("entered");
-    JSCallbackManagerPtr cbm =
-        DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-    if (!cbm) {
-        LogError("no callback manager");
-        return;
-    }
-//    Try
-//    {
-//        if (event->getResult()) {
-//
-//                     LogDebug("event->getResult() entered");
-//            AccountConverterFactory::ConverterType converter =
-//                AccountConverterFactory::getConverter(cbm->getContext());
-//            const std::vector<IAccountServicePtr> &results = event->getAccountServices();
-//            LogDebug("found AccountServices: " << results.size());
-//            JSValueRef result = converter->toJSValueRef(results);
-//            cbm->callOnSuccess(result);
-//            return;
-//        }
-//    }
-//    Catch(Exception)
-//    {
-//        LogError("error during processing answer");
-//    }
-    JSValueRef errorObject = JSDOMExceptionFactory::UnknownException.make(
-            cbm->getContext());
-    cbm->callOnError(errorObject);
-}
-
-
-
-}
-}
-}
diff --git a/src/standards/Tizen/Account/ResponseDispatcher.h b/src/standards/Tizen/Account/ResponseDispatcher.h
deleted file mode 100755 (executable)
index 8615a87..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#ifndef WRTPLUGINS_ACCOUNT_RESPONSEDISPATCHER_H_
-#define WRTPLUGINS_ACCOUNT_RESPONSEDISPATCHER_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <API/Account/IEventCreateAccount.h>
-#include <API/Account/IEventAddAccount.h>
-#include <API/Account/IEventDeleteAccount.h>
-#include <API/Account/IEventFindAccounts.h>
-#include <API/Account/IEventUpdateAccount.h>
-#include <API/Account/IEventGetAccountServices.h>
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-       
-typedef EventAnswerReceiver< IEventGetAccountServices >
-GetAccountServicesEventAnswerReceiver;
-
-typedef EventAnswerReceiver< IEventCreateAccount >
-AccountEventAnswerReceiverCreate;
-
-typedef EventAnswerReceiver< IEventAddAccount >
-AccountEventAnswerReceiverAdd;
-
-typedef EventAnswerReceiver< IEventDeleteAccount >
-AccountEventAnswerReceiverDelete;
-
-typedef EventAnswerReceiver< IEventUpdateAccount >
-AccountEventAnswerReceiverUpdate;
-
-typedef EventAnswerReceiver< IEventFindAccounts >
-AccountEventAnswerReceiverFind;
-
-
-class AccountResponseDispatcher :
-    public AccountEventAnswerReceiverCreate,
-    public AccountEventAnswerReceiverAdd,
-    public AccountEventAnswerReceiverDelete,
-    public AccountEventAnswerReceiverUpdate,
-    public AccountEventAnswerReceiverFind,
-    public GetAccountServicesEventAnswerReceiver
-
-{
-  public:
-    static AccountResponseDispatcher& getInstance();
-  private:
-    AccountResponseDispatcher();
-    virtual ~AccountResponseDispatcher();
-  protected:
-    void OnAnswerReceived(const IEventCreateAccountPtr &event);
-    void OnAnswerReceived(const IEventAddAccountPtr &event);   
-    void OnAnswerReceived(const IEventDeleteAccountPtr &event);
-    void OnAnswerReceived(const IEventUpdateAccountPtr &event);
-    void OnAnswerReceived(const IEventFindAccountsPtr &event);
-    void OnAnswerReceived(const IEventGetAccountServicesPtr &event);
-
-};
-}
-}
-}
-
-#endif
diff --git a/src/standards/Tizen/Account/config.xml b/src/standards/Tizen/Account/config.xml
deleted file mode 100755 (executable)
index 30fecc1..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" ?>
-<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
-<plugin-properties>
-    <library-name>libwrt-plugins-tizen-1.0-account.so</library-name>
-    <feature-install-uri>account.install.uri</feature-install-uri>
-    <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
-    <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
-    <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
-
-    <api-feature>
-        <name>http://tizen.org/api/account</name>
-        <device-capability>account.read</device-capability>
-        <device-capability>account.write</device-capability>
-    </api-feature>
-
-    <api-feature>
-        <name>http://tizen.org/api/account.read</name>
-        <device-capability>account.read</device-capability>
-    </api-feature>
-
-    <api-feature>
-        <name>http://tizen.org/api/account.write</name>
-        <device-capability>account.write</device-capability>
-    </api-feature> 
-</plugin-properties>
\ No newline at end of file
diff --git a/src/standards/Tizen/Account/old/JSAccountService.cpp b/src/standards/Tizen/Account/old/JSAccountService.cpp
deleted file mode 100755 (executable)
index d4fc69d..0000000
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/**
- * @file        JSAccountService.cpp
-* @author              Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/Converter.h>
-#include <API/Account/IAccountService.h>
-#include <API/Account/AccountFactory.h>
-#include <API/Account/IEventCreateAccount.h>
-#include <API/Account/IEventDeleteAccount.h>
-#include <API/Account/IEventFindAccounts.h>
-#include <API/Account/IEventUpdateAccount.h>
-
-
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/ScopedJSStringRef.h>
-#include <CommonsJavaScript/SecurityExceptions.h>
-
-
-#include "JSAccountManager.h"
-#include "AccountConverter.h"
-#include "JSAccountService.h"
-#include "JSAccount.h"
-#include "plugin_config.h"
-#include "ResponseDispatcher.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace {
-
-#define TIZEN_ACCOUNT_SERVICE_ATTRIBUTENAME  "AccountService"
-#define TIZEN_ACCOUNT_SERVICE_PROPERTY_TYPE  "type"
-#define TIZEN_ACCOUNT_SERVICE_PROPERTY_NAME  "name"
-
-
-/**
- * @throw InvalidArgumentException If not a callback nor JS null nor JS undefined.
- */
-JSValueRef getFunctionOrNull(JSContextRef ctx,
-        JSValueRef arg)
-{
-    if (Validator(ctx).isCallback(arg)) {
-               LogDebug("isCallback");
-        return arg;
-    } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
-
-       LogDebug("not Callback");
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-}
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-JSClassDefinition JSAccountService::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    TIZEN_ACCOUNT_SERVICE_ATTRIBUTENAME,
-    NULL,
-    m_property,
-    m_function,
-    initialize,
-    finalize,
-    NULL, //HasProperty,
-    NULL, //GetProperty,
-    NULL, //SetProperty,
-    NULL, //DeleteProperty,
-    NULL, //GetPropertyNames,
-    NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    NULL, //HasInstance,
-    NULL //ConvertToType
-};
-
-JSStaticValue JSAccountService::m_property[] = {
-    { TIZEN_ACCOUNT_SERVICE_PROPERTY_TYPE, JSAccountService::getPropertyType,
-      NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_ACCOUNT_SERVICE_PROPERTY_NAME, JSAccountService::getPropertyName,
-      NULL, kJSPropertyAttributeReadOnly },
-    { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSAccountService::m_function[] = {
-    { "createAccount", createAccount, kJSPropertyAttributeNone },
-    { "addAccount", addAccount, kJSPropertyAttributeNone },
-    { "updateAccount", updateAccount, kJSPropertyAttributeNone },
-    { "deleteAccount", deleteAccount, kJSPropertyAttributeNone },
-    { "getAccounts", findAccounts, kJSPropertyAttributeNone },
-
-    { 0, 0, 0 }
-};
-
-JSClassRef JSAccountService::m_jsClassRef = JSClassCreate(JSAccountService::getClassInfo());
-
-void JSAccountService::initialize(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("entered");
-    AccountServicePrivObject *priv =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        //create default instance
-        LogWarning("create default instance");
-        IAccountServicePtr account =
-            AccountFactory::getInstance().createAccountObject();
-        priv = new AccountServicePrivObject(context, account);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            delete priv;
-        }
-    } else {
-        //can be set by JSMakeObject inside getCalendars method
-        LogDebug("private object alrerady exists");
-    }
-}
-
-void JSAccountService::finalize(JSObjectRef object)
-{
-    LogDebug("entered");
-    AccountServicePrivObject *priv =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(object));
-    delete priv;
-}
-
-const JSClassRef JSAccountService::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-const JSClassDefinition* JSAccountService::getClassInfo()
-{
-    return &m_classInfo;
-}
-
-JSValueRef JSAccountService::updateAccount(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-
-    AccountServicePrivObject *privateObject =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-
-//    AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(privateObject->getContext(),ACCOUNT_FUNCTION_API_UPDATE_ACCOUNT);
-
-    Try
-    {
-        IAccountServicePtr accountservice = getAccountService(context, thisObject, exception);
-
-
-         if (argumentCount != 1) {
-            LogError("Wrong number of parameters.");
-            return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-        }
-
-
-
-        if (JSValueIsUndefined(context, arguments[0]) ||JSValueIsNull(context, arguments[0])) {
-            return JSDOMExceptionFactory::InvalidValuesException.make(privateObject->getContext());}
-
-
-       JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-
-          EventAccountPtr account = JSAccount::getIEvent(arg);
-        if (!JSAccount::validate(context, arg, exception)) {
-            LogError("account parameter contains errors");
-
-            return JSValueMakeNull(context);
-        }
-
-        AccountConverterFactory::ConverterType converter =AccountConverterFactory::getConverter(context);
-        //EventAccountPtr account = converter->toAccount(arguments[0]);
-
-        if (!account) {
-            LogError("updateAccount: Failed to update account");
-
-            return JSDOMExceptionFactory::NotFoundException.make(privateObject->getContext());
-        }
-
-        IEventUpdateAccountPtr dplEvent(new IEventUpdateAccount());
-        dplEvent->setEvent(account);
-        dplEvent->setForSynchronousCall();
-        accountservice->updateAccount(dplEvent);
-
-        if (dplEvent->getResult()) {
-            return JSValueMakeNull(context);
-        } else {
-            LogError("Unknow error occured.");
-            return JSDOMExceptionFactory::UnknownException.make(context, exception);
-        }
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogError("Invalid argument");
-        return JSDOMExceptionFactory::TypeMismatchException.make(context,
-                                                              exception);
-    }
-    Catch(Exception)
-    {
-        LogError("unknow error occured");
-    }
-    return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountService::deleteAccount(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    AccountServicePrivObject *privateObject =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-    JSCallbackManagerPtr cbm(NULL);
-
-//    AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(privateObject->getContext(),ACCOUNT_FUNCTION_API_DELETE_ACCOUNT);
-    Try
-    {
-        IAccountServicePtr accountservice = getAccountService(context, thisObject, exception);
-        if (argumentCount!=1) {
-            LogError("Wrong number of parameters.");
-            return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-        }
-
-
-
-        //if not able to convert to int then it won't be found
-        //TODO: Calendar has EventID function. I need to check this later
-        int id = 0;
-        Try
-        {
-
-             AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-               id = converter->toInt(converter->toString(arguments[0]));
-        }
-        Catch(Exception)
-        {
-            LogError("invalid value of id parameter, account will not be found");
-             return JSDOMExceptionFactory::NotFoundException.make(privateObject->getContext());
-        }
-        //abstract API use event object as a filter, but only id
-        //attribute is revelant during delete operation.
-        EventAccountPtr account(new EventAccount());
-        account->setID(id);
-        IEventDeleteAccountPtr dplEvent(new IEventDeleteAccount());
-        dplEvent->setEvent(account);
-
-        dplEvent->setForSynchronousCall();
-        accountservice->deleteAccount(dplEvent);
-
-         if (dplEvent->getResult()) {
-            return JSValueMakeNull(context);
-        } else {
-            if (dplEvent->getExceptionCode() == ExceptionCodes::NotFoundException) {
-                return JSDOMExceptionFactory::NotFoundException.make(context);
-            } else {
-                return JSDOMExceptionFactory::UnknownException.make(context);
-            }
-        }
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogError("Invalid argument");
-        return JSDOMExceptionFactory::TypeMismatchException.make(context,
-                                                              exception);
-    }
-    Catch(Exception)
-    {
-        LogError("unknow error occured");
-    }
-
-    return JSValueMakeNull(context);
-}
-
-JSValueRef JSAccountService::createAccount(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-
-    AccountServicePrivObject *privateObject =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-
-    Try
-    {
-        // We need to use the global context for the event creation to invoke TZDate functions.
-        JSObjectRef jsObject = JSObjectMake(privateObject->getContext(),
-                                            JSAccount::getClassRef(), NULL);
-        if (jsObject == NULL) {
-            LogError("CreateEvent: failed to create object reference");
-            return JSDOMExceptionFactory::UnknownException.make(context, exception);
-        }
-        if (argumentCount >= 1 &&
-            !JSValueIsUndefined(context, arguments[0]) &&
-            !JSValueIsNull(context, arguments[0])) {
-            //set properties if declared
-            LogDebug("setting properties");
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(context);
-            EventAccountPtr event = converter->toAccount(arguments[0]);
-
-
-            JSAccount::setIEvent(event, privateObject->getContext(), jsObject);
-        } else {
-
-            //TODO: check if No default value for Account
-             //set default values
-             /*
-             EventAccountPtr account = JSAccount::getIEvent(jsObject);
-            event->setStartTime(std::time(NULL));
-            event->setEndTime(event->getStartTime());
-            event->setStatus(CalendarEvent::CONFIRMED_STATUS);
-            */
-        }
-        return static_cast<JSValueRef>(jsObject);
-    }
-    Catch(ConversionException)
-    {
-        LogError("conversion error");
-        return JSDOMExceptionFactory::InvalidValuesException.make(context,
-                                                               exception);
-    }
-    Catch(Exception)
-    {
-        LogError("error during execution");
-    }
-    return JSDOMExceptionFactory::UnknownException.make(context, exception);
-}
-
-
-JSValueRef JSAccountService::addAccount(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-
-    AccountServicePrivObject *privateObject =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(thisObject));
-    LogDebug("jcpark 1");
-    assert(privateObject);
-    //JSCallbackManagerPtr cbm(NULL);
-   LogDebug("jcpark 2");
-       //TODO: down here!! why?
-     //ACCOUNT_CHECK_ACCESS( privateObject->getContext(),ACCOUNT_FUNCTION_API_ADD_ACCOUNT);
-    Try
-    {
-        LogDebug("1");
-        IAccountServicePtr accountservice = getAccountService(context, thisObject, NULL);
-         LogDebug("2");
-        if (argumentCount != 1) {
-            LogError("Wrong number of parameters.");
-            return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-        }
-       LogDebug("3");
-
-               if (JSValueIsUndefined(context, arguments[0]) ||
-            JSValueIsNull(context, arguments[0])) {
-            return JSDOMExceptionFactory::InvalidValuesException.make(
-                                 privateObject->getContext());
-            return JSValueMakeNull(context);}
-    LogDebug("4");
-             LogDebug("setting properties");
-            AccountConverterFactory::ConverterType converter =
-            AccountConverterFactory::getConverter(context);
-            EventAccountPtr account = converter->toAccount(arguments[0]);
-
-            if (!account) {
-            LogError("Failed to get an event.");
-            return JSDOMExceptionFactory::UnknownException.make(privateObject->getContext());}
-
-                IEventAddAccountPtr dplEvent(new IEventAddAccount());
-             dplEvent->setEvent(account);
-             dplEvent->setForSynchronousCall();
-             accountservice->addAccount(dplEvent);
-
-               if (dplEvent->getResult()) {
-            return converter->toJSValueRef(dplEvent->getEvent()->getID());
-             } else {
-            return JSDOMExceptionFactory::UnknownException.make(context, exception);}
-
-    }
-    Catch(InvalidArgumentException)
-    {
-        LogError("Invalid argument");
-        return JSDOMExceptionFactory::TypeMismatchException.make(context,
-                                                              exception);
-    }
-    Catch(Exception)
-    {
-        LogError("Unexpected error during adding account");
-         return JSDOMExceptionFactory::UnknownException.make(privateObject->getContext());
-    }
-    return JSValueMakeNull(context);
-}
-JSValueRef JSAccountService::findAccounts(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    AccountServicePrivObject *privateObject =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-//    AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(privateObject->getContext(),ACCOUNT_FUNCTION_API_FIND_ACCOUNTS);
-    JSCallbackManagerPtr cbm(NULL);
-    Try
-    {
-    LogDebug("2");
-        IAccountServicePtr account = getAccountService(context, thisObject, exception);
-        if (argumentCount < 1) {
-            LogError("No callback parameters");
-            return JSDOMExceptionFactory::TypeMismatchException.make(context,
-                                                                  exception);
-        }
-               LogDebug("3");
-        JSValueRef onError =
-            (argumentCount >
-             1 ? getFunctionOrNull(context, arguments[1]) : NULL);
-        JSContextRef globalContext = privateObject->getContext();
-       LogDebug("4");
-
-        cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-//        ASYNC_CBM_ACCESS_STATUS_HANDLER(status, context, cbm);
-
-        Validator validator(context);
-        if (validator.isCallback(arguments[0])) {
-            cbm->setOnSuccess(arguments[0]);
-        } else if (JSValueIsNull(context,
-                                 arguments[0]) ||
-                   JSValueIsUndefined(context, arguments[0])) {
-            cbm->callOnError(JSDOMExceptionFactory::InvalidValuesException.make(
-                                 context));
-            return JSValueMakeNull(context);
-        } else {
-            return JSDOMExceptionFactory::TypeMismatchException.make(context,
-                                                                  exception);
-        }
-        //setup filters
-   /*     EventFilterPtr filter(NULL);
-        if (argumentCount >= 3) {
-            LogDebug("setting some filters");
-            AccountConverterFactory::ConverterType converter =
-                AccountConverterFactory::getConverter(context);
-            Try
-            {
-                if (!JSValueIsUndefined(context,
-                                        arguments[2]) &&
-                    !JSValueIsNull(context, arguments[2])) {
-                    filter = converter->toEventFilter(arguments[2]);
-                }
-            }
-            Catch(InvalidArgumentException)
-            {
-                LogError("Invalid argument");
-                filter.Reset();
-            }
-        }*/
-        LogDebug("6");
-        IEventFindAccountsPtr dplEvent(new IEventFindAccounts());
-        dplEvent->setPrivateData(
-            DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(
-            &AccountResponseDispatcher::getInstance());
-      //  dplEvent->setFilter(filter);
-        account->findAccounts(dplEvent);
-
-        return makePendingOperation(cbm->getContext(), dplEvent);
-    }
-    Catch(InvalidArgumentException)
-    {
-        return JSDOMExceptionFactory::TypeMismatchException.make(
-                   context, exception);
-    }
-    Catch(ConversionException)
-    {
-        LogError("Invalid argument");
-        return JSDOMExceptionFactory::TypeMismatchException.make(
-                   context, exception);
-    }
-    Catch(Exception)
-    {
-        LogError("unknow error occured");
-    }
-    if (NULL != cbm) {
-        cbm->callOnError(JSDOMExceptionFactory::UnknownException.make(
-                             privateObject->getContext()));
-    }
-    return JSValueMakeNull(context);
-}
-
-IAccountServicePtr JSAccountService::getAccountService(JSContextRef ctx,
-        const JSObjectRef object,
-        JSValueRef* exception)
-{
-    AccountServicePrivObject *priv =
-        static_cast<AccountServicePrivObject*>(JSObjectGetPrivate(object));
-    if (priv) {
-        return priv->getObject();
-    }
-    ThrowMsg(NullPointerException, "Private object is NULL.");
-}
-
-JSValueRef JSAccountService::getPropertyName(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    Try
-    {
-        IAccountServicePtr accountservice = getAccountService(context, object, exception);
-        Converter converter(context);
-        return converter.toJSValueRef(accountservice->getName());
-    }
-    Catch(Exception)
-    {
-        LogError("error during executing a function");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSAccountService::getPropertyType(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    Try
-    {
-        IAccountServicePtr accountservice = getAccountService(context, object, exception);
-        int accountserviceType = accountservice->getType();
-        Converter converter(context);
-        switch (accountserviceType) {
-/*        case IAccountService::TYPE_SIM:
-            return converter.toJSValueRef(
-                       JSAccountManager::TYPE_SIM);
-            break;*/
-        case IAccountService::TYPE_INTERNET:
-            return converter.toJSValueRef(JSAccountManager::TYPE_INTERNET);
-            break;
-        default:
-            LogWarning("invalid type of accountservice");
-            break;
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("error during executing a function");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-}
-}
-}
diff --git a/src/standards/Tizen/Account/old/JSAccountService.h b/src/standards/Tizen/Account/old/JSAccountService.h
deleted file mode 100755 (executable)
index 523dec3..0000000
+++ /dev/null
@@ -1,163 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @file        JSAccountService.h
- * @author      Jihwa Park (jh7979.park@samsung.com)
- * @author      Sangtai Kim
- * @version     0.1
- */
-
-#ifndef _JS_TIZEN_ACCOUNTSERVICE_H_
-#define _JS_TIZEN_ACCOUNTSERVICE_H_
-
-#include <vector>
-#include <string>
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/IAccountService.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-typedef PrivateObject<IAccountServicePtr,
-                               NoOwnership> AccountServicePrivObject;
-
-class JSAccountService
-{
-  public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static const JSClassRef getClassRef();
-
-  private:
-    /**
-     * This member variable contains the values which has to be passed
-     * when the this class is embedded into JS Engine.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This member variable contains the initialization values for the
-     * properties of this class. The values are given according to
-     * the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context,
-            JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    static JSValueRef getPropertyName(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-    static JSValueRef getPropertyType(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-
-
-    /**
-     * Update an event.
-     */
-    static JSValueRef updateAccount(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
-     * Delete a calendar event.
-     */
-    static JSValueRef deleteAccount(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
-     * Search for calendar events.
-     */
-    static JSValueRef findAccounts(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
-     * Create Events
-     */
-    static JSValueRef createAccount(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-
-  /**
-     * Add Event
-     */
-    static JSValueRef addAccount(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-     /**
-     *  Returns calendar stored as private object
-     */
-    static IAccountServicePtr getAccountService(JSContextRef ctx,
-            const JSObjectRef object,
-            JSValueRef* exception);
-
-
-};
-}
-}
-}
-
-#endif /* _JS_TIZEN_ACCOUNTSERVICE_H_ */
-
diff --git a/src/standards/Tizen/Account/plugin_config.cpp b/src/standards/Tizen/Account/plugin_config.cpp
deleted file mode 100755 (executable)
index b870d5f..0000000
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <Commons/FunctionDefinition.h>
-#include <Commons/FunctionDeclaration.h>
-#include <iostream>
-#include <Commons/Exception.h>
-#include <dpl/exception.h>
-#include <map>
-
-#include "plugin_config.h"
-
-#define ACCOUNT_FEATURE_API "http://tizen.org/api/account"
-#define ACCOUNT_FEATURE_API_READ  "http://tizen.org/api/account.read"
-#define ACCOUNT_FEATURE_API_WRITE "http://tizen.org/api/account.write"
-
-#define ACCOUNT_DEVICE_CAP_READ "account.read"
-#define ACCOUNT_DEVICE_CAP_WRITE "account.write"
-
-//using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-//using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-
-static FunctionMapping createAccountFunctions();
-
-static FunctionMapping AccountFunctions =
-    createAccountFunctions();
-
-DEFINE_FUNCTION_GETTER(Account, AccountFunctions);
-
-static FunctionMapping createAccountFunctions()
-{
-
-    /**
-     * Device capabilities
-     */
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_READ, ACCOUNT_DEVICE_CAP_READ);
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_ACCOUNT_WRITE, ACCOUNT_DEVICE_CAP_WRITE);
-
-    ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
-
-    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_READ);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_READ, DEVICE_CAP_ACCOUNT_READ);
-
-    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_ACCOUNT_WRITE);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_ACCOUNT_WRITE, DEVICE_CAP_ACCOUNT_WRITE);
-
-    /**
-     * Api Features
-     */
-    ACE_CREATE_FEATURE(FEATURE_ACCOUNT, ACCOUNT_FEATURE_API);
-    ACE_CREATE_FEATURE(FEATURE_ACCOUNT_READ, ACCOUNT_FEATURE_API_READ);
-    ACE_CREATE_FEATURE(FEATURE_ACCOUNT_WRITE, ACCOUNT_FEATURE_API_WRITE);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_READ);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ_WRITE, FEATURE_ACCOUNT_WRITE);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_READ);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ, FEATURE_ACCOUNT_READ);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT_WRITE);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_WRITE, FEATURE_ACCOUNT_WRITE);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_ACCOUNT);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT, FEATURE_ACCOUNT);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_READ);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_ACCOUNT_READ,FEATURE_ACCOUNT_READ);
-
-    ACE_CREATE_FEATURE_LIST(ACCOUNT_FEATURES_WRITE);
-    ACE_ADD_API_FEATURE(ACCOUNT_FEATURES_WRITE,FEATURE_ACCOUNT_WRITE);
-
-    /**
-     * Functions
-     */
-
-    FunctionMapping accountMapping;
-
-    //addAccount
-    AceFunction addAccountFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_CREATE_ACCOUNT,
-            ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
-            ACCOUNT_FEATURES_ACCOUNT_READ_WRITE,
-            EMPTY_DEVICE_LIST);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_ADD_ACCOUNT,
-                               addAccountFunc));
-
-    //Add listener
-    AceFunction listenerAccountsFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_ADD_LISTENER_ACCOUNTS,
-            ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS,
-                               listenerAccountsFunc));
-
-    //Remove listener
-    AceFunction removelistenerAccountsFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_REMOVE_LISTENER_ACCOUNTS,
-            ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS,
-                               removelistenerAccountsFunc));
-
-    //Get Account by ID
-    AceFunction getAccountbyId = ACE_CREATE_FUNCTION(
-            FUNCTION_GET_ACCOUNT_BY_ID,
-            ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID,
-                               getAccountbyId));
-
-    //Get ServiceTypes by ID
-    AceFunction getServicetypesbyId = ACE_CREATE_FUNCTION(
-            FUNCTION_GET_SERVICETYPE_BY_ID,
-            ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID,
-                               getServicetypesbyId));
-
-    //Get Provider by ID
-    AceFunction getProviderbyId = ACE_CREATE_FUNCTION(
-            FUNCTION_GET_PROVIDER_BY_ID,
-            ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID,
-                               getProviderbyId));
-
-    //Find Accounts by ServiceType
-    AceFunction findAccountsbyServicetype = ACE_CREATE_FUNCTION(
-            FUNCTION_FIND_ACCOUNTS_BY_SERVICETYPE,
-            ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE,
-                               findAccountsbyServicetype));
-
-    //Find Accounts by Tags
-    AceFunction findAccountsbyTags = ACE_CREATE_FUNCTION(
-            FUNCTION_FIND_ACCOUNTS_BY_TAGS,
-            ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS,
-                               findAccountsbyTags));
-
-    //Find Accounts
-       AceFunction findAccounts = ACE_CREATE_FUNCTION(
-                       FUNCTION_FIND_ACCOUNTS,
-                       ACCOUNT_FUNCTION_API_FIND_ACCOUNTS,
-                       ACCOUNT_FEATURES_ACCOUNT_READ,
-                       DEVICE_LIST_ACCOUNT_READ);
-
-       accountMapping.insert(std::make_pair(
-                                                          ACCOUNT_FUNCTION_API_FIND_ACCOUNTS,
-                                                          findAccounts));
-
-    //Find Services by Tags
-    AceFunction findServicesbyTags = ACE_CREATE_FUNCTION(
-            FUNCTION_FIND_SERVICES_BY_TAGS,
-            ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS,
-                               findServicesbyTags));
-
-//Find Services
-       AceFunction findServices = ACE_CREATE_FUNCTION(
-                       FUNCTION_FIND_SERVICES,
-                       ACCOUNT_FUNCTION_API_FIND_SERVICES,
-                       ACCOUNT_FEATURES_ACCOUNT_READ,
-                       DEVICE_LIST_ACCOUNT_READ);
-
-       accountMapping.insert(std::make_pair(
-                                                          ACCOUNT_FUNCTION_API_FIND_SERVICES,
-                                                          findServices));
-
-    //Find Providers
-    AceFunction findProviders = ACE_CREATE_FUNCTION(
-            FUNCTION_FIND_PROVIDERS,
-            ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_FIND_PROVIDERS,
-                               findProviders));
-
-    //Find ServiceTypes
-    AceFunction findServicetypes = ACE_CREATE_FUNCTION(
-            FUNCTION_FIND_SERVICETYPES,
-            ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
-            ACCOUNT_FEATURES_ACCOUNT_READ,
-            DEVICE_LIST_ACCOUNT_READ);
-
-    accountMapping.insert(std::make_pair(
-                               ACCOUNT_FUNCTION_API_FIND_SERVICETYPES,
-                               findServicetypes));
-
-    //getServiceByName
-       AceFunction getServiceByName = ACE_CREATE_FUNCTION(
-                                       FUNCTION_GET_SERVICE_BY_NAME,
-                                       ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
-                                       ACCOUNT_FEATURES_ACCOUNT_READ,
-                                       DEVICE_LIST_ACCOUNT_READ);
-       accountMapping.insert(std::make_pair(
-                                       ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME,
-                                       getServiceByName));
-
-       //getServiceById
-               AceFunction getServiceById = ACE_CREATE_FUNCTION(
-                                               FUNCTION_GET_SERVICE_BY_ID,
-                                               ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
-                                               ACCOUNT_FEATURES_ACCOUNT_READ,
-                                               DEVICE_LIST_ACCOUNT_READ);
-               accountMapping.insert(std::make_pair(
-                                               ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID,
-                                               getServiceById));
-
-    return accountMapping;
-}
-}
-}
-}
diff --git a/src/standards/Tizen/Account/plugin_config.h b/src/standards/Tizen/Account/plugin_config.h
deleted file mode 100755 (executable)
index 23bdc4a..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _ACCOUNT_PLUGIN_CONFIG_H_
-#define _ACCOUNT_PLUGIN_CONFIG_H_
-
-#include <string>
-#include <Commons/FunctionDeclaration.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Account{
-
-#define ACCOUNT_FUNCTION_API_ADD_ACCOUNT                  "addAccount"
-#define ACCOUNT_FUNCTION_API_ADD_LISTENER_ACCOUNTS        "addAccountListener"
-#define ACCOUNT_FUNCTION_API_REMOVE_LISTENER_ACCOUNTS     "removeAccountListener"
-#define ACCOUNT_FUNCTION_API_GET_ACCOUNT_BY_ID            "getAccountById"
-#define ACCOUNT_FUNCTION_API_GET_SERVICETYPE_BY_ID        "getServiceTypeById"
-#define ACCOUNT_FUNCTION_API_GET_PROVIDER_BY_ID           "getProviderById"
-#define ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_SERVICETYPE "findAccountsByServiceType"
-#define ACCOUNT_FUNCTION_API_FIND_ACCOUNTS_BY_TAGS        "findAccountsByTags"
-#define ACCOUNT_FUNCTION_API_FIND_ACCOUNTS                "findAccounts"
-#define ACCOUNT_FUNCTION_API_FIND_SERVICES_BY_TAGS        "findServicesByTags"
-#define ACCOUNT_FUNCTION_API_FIND_SERVICES                "findServices"
-#define ACCOUNT_FUNCTION_API_FIND_PROVIDERS               "findProviders"
-#define ACCOUNT_FUNCTION_API_FIND_SERVICETYPES            "findServiceTypes"
-#define ACCOUNT_FUNCTION_API_GET_SERVICE_BY_NAME          "getServiceByName"
-#define ACCOUNT_FUNCTION_API_GET_SERVICE_BY_ID            "getServiceById"
-
-
-
-DECLARE_FUNCTION_GETTER(Account);
-
-// TODO : should confirm getAccountFunctionData
-#define ACCOUNT_CHECK_ACCESS(globalContext, functionName)                     \
-    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
-        getAccountFunctionData,           \
-        functionName)
-
-}
-}
-}
-
-#endif //  _CALENDAR_PLUGIN_CONFIG_H_
diff --git a/src/standards/Tizen/Account/plugin_initializer.cpp b/src/standards/Tizen/Account/plugin_initializer.cpp
deleted file mode 100755 (executable)
index d3e67f5..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-/*
- * @author      Karol Majewski (k.majewski@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#include <dpl/log/log.h>
-
-#include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
-#include <Commons/Exception.h>
-#include "JSAccountManager.h"
-#include "JSAccount.h"
-
-using namespace TizenApis::Api::Account;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-void on_widget_start_callback(int widgetId,
-        JavaScriptContext context,
-        const engine_interface_t *interface)
-{
-    LogDebug("[Tizen\\account] on_widget_start_callback (" << widgetId << ")");
-    Try
-    {
-        WrtWrappersMgr::getInstance().registerWrapper(
-            widgetId,
-            context,
-            interface);
-    }
-    Catch(Exception)
-    {
-        LogError("Wrt wrapper registration failed");
-    }
-}
-
-void on_widget_stop_callback(int widgetId)
-{
-    LogDebug("[Tizen\\account] on_widget_stop_callback (" << widgetId << ")");
-    WrtWrappersMgr::getInstance().removeWrapper(widgetId);
-}
-
-PLUGIN_ON_WIDGET_START(on_widget_start_callback)
-PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
-
-PLUGIN_CLASS_MAP_BEGIN
-       PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ,
-               "account",
-               TizenApis::Tizen1_0::Account::JSAccountManager::getClassRef(),
-               NULL)
-PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ,
-               "Account",
-               TizenApis::Tizen1_0::Account::JSAccount::getClassRef(),
-               NULL)
-PLUGIN_CLASS_MAP_END
-
-#undef PIM
index 23d39d5..2e9dcd0 100755 (executable)
@@ -88,6 +88,8 @@ std::vector<std::string> AlarmConverter::convertFlagToDaysOfTheWeek(int byDayVal
         daysOfTheWeek.push_back("FR");
     if(byDayValue & ALARM_WEEK_FLAG_SATURDAY)
         daysOfTheWeek.push_back("SA");
+
+    return daysOfTheWeek;
 }
 
 
@@ -117,7 +119,6 @@ bool AlarmConverter::toAlarmAbsolutePtr(int id, service_h handle, AlarmAbsoluteP
 {   
     char* dateString;
     char* alarmType;
-    int delay;
     struct tm date;
     int bydayValue = 0; 
     int error = ALARM_ERROR_NONE;
@@ -211,6 +212,57 @@ int AlarmConverter::toNativeInterval(std::string freq, std::string interval)
     return freqInSecond * intervalValue;
 }
 
+bool AlarmConverter::toAlarmService(service_h service, ApplicationServicePtr appservice)
+    {
+    if (appservice->getOperation().compare("") != 0) {
+       LogDebug("operation is "<<appservice->getOperation());
+       service_set_operation(service, appservice->getOperation().c_str() );
+    } else {
+       LogDebug("Error. operation is madatory field. cannot be null");
+       return false;
+    }
+
+    if (appservice->getUri().compare("") != 0) {
+       LogDebug("uri is not null");
+       service_set_uri(service, appservice->getUri().c_str() );
+    }
+
+    if (appservice->getMime().compare("") != 0) {
+       LogDebug("mime is "<<appservice->getMime());
+       service_set_mime(service, appservice->getMime().c_str() );
+    }
+
+    LogDebug(">>> appservice->getServiceDataArray");
+    std::vector<ApplicationServiceDataPtr> serviceDataArray = appservice->getServiceDataArray();
+
+    if (!serviceDataArray.empty()) {
+       const char* key = NULL;
+       const char** arr = NULL;                                
+       LogDebug("serviceDataArray.size() : "<<serviceDataArray.size());
+
+       for (size_t i = 0; i < serviceDataArray.size(); ++i) {
+               key = serviceDataArray.at(i)->getKey().c_str();
+               if (key == NULL) {
+                    return false;
+               }
+               std::vector<std::string> valueArray = serviceDataArray.at(i)->getValue();
+               size_t size = valueArray.size();
+               
+               arr = (const char**)calloc(sizeof(char*), size);
+
+               for (size_t j = 0; j < size; j++) {
+                       arr[j] = valueArray.at(j).c_str();
+               }
+               
+               service_add_extra_data_array(service, key, arr, size);
+
+               if (arr)
+                       free(arr);
+       }
+    }
+    return true;
+}
+
 
 }
 }
index 8815ce8..949c32d 100755 (executable)
@@ -23,6 +23,9 @@
 #include <app.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <Tizen/Application/JSApplicationService.h>
+#include <API/Application/ApplicationService.h>
+#include <Tizen/Application/ApplicationConverter.h>
 #include "JSAlarmAbsolute.h"
 #include "AlarmAbsolute.h"
 #include "JSAlarmRelative.h"
@@ -36,6 +39,8 @@ namespace Alarm {
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Tizen1_0::Alarm;
+using namespace TizenApis::Tizen1_0::Application;
+using namespace TizenApis::Api::Application;
 
 class AlarmConverter : public WrtDeviceApis::CommonsJavaScript::Converter
 {
@@ -53,6 +58,7 @@ public:
     bool toAlarmAbsolutePtr(int id, service_h handle, AlarmAbsolutePtr ptr);
     bool toAlarmRelativePtr(int id, service_h handle, AlarmRelativePtr ptr);
     int toNativeInterval(std::string freq, std::string interval);
+    bool toAlarmService(service_h alarm_service, ApplicationServicePtr ptr);
 };
 
 typedef ConverterFactory<AlarmConverter> AlarmConverterFactory;
index f3026c0..3103670 100755 (executable)
@@ -7,6 +7,7 @@ include_directories(${alarm_INCLUDE_DIRS})
 set(CMAKE_INSTALL_RPATH
                ${CMAKE_INSTALL_RPATH}
                ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+               ${CMAKE_INSTALL_PREFIX}/tizen-1.0-application
 )
 
 set(SRCS
@@ -28,6 +29,7 @@ set(CMAKE_INSTALL_RPATH
 add_library(${TARGET_NAME} SHARED ${SRCS})
 target_link_libraries(${TARGET_NAME}
   wrt-plugins-tizen-1.0-tizen-impl
+  wrt-plugins-tizen-1.0-application-impl
   ${LIBS_COMMON}
   ${alarm_LIBRARIES}
 )
index 1c10efd..5e096e6 100755 (executable)
@@ -117,10 +117,7 @@ bool JSAlarmAbsolute::hasInstance(JSContextRef context, JSObjectRef constructor,
 
 JSObjectRef JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    LogError("[ILOVEFILM] Enter constructor");
-
     struct tm date;
-    int interval =0;
     AlarmConverter converter(ctx);
     Validator validator(ctx);
 
@@ -129,12 +126,12 @@ JSObjectRef JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRef construct
 
         if(argumentCount < 1)
         {
-            ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong argumentCount");
+            ThrowMsg(WrtDeviceApis::Commons::ConversionException, "");
         }
 
         if(!validator.isDate(arguments[0]))
         {   
-            ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"Invalid Date");
+            ThrowMsg(WrtDeviceApis::Commons::ConversionException, "");
         }
         
         date = converter.toDateTm(arguments[0]);
@@ -142,15 +139,17 @@ JSObjectRef JSAlarmAbsolute::constructor(JSContextRef ctx, JSObjectRef construct
 
         if(argumentCount >= 2)
         {
-            if(JSValueIsNumber(ctx, arguments[1]))
-            {
-                int interval = JSValueToNumber(ctx, arguments[1], exception);
-                privateData->setInterval(interval);            
-            } else if(JSIsArrayValue(ctx, arguments[1])) {
+            if(JSIsArrayValue(ctx, arguments[1])) {
                 std::vector<std::string> daysOfTheWeek = converter.toVectorOfStrings(arguments[1]);
                 if(daysOfTheWeek.size() >0) {
                     privateData->setByDayRecurrence(daysOfTheWeek);    
                 }
+            } else {
+                int interval  = converter.toInt(arguments[1]);
+                if(interval <0) {
+                    ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"Invalid period");
+                }
+                privateData->setInterval(interval);
             }
         }
         return JSValueToObject(ctx, createJSObject(ctx, privateData), exception);
@@ -173,11 +172,11 @@ AlarmAbsolutePtr JSAlarmAbsolute::getPrivData(JSObjectRef object)
 {
     JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(object));
     if (!priv) {
-       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Private object is null");
     }
     AlarmAbsolutePtr result = priv->getObject();
     if (!result) {
-       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Private object is null");
     }
     return result;
 }
@@ -231,7 +230,8 @@ JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date)
 JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception)
 {   
     LogError("GContext = " << TizenApis::Tizen1_0::Alarm::JSAlarmManager::gContext);
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(TizenApis::Tizen1_0::Alarm::JSAlarmManager::gContext, ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(
+            ALARM_FUNCTION_API_GET_NEXT_SCHEDULED_DATE);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
     struct tm date;
@@ -249,6 +249,8 @@ JSValueRef JSAlarmAbsolute::getNextScheduledDate( JSContextRef ctx, JSObjectRef
             return JSValueMakeNull(ctx);
         }
         return result;
+    } Catch (WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     } Catch(WrtDeviceApis::Commons::Exception) {
         return JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
     }
@@ -261,9 +263,7 @@ JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx,
                JSValueRef* exception)
 {
     Converter converter(ctx);
-    int id;
     struct tm date;
-    time_t temp;
     Try
     {
         AlarmAbsolutePtr privateData = getPrivData(object);
@@ -282,6 +282,8 @@ JSValueRef JSAlarmAbsolute::getDate(JSContextRef ctx,
 
         JSObjectRef result = JSObjectMakeDate(ctx, 6, args, exception);
         return result;
+    } Catch (WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     } Catch(WrtDeviceApis::Commons::Exception) {
         return JSValueMakeUndefined(ctx);
     }
@@ -298,12 +300,16 @@ JSValueRef JSAlarmAbsolute::getId(JSContextRef ctx,
     Try
     {
         AlarmAbsolutePtr privateData = getPrivData(object);
+        Converter converter(ctx);
         id = privateData->getId();
         if(id >= 0) {
-            return converter.toJSValueRef(id);
+            std::string strId = converter.toString(id);
+            return converter.toJSValueRef(strId);
         } else {
             return JSValueMakeNull(ctx);
         }
+    } Catch (WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     } Catch(WrtDeviceApis::Commons::Exception) {
         return JSValueMakeNull(ctx);
     }
@@ -329,6 +335,8 @@ JSValueRef JSAlarmAbsolute::getInterval(JSContextRef ctx,
         } else {
             return JSValueMakeNull(ctx);    
         }
+    } Catch (WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     } Catch(WrtDeviceApis::Commons::Exception) {
             return JSValueMakeNull(ctx);    
     }   
@@ -363,6 +371,8 @@ JSValueRef JSAlarmAbsolute::getDaysOfTheWeek(JSContextRef ctx,
             }
         }
         return jsResult;
+    } Catch (WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     } Catch(WrtDeviceApis::Commons::Exception) {
         return JSCreateArrayObject(ctx, 0, NULL);
     }
index b3f0ad2..93dc8c9 100755 (executable)
@@ -26,6 +26,9 @@
 #include <Commons/Exception.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Application/JSApplicationService.h>
+#include <API/Application/ApplicationService.h>
+#include <Tizen/Application/ApplicationConverter.h>
 
 #include "plugin_config.h"
 #include "AlarmConverter.h"
@@ -46,6 +49,9 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Tizen1_0::Alarm;
 using namespace TizenApis::Commons;
 using namespace TizenApis::Api::Alarm;
+using namespace TizenApis::Tizen1_0::Application;
+using namespace TizenApis::Api::Application;
+
 
 static bool alarm_iterate_callback(int alarm_id, void *user_data)
 {
@@ -132,53 +138,56 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
     std::string package;
     std::string page;
 
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(gContext, ALARM_FUNCTION_API_ADD);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_ADD);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
     Validator check(ctx, exception);
     AlarmConverter converter(ctx);
+    ApplicationConverter applicationConverter(ctx);
 
     Try {
 
         if(argumentCount < 2) {
-            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
         }
 
         if(argumentCount >= 2) {
-            if(!JSValueIsString(ctx, arguments[1])) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
-            }
+             // Think it is application id
             package = converter.toString(arguments[1]);
         }
 
-        if(argumentCount == 3) {
-            if(!JSValueIsString(ctx, arguments[2])) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
-            }
-            Throw(WrtDeviceApis::Commons::UnsupportedException);
-        }
-
         if(JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmAbsolute::getClassRef())) {
             // AlarmAbsolute obj
             JSObjectRef alarmObj = JSValueToObject(ctx, arguments[0], exception);
             JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(alarmObj));
             if (!priv) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Private object is null");
             }
             AlarmAbsolutePtr alarmPtr = priv->getObject();
             if (!alarmPtr) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Private object is null");
             }
 
             startDate = alarmPtr->getDate();
-            // ilovefilm
             service = alarmPtr->getService();
-            if(!page.empty()) {
-                JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Page is not support");
-            }
-            else {
+
+            if(argumentCount >=3) {
+                // It's service object
+                if(JSValueIsObjectOfClass(ctx, arguments[2], JSApplicationService::getClassRef())) {
+                    ApplicationServicePtr appService = applicationConverter.toApplicationService(arguments[2]);
+                    if(converter.toAlarmService(service, appService) == false) {
+                        return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+                    }                  
+                } else if (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2])) {
+                    // do nothing
+                } else {
+                    return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error");
+                }
+                
+            } else {
                 service_set_operation(service, SERVICE_OPERATION_DEFAULT);            
             }
+
             service_set_package(service, package.c_str());
 
             AbsoluteRecurrence::Type alarmType = alarmPtr->getRecurrenceType();
@@ -203,23 +212,35 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
             JSObjectRef alarmObj = JSValueToObject(ctx, arguments[0], exception);
             JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(alarmObj));
             if (!priv) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Private object is null");
             }
 
             AlarmRelativePtr alarmPtr = priv->getObject();
             if (!alarmPtr) {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Private object is null");
             }
 
             delay = alarmPtr->getDelay();
             int interval = alarmPtr->getPeriod();
             service = alarmPtr->getService();
-            if(!page.empty()) {
-                JSTizenExceptionFactory::postException(ctx, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Page is not support");
-            }
-            else {
+
+            if(argumentCount >=3) {
+                // It's service object
+                if(JSValueIsObjectOfClass(ctx, arguments[2], JSApplicationService::getClassRef())) {
+                    ApplicationServicePtr appService = applicationConverter.toApplicationService(arguments[2]);
+                    if(converter.toAlarmService(service, appService) == false) {
+                        return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+                   }
+                } else if (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2])) {
+                    // do nothing
+                } else {
+                    return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error");
+                }
+
+            } else {
                 service_set_operation(service, SERVICE_OPERATION_DEFAULT);            
             }
+
             service_set_package(service, package.c_str());
             int err = alarm_schedule_after_delay(service, delay, interval, &alarm_id);
             
@@ -227,7 +248,7 @@ JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef
                 alarmPtr->setId(alarm_id);
             }
         } else {
-                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Object is instance of Alarm");
             }
     } Catch (WrtDeviceApis::Commons::ConversionException) {
         return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
@@ -249,25 +270,34 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject
 {
     int err;
 
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(gContext, ALARM_FUNCTION_API_REMOVE);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_REMOVE);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
     
+    Converter converter(ctx);
+    JSValueRef value;
+    int id;
+    
     Try {
         if(argumentCount < 1 ) {
-            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+            value = JSValueMakeUndefined(ctx);
+            id = converter.toInt(value);
+        } else {
+            id = converter.toInt(arguments[0]);
         }
 
-        int id = JSValueToNumber(ctx, arguments[0], exception);
+        if(id <= 0) {
+            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+        }
+        
         err = alarm_cancel(id);
         
-
         if(err != ALARM_ERROR_NONE)
         {
             if(err == ALARM_ERROR_INVALID_PARAMETER) {
-                JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::NOT_FOUND_ERROR, "Not found error");
+                return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::NOT_FOUND_ERROR, "Not found error");
             }
             else {
-                JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+                return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
             }
         }
        
@@ -290,7 +320,8 @@ JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObject
 JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     LogError("GContext = " << gContext);
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(gContext, ALARM_FUNCTION_API_REMOVE_ALL);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(
+            ALARM_FUNCTION_API_REMOVE_ALL);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
     alarm_cancel_all();
@@ -302,7 +333,7 @@ JSValueRef JSAlarmManager::removeAll(JSContextRef ctx, JSObjectRef object, JSObj
 JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
 
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(gContext, ALARM_FUNCTION_API_GET_ALL);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_GET_ALL);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
     int error;
@@ -321,7 +352,7 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
 
         //JSCreateArrayObject(JSContextRef context, int length, const JSValueRef vector [ ])
         LogInfo("Enter getAll Natvie alarm id size = " << alarmIds.size());
-        for(int i = 0; i < alarmIds.size(); i++)
+        for(unsigned int i = 0; i < alarmIds.size(); i++)
         { 
            service_h handle;
            char* alarmType;
@@ -378,27 +409,27 @@ JSValueRef JSAlarmManager::getAll(JSContextRef ctx, JSObjectRef object, JSObject
 JSValueRef JSAlarmManager::get(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
 
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(gContext, ALARM_FUNCTION_API_GET);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(ALARM_FUNCTION_API_GET);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
-    int error;
     int alarmId;
+    JSValueRef value;
     AlarmConverter converter(ctx);
     
     Try {    
         if(argumentCount <1) {
-            // Exception
-            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+            value = JSValueMakeUndefined(ctx);            
+            Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+        } else {
+            alarmId = converter.toInt(arguments[0]);
         }
-
-        if(!JSValueIsNumber(ctx, arguments[0])){
-           return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-        } 
-        alarmId = JSValueToNumber(ctx, arguments[0], exception);
-
+        
         service_h handle;
         char* alarmType;
-        alarm_get_service(alarmId, &handle);
+        int error = alarm_get_service(alarmId, &handle);
+        if(error != ALARM_ERROR_NONE) {
+            return JSTizenExceptionFactory::postException(ctx, exception,JSTizenException::NOT_FOUND_ERROR, "id not found");
+        }
         service_get_extra_data(handle, ALARM_TYPE_KEY, &alarmType);
         if(!strcmp(alarmType, ALARM_TYPE_ABSOLUTE_VALUE)) 
         {
index aebfa3a..6ffaeb9 100755 (executable)
@@ -122,34 +122,34 @@ JSObjectRef JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef construct
     Validator validator(ctx);
     int delay = 0;
     int interval = 0;
-    bool isRecurrence = false;
+    JSValueRef value;
 
     Try {
 
         if(argumentCount < 1)
         {
-            ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong argumentCount");
-        }
-        
-        if(!JSValueIsNumber(ctx, arguments[0]))
-        {
-            ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"Invalid Type");
+            value = JSValueMakeUndefined(ctx);
+            delay = converter.toInt(value);
         }
 
-        delay = JSValueToNumber(ctx, arguments[0], exception);
+        delay = converter.toInt(arguments[0]);
 
-        if(delay <=0) {
+        if(delay < 0) {
             ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"First parameter should be > 0");
         }
 
-        if(argumentCount == 2)
+        if(argumentCount >= 2)
         {
-            if(!JSValueIsNumber(ctx, arguments[1]))
-            {
-                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"Invalid Type");
+            // Ignores if it is optional
+            if(JSValueIsUndefined(ctx, arguments[1])) {
+                return JSValueToObject(ctx, createJSObject(ctx, delay, interval), exception);
+            }
+
+            interval = converter.toInt(arguments[1]);
+            if(interval < 0) {
+                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"First parameter should be > 0");
             }
             
-            interval = JSValueToNumber(ctx, arguments[1], exception);
             LogInfo("Constructor interval  = " << interval);
         }
         return JSValueToObject(ctx, createJSObject(ctx, delay, interval), exception);
@@ -206,7 +206,8 @@ JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, int
 JSValueRef JSAlarmRelative::getRemainingSeconds(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception)
 { 
 
-    AceSecurityStatus status = ALARM_CHECK_ACCESS(TizenApis::Tizen1_0::Alarm::JSAlarmManager::gContext, ALARM_FUNCTION_API_GET_REMAINING_SECONDS);
+    AceSecurityStatus status = ALARM_CHECK_ACCESS(
+            ALARM_FUNCTION_API_GET_REMAINING_SECONDS);
     TIZEN_SYNC_ACCESS_HANDLER(status, ctx, exception);
 
     struct tm date;
@@ -261,7 +262,8 @@ JSValueRef JSAlarmRelative::getId(JSContextRef ctx,
         AlarmRelativePtr privateData = getPrivData(object);
         id = privateData->getId();
         if(id >= 0) {
-            return converter.toJSValueRef(id);
+            std::string strId = converter.toString(id);
+            return converter.toJSValueRef(strId);
         } else {
             return JSValueMakeNull(ctx);            
         }
index 925c4fa..5fc2458 100755 (executable)
@@ -38,9 +38,8 @@ namespace Alarm {
 \r
 DECLARE_FUNCTION_GETTER(Alarm);\r
 \r
-#define ALARM_CHECK_ACCESS(globalContext, functionName)                     \\r
+#define ALARM_CHECK_ACCESS(functionName)                     \\r
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \\r
-        globalContext,                     \\r
         getAlarmFunctionData,           \\r
         functionName)\r
 }\r
index f04a5d4..d607fb1 100755 (executable)
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include <Commons/Exception.h>
 #include "JSAlarmManager.h"
 #include "JSAlarmAbsolute.h"
 #include "JSAlarmRelative.h"
 
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\AlarmManager ] on_widget_start_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess initialization failed");
+    }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
     LogDebug("[Tizen\\AlarmManager ] on_widget_stop_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index b56b52c..9c208d9 100755 (executable)
@@ -38,9 +38,9 @@ class ApplicationAnswerReceiver :
                public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventLaunchService>
 {
     public:
-        explicit             ApplicationAnswerReceiver(const JSCallbackManagerPtr &callbackManager);
-        explicit             ApplicationAnswerReceiver(const LaunchServicePrivateDataPtr &ApplicatoinServiceCallback);
-        virtual              ~ApplicationAnswerReceiver();
+        explicit ApplicationAnswerReceiver(const JSCallbackManagerPtr &callbackManager);
+        explicit ApplicationAnswerReceiver(const LaunchServicePrivateDataPtr &ApplicatoinServiceCallback);
+        virtual ~ApplicationAnswerReceiver();
 
     protected:
         void OnAnswerReceived(const Api::Application::EventListInstalledApplicationsPtr &event);
index a71791a..964a97f 100755 (executable)
@@ -234,7 +234,7 @@ ApplicationContextArrayPtr ApplicationConverter::toApplicationContextArray(const
 JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServicePtr &arg)
 {
        LogDebug("entered");
-       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationService::getClassRef(), arg);
+       return JSApplicationService::createJSObject(m_context, arg);
 }
 
 ApplicationServicePtr ApplicationConverter::toApplicationService(const JSValueRef &jsValue)
index 2b35e6f..71dd277 100755 (executable)
@@ -79,6 +79,7 @@ void ApplicationListener::onAnswerReceived(const EventInstalledApplicationChange
                                        priveData->getOnUninstalled()->callOnSuccess(result);
                                        break;
                                default:
+                                       // TODO: if error callback is not exist???
                                        LogError(">>> unknown event is come");
                                        errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
                                        priveData->getOnInstalled()->callOnError(errorObject);
index e6a5de4..2d13b57 100755 (executable)
@@ -65,7 +65,6 @@ bool ApplicationUtil::isArray(const JSValueRef& arg)
            JSIsArrayValue(m_context, arg);
 }
 
-
 bool ApplicationUtil::isNullOrString(const JSValueRef& arg)
 {
     return !JSValueIsUndefined(m_context, arg) &&
@@ -102,6 +101,37 @@ bool ApplicationUtil::isNullOrUndefined(const JSValueRef& arg)
             JSValueIsUndefined(m_context, arg));
 }
 
+bool ApplicationUtil::isNullOrUndefinedOrString(const JSValueRef& arg)
+{
+    return (JSValueIsNull(m_context, arg) ||
+                  JSValueIsUndefined(m_context, arg) ||
+           JSValueIsString(m_context, arg));
+}
+
+bool ApplicationUtil::isNullOrUndefinedOrObject(const JSValueRef& arg)
+{
+    return (JSValueIsNull(m_context, arg) ||
+                  JSValueIsUndefined(m_context, arg) ||
+           JSValueIsObject(m_context, arg));
+}
+
+bool ApplicationUtil::isNullOrUndefinedOrFunction(const JSValueRef& arg)
+{
+    Converter converter(m_context);
+    return (JSValueIsNull(m_context, arg) ||
+                  JSValueIsUndefined(m_context, arg) ||
+           JSObjectIsFunction(m_context, converter.toJSObjectRef(arg)));
+}
+
+bool ApplicationUtil::isNullOrUndefinedOrArray(const JSValueRef& arg)
+{
+    Converter converter(m_context);
+    return (JSValueIsNull(m_context, arg) ||
+                  JSValueIsUndefined(m_context, arg) ||
+           JSIsArrayValue(m_context, arg));
+}
+
+
 }
 } // 
 } // 
index 3fd8048..5e9e461 100755 (executable)
@@ -38,6 +38,10 @@ class ApplicationUtil
        bool isNullOrFunction(const JSValueRef& arg);
        bool isNullOrArray(const JSValueRef& arg);
     bool isNullOrUndefined(const JSValueRef& arg);
+       bool isNullOrUndefinedOrString(const JSValueRef& arg);
+       bool isNullOrUndefinedOrObject(const JSValueRef& arg);
+       bool isNullOrUndefinedOrFunction(const JSValueRef& arg);
+       bool isNullOrUndefinedOrArray(const JSValueRef& arg);
 
   protected:
     JSContextRef m_context;
index c5285c8..b8cdc60 100755 (executable)
@@ -1,17 +1,18 @@
 set(TARGET_NAME "wrt-plugins-tizen-1.0-application")
 set(DESTINATION_NAME "tizen-1.0-application")
+set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-application-impl")
+
 include_directories(${INCLUDES_PLATFORM_IMPLEMENTATION_APPLICATION})
 
 set(CMAKE_INSTALL_RPATH
     ${CMAKE_INSTALL_RPATH}
-    ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+    ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
 )
 
-set(SRCS 
+set(SRCS_IMPL
 #  ${SRCS_PLATFORM_API_WRT_WRAPPER}
   ${SRCS_PLATFORM_API_APPLICATION}
   ${SRCS_PLATFORM_IMPLEMENTATION_APPLICATION}
-  plugin_initializer.cpp
   plugin_config.cpp  
   ApplicationAnswerReceiver.cpp
   ApplicationListener.cpp  
@@ -28,12 +29,22 @@ set(SRCS
   LaunchServicePrivateData.cpp
 )
 
-add_library(${TARGET_NAME} SHARED ${SRCS})
-target_link_libraries(${TARGET_NAME}
-  wrt-plugins-tizen-1.0-tizen-impl
+add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+
+target_link_libraries(${TARGET_IMPL_NAME}
   ${LIBS_COMMON}
   ${LIBS_PLATFORM_IMPLEMENTATION_APPLICATION}
 )
 
-INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+set(SRCS
+  plugin_initializer.cpp
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  ${TARGET_IMPL_NAME}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
+
index 2d6a2d0..1096e9c 100755 (executable)
@@ -21,6 +21,7 @@
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <Tizen/Common/SecurityExceptions.h>
 #include <Commons/Exception.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
@@ -80,15 +81,15 @@ JSStaticFunction JSApplication::m_function[] = {
                { "launch",JSApplication::launch,kJSPropertyAttributeNone },
                { "exit",JSApplication::exit,kJSPropertyAttributeNone },
                { "kill",JSApplication::kill,kJSPropertyAttributeNone },
-               /*{ "hide",JSApplication::hide,kJSPropertyAttributeNone },*/
-               { "getApplicationsInformation",JSApplication::getApplicationsInformation,kJSPropertyAttributeNone },
-               { "getRunningApplicationsContext",JSApplication::getRunningApplicationsContext,kJSPropertyAttributeNone },
-               { "getApplicationInformation",JSApplication::getApplicationInformation,kJSPropertyAttributeNone },
-               { "getCurrentApplicationContext",JSApplication::getCurrentApplicationContext,kJSPropertyAttributeNone },
-               { "addApplicationInformationEventListener",JSApplication::addApplicationInformationEventListener,kJSPropertyAttributeNone },
-               { "removeApplicationInformationEventListener",JSApplication::removeApplicationInformationEventListener,kJSPropertyAttributeNone },
+               { "hide",JSApplication::hide,kJSPropertyAttributeNone },
+               { "getAppsInfo",JSApplication::getAppsInfo,kJSPropertyAttributeNone },
+               { "getAppsContext",JSApplication::getAppsContext,kJSPropertyAttributeNone },
+               { "getAppInfo",JSApplication::getAppInfo,kJSPropertyAttributeNone },
+               { "getAppContext",JSApplication::getAppContext,kJSPropertyAttributeNone },
+               { "addAppInfoEventListener",JSApplication::addAppInfoEventListener,kJSPropertyAttributeNone },
+               { "removeAppInfoEventListener",JSApplication::removeAppInfoEventListener,kJSPropertyAttributeNone },
                { "launchService",JSApplication::launchService,kJSPropertyAttributeNone },
-               { "getApplicationService",JSApplication::getApplicationService,kJSPropertyAttributeNone },
+               { "getAppService",JSApplication::getAppService,kJSPropertyAttributeNone },
                { 0, 0, 0 }
 };
 
@@ -108,15 +109,19 @@ const JSClassDefinition* JSApplication::getClassInfo()
 
 void JSApplication::initialize(JSContextRef context, JSObjectRef object) 
 {
+       LogDebug(">>> JSApplication::initialize");
        JSApplicationPriv* priv = static_cast<JSApplicationPriv*>(JSObjectGetPrivate(object));
-       assert(!priv && "Invalid object creation.");
-       
-       IApplicationPtr applications(ApplicationFactory::getInstance().createApplication());
-       priv = new JSApplicationPriv(context, applications);
-       
-       if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-               LogError("Object can't store private data.");
-               delete priv;
+
+       if (!priv) {
+               IApplicationPtr applications(ApplicationFactory::getInstance().createApplication());
+               priv = new JSApplicationPriv(context, applications);
+               
+               if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+                       LogError("Object can't store private data.");
+                       delete priv;
+               }
+       } else {
+               LogDebug("private date is already exist");
        }
 }
 
@@ -143,30 +148,33 @@ JSValueRef JSApplication::launch(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_LAUNCH);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(priv->getContext());
        ApplicationUtil util(context, exception);
-       if (!util.isString(arguments[0]) ||
-               !util.isFunction(arguments[1]) ||
-               (argumentCount > 2 && !util.isNullOrFunction(arguments[2])) ||
-               (argumentCount > 3 && !util.isNullOrString(arguments[3]))) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if (argumentCount > 1) {
+               if (util.isFunction(arguments[1])) {
+                       callbackManager->setOnSuccess(arguments[1]);
+               } else if (!util.isNullOrUndefined(arguments[1])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
 
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-       callbackManager->setOnSuccess(arguments[1]);
        if (argumentCount > 2) {
-               callbackManager->setOnError(arguments[2]);
+               if (util.isFunction(arguments[2])) {
+                       callbackManager->setOnError(arguments[2]);
+               } else if (!util.isNullOrUndefined(arguments[2])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
+       }
+
+       if ((argumentCount > 3) && !util.isNullOrUndefined(arguments[3])) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported");
        }
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
@@ -175,12 +183,15 @@ JSValueRef JSApplication::launch(JSContextRef context,
        Try {
                IApplicationPtr applications(priv->getObject());
                event->setEventType(EventManageApplication::APP_MANAGER_LAUNCH_APPLICATION);
-               event->setAppId(converter->toString(arguments[0]));
-               // TODO: argument passing is not supported yet
-               if (argumentCount > 3) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported");
-                       //event->setArgument(converter->toString(arguments[3]));
+
+               if (argumentCount > 0) {
+                       event->setAppId(converter->toString(arguments[0]));
+               } else {
+                       // if error callback is not set, below line is skipped.
+                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+                       return JSValueMakeNull(context);
                }
+
                event->setPrivateData(StaticPointerCast<IEventPrivateData>(callbackManager));
                event->setForAsynchronousCall(new ApplicationAnswerReceiver(callbackManager));
                applications->launch(event);
@@ -190,10 +201,11 @@ JSValueRef JSApplication::launch(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
        } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeNull(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeNull(context);
        }
        
        return JSValueMakeUndefined(context);
@@ -207,38 +219,47 @@ JSValueRef JSApplication::kill(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_KILL);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_KILL);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 2)) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(priv->getContext());
        ApplicationUtil util(context, exception);
-       if (!util.isObject(arguments[0]) ||
-               ((argumentCount > 1) && !util.isNullOrFunction(arguments[2]))) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if (argumentCount > 1) {
+               if (util.isFunction(arguments[1])) {
+                       callbackManager->setOnSuccess(arguments[1]);
+               } else if (!util.isNullOrUndefined(arguments[1])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
 
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-       if (argumentCount > 1) {
-               callbackManager->setOnSuccess(arguments[1]);
+       if (argumentCount > 2) {
+               if (util.isFunction(arguments[2])) {
+                       callbackManager->setOnError(arguments[2]);
+               } else if (!util.isNullOrUndefined(arguments[2])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
-       
+
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
        EventManageApplicationPtr event(new EventManageApplication());
        
        Try{
-               ApplicationContextPtr appContext = converter->toApplicationContext(arguments[0]);
+               std::string appContextId;
+               if (argumentCount > 0) {
+                       appContextId = converter->toString(arguments[0]);
+               } else {
+                       // if error callback is not set, below line is skipped.
+                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+                       return JSValueMakeNull(context);
+               }
                
                IApplicationPtr applications(priv->getObject());
                event->setEventType(EventManageApplication::APP_MANAGER_KILL_APPLICATION);
-               event->setApplicationContext(appContext);
+               event->setContextId(appContextId);
                event->setPrivateData(StaticPointerCast<IEventPrivateData>(callbackManager));
                event->setForAsynchronousCall(new ApplicationAnswerReceiver(callbackManager));
                applications->kill(event);
@@ -248,12 +269,13 @@ JSValueRef JSApplication::kill(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
        } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeNull(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeNull(context);
        }
-       
+
        return JSValueMakeUndefined(context);
 }
 
@@ -265,19 +287,31 @@ JSValueRef JSApplication::exit(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_EXIT);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_EXIT);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount != 0) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
        Try {
-               IApplicationPtr applications(priv->getObject());
-               applications->exit();
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               // get window object
+               JSObjectRef windowObject = JSContextGetGlobalObject(context);
+               
+               // get location object
+               JSObjectRef locationObejct = converter.toJSObjectRef(JSObjectGetProperty(context, 
+                                                                                                                                                               windowObject, 
+                                                                                                                                                               ScopedJSStringRef(JSStringCreateWithUTF8CString("location")).get(), 
+                                                                                                                                                               NULL));
+               
+               // set window.location.href property to "tizen://exit" or "tizen://hide"
+               JSObjectSetProperty(context, 
+                                                  locationObejct,
+                                                  ScopedJSStringRef(JSStringCreateWithUTF8CString("href")).get(), 
+                                                  JSValueMakeString(context, JSStringCreateWithUTF8CString("tizen://exit")),
+                                                  kJSPropertyAttributeNone, 
+                                                  NULL);
                
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
@@ -285,7 +319,7 @@ JSValueRef JSApplication::exit(JSContextRef context,
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
-       
+
        return JSValueMakeUndefined(context);
 }
 
@@ -297,23 +331,32 @@ JSValueRef JSApplication::hide(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported"); 
-
-#if 0
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_HIDE);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_HIDE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount != 0) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
        Try {
-               IApplicationPtr applications(priv->getObject());
-               applications->hide();
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               // get window object
+               JSObjectRef windowObject = JSContextGetGlobalObject(context);
+               
+               // get location object
+               JSObjectRef locationObejct = converter.toJSObjectRef(JSObjectGetProperty(context, 
+                                                                                                                                                               windowObject, 
+                                                                                                                                                               ScopedJSStringRef(JSStringCreateWithUTF8CString("location")).get(), 
+                                                                                                                                                               NULL));
+               
+               // set window.location.href property to "tizen://exit" or "tizen://hide"
+               JSObjectSetProperty(context, 
+                                                  locationObejct,
+                                                  ScopedJSStringRef(JSStringCreateWithUTF8CString("href")).get(), 
+                                                  JSValueMakeString(context, JSStringCreateWithUTF8CString("tizen://hide")),
+                                                  kJSPropertyAttributeNone, 
+                                                  NULL);
                
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
@@ -321,9 +364,8 @@ JSValueRef JSApplication::hide(JSContextRef context,
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
-       
+
        return JSValueMakeUndefined(context);
-#endif
 }
 
 
@@ -335,56 +377,77 @@ JSValueRef JSApplication::launchService(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_LAUNCH_SERVICE); 
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_LAUNCH_SERVICE);   
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
 
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
+       JSContextRef gContext = priv->getContext();
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
        ApplicationUtil util(context, exception);
-       if (!util.isObject(arguments[0]) ||
-               !util.isFunction(arguments[1]) ||
-               ((argumentCount > 2) && !util.isNullOrFunction(arguments[2])) ||
-               ((argumentCount > 3) && !util.isNullOrObject(arguments[3]))) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if (argumentCount > 2) {
+               if (util.isFunction(arguments[2])) {
+                       callbackManager->setOnSuccess(arguments[2]);
+               } else if (!util.isNullOrUndefined(arguments[2])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
 
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-       callbackManager->setOnSuccess(arguments[1]);
-       if (argumentCount > 2)
-               callbackManager->setOnError(arguments[2]);
+       if (argumentCount > 3) {
+               if (util.isFunction(arguments[3])) {
+                       callbackManager->setOnError(arguments[3]);
+               } else if (!util.isNullOrUndefined(arguments[3])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
+       }
 
        JSCallbackManagerPtr replyCallbackManager;
-       if (argumentCount == 4) {
-               JSObjectRef cbObj = JSValueToObject(context, arguments[3], exception);
-               JSValueRef onsuccess = JSUtils::getJSProperty(context, cbObj, "onSuccess");
-               JSValueRef onfail = JSUtils::getJSProperty(context, cbObj, "onFailed");
-               
-               if (!util.isFunction(onsuccess) || !util.isFunction(onfail)) {
-                       LogError("Wrong parameters");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+       Try {
+               if (argumentCount > 4) {
+                       if (util.isObject(arguments[4])) {
+                               JSObjectRef cbObj = JSValueToObject(context, arguments[4], exception);
+                               JSValueRef onsuccess = JSUtils::getJSProperty(context, cbObj, "onsuccess");
+                               JSValueRef onfail = JSUtils::getJSProperty(context, cbObj, "onfail");
+                               
+                               if (!util.isFunction(onsuccess) || !util.isFunction(onfail)) {
+                                       LogError("Wrong parameters");
+                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+                               }
+                               
+                               replyCallbackManager = JSCallbackManager::createObject(gContext, onsuccess, onfail);
+                       } else if (!util.isNullOrUndefined(arguments[4])) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+                       }
                }
-               
-               replyCallbackManager = JSCallbackManager::createObject(gContext, onsuccess, onfail);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");               
        }
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
        EventLaunchServicePtr event(new EventLaunchService());
 
        Try {
-               ApplicationServicePtr appService = converter->toApplicationService(arguments[0]);
+               ApplicationServicePtr appService;
+               if (argumentCount > 0) {
+                       appService = converter->toApplicationService(arguments[0]);
+               } else {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");       
+               }
+               
                LaunchServicePrivateDataPtr privateData(new LaunchServicePrivateData(callbackManager,replyCallbackManager));
                IApplicationPtr applications(priv->getObject());
+               std::string appId = "";
+               if ((argumentCount > 1) && !util.isNullOrUndefined(arguments[1])) {
+                       appId = converter->toString(arguments[1]);
+               }
 
                event->setEventType(EventLaunchService::APPLICATION_SERVICE_LAUNCH);
                event->setPrivateData(StaticPointerCast<IEventPrivateData> (privateData));
                event->setService(appService); 
+               event->setAppId(appId);
                event->setForAsynchronousCall(new ApplicationAnswerReceiver(privateData));
 
                applications->launchService(event);
@@ -394,51 +457,56 @@ JSValueRef JSApplication::launchService(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
        } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeNull(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeNull(context);
        }
+       
 
     return JSValueMakeUndefined(context);      
 }
 
-JSValueRef JSApplication::getApplicationService(JSContextRef context, 
+JSValueRef JSApplication::getAppService(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported"); 
-
-#if 0
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_GET_APP_SERVICE);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_SERVICE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount != 0) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
        EventLaunchServicePtr event(new EventLaunchService());
        
        Try {
+               JSObjectRef windowObject = JSContextGetGlobalObject(context);
+               JSValueRef encodedBundle = JSObjectGetProperty(context, 
+                                                                                                       windowObject, 
+                                                                                                       ScopedJSStringRef(JSStringCreateWithUTF8CString("__bundle")).get(), 
+                                                                                                       exception);
+               if (JSValueIsUndefined(context, encodedBundle) || JSValueIsNull(context, encodedBundle)) {
+                       LogError("encodedBundle"+converter->toString(encodedBundle));
+                       return JSValueMakeNull(context);
+               }
+               
                IApplicationPtr applications(priv->getObject());
                event->setEventType(EventLaunchService::APPLICATION_SERVICE_GET_REQUEST);
                event->setForSynchronousCall();
+               event->setEncodedBundle(converter->toString(encodedBundle));
                applications->getApplicationService(event);
-               
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "no service request found");                       
                } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
                }
-
                return converter->toJSValueRef(event->getService());
                
        } Catch (WrtDeviceApis::Commons::ConversionException) {
@@ -451,11 +519,10 @@ JSValueRef JSApplication::getApplicationService(JSContextRef context,
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
-#endif
 }
 
 
-JSValueRef JSApplication::getRunningApplicationsContext(JSContextRef context, 
+JSValueRef JSApplication::getAppsContext(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -463,28 +530,32 @@ JSValueRef JSApplication::getRunningApplicationsContext(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_GET_RUNNING_APPS_CONTEXT);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_RUNNING_APPS_CONTEXT);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 2)) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(priv->getContext());
        ApplicationUtil util(context, exception);
-       if (!util.isFunction(arguments[0]) ||
-               !util.isNullOrFunction(arguments[1])) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if ((argumentCount > 0) && util.isFunction(arguments[0])) {
+               callbackManager->setOnSuccess(arguments[0]);
+       } else {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-       callbackManager->setOnSuccess(arguments[0]);
        if (argumentCount > 1) {
-               callbackManager->setOnError(arguments[1]);
+               if (util.isFunction(arguments[1])) {
+                       callbackManager->setOnError(arguments[1]);
+               } else if (!util.isNullOrUndefined(arguments[1])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
 
        EventListInstalledApplicationsPtr event(new EventListInstalledApplications());
@@ -500,17 +571,17 @@ JSValueRef JSApplication::getRunningApplicationsContext(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
        } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeNull(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeNull(context);
        }
        
        return JSValueMakeUndefined(context);
 }
 
-
-JSValueRef JSApplication::getCurrentApplicationContext(JSContextRef context, 
+JSValueRef JSApplication::getAppContext(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -518,33 +589,40 @@ JSValueRef JSApplication::getCurrentApplicationContext(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
        
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_GET_CURRENT_APP_CONTEXT);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_CURRENT_APP_CONTEXT);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       
-       if (argumentCount != 0) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
 
-       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
        EventGetApplicationPtr event(new EventGetApplication());
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
        Try {
                IApplicationPtr applications(priv->getObject());
                event->setEventType(EventGetApplication::APP_MANAGER_GET_CONTEXT);
                event->setForSynchronousCall();
+               ApplicationUtil util(context, exception);
+               if (argumentCount > 0 && !util.isNullOrUndefined(arguments[0])) {
+                       event->setContextId(converter->toString(arguments[0]));
+               }
                applications->getApplication(event);
-               
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
+
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Given package is not found");                     
+               } else if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::UnknownException) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
                }
                
                return converter->toJSValueRef(event->getApplicationContext());
                
+       } Catch (WrtDeviceApis::Commons::ConversionException) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
+       } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
@@ -552,7 +630,7 @@ JSValueRef JSApplication::getCurrentApplicationContext(JSContextRef context,
 }
 
 
-JSValueRef JSApplication::getApplicationsInformation(JSContextRef context, 
+JSValueRef JSApplication::getAppsInfo(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -560,28 +638,32 @@ JSValueRef JSApplication::getApplicationsInformation(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_GET_APPS_INFO);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APPS_INFO);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 2)) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(priv->getContext());
        ApplicationUtil util(context, exception);
-       if (!util.isFunction(arguments[0]) ||
-               !util.isNullOrFunction(arguments[1])) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if ((argumentCount > 0) && util.isFunction(arguments[0])) {
+               callbackManager->setOnSuccess(arguments[0]);
+       } else {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
-       callbackManager->setOnSuccess(arguments[0]);
        if (argumentCount > 1) {
-               callbackManager->setOnError(arguments[1]);
+               if (util.isFunction(arguments[1])) {
+                       callbackManager->setOnError(arguments[1]);
+               } else if (!util.isNullOrUndefined(arguments[1])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+               }
        }
 
        EventListInstalledApplicationsPtr event(new EventListInstalledApplications());
@@ -597,16 +679,17 @@ JSValueRef JSApplication::getApplicationsInformation(JSContextRef context,
        } Catch (WrtDeviceApis::Commons::UnsupportedException) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported"); 
        } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeNull(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeNull(context);
        }
        
        return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSApplication::getApplicationInformation(JSContextRef context, 
+JSValueRef JSApplication::getAppInfo(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -614,22 +697,13 @@ JSValueRef JSApplication::getApplicationInformation(JSContextRef context,
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
        
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_GET_APP_INFO);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_GET_APP_INFO);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount > 1) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       }
-
-       ApplicationUtil util(context, exception);
-       if ((argumentCount == 1) && !util.isNullOrString(arguments[0])) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-       }
-
        EventGetApplicationPtr event(new EventGetApplication());
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
@@ -637,7 +711,8 @@ JSValueRef JSApplication::getApplicationInformation(JSContextRef context,
                IApplicationPtr applications(priv->getObject());
                event->setEventType(EventGetApplication::APP_MANAGER_GET_INFORMATION);
                event->setForSynchronousCall();
-               if (argumentCount == 1 && util.isString(arguments[0])) {
+               ApplicationUtil util(context, exception);
+               if (argumentCount > 0 && !util.isNullOrUndefined(arguments[0])) {
                        event->setAppId(converter->toString(arguments[0]));
                }
                applications->getApplication(event);
@@ -663,7 +738,7 @@ JSValueRef JSApplication::getApplicationInformation(JSContextRef context,
 }
 
 
-JSValueRef JSApplication::addApplicationInformationEventListener(JSContextRef context, 
+JSValueRef JSApplication::addAppInfoEventListener(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -671,45 +746,41 @@ JSValueRef JSApplication::addApplicationInformationEventListener(JSContextRef co
        JSValueRef* exception) 
 {
        JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       JSContextRef gContext = priv->getContext();
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(gContext, APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER);    
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER);      
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 2)) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
-       ApplicationUtil util(context, exception);
-       if (!util.isObject(arguments[0]) ||
-               !util.isNullOrFunction(arguments[1])) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-       }
-       
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
        Try {
                JSObjectRef cbObj = converter->toJSObjectRef(arguments[0]);
-           JSValueRef onInstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onInstalled");
-           JSValueRef onUpdated = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onUpdated");
-           JSValueRef onUninstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onUninstalled");
-               
+           JSValueRef onInstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "oninstalled");
+           JSValueRef onUpdated = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onupdated");
+           JSValueRef onUninstalled = JSUtils::getJSPropertyOrUndefined(context, cbObj, "onuninstalled");
+
+               ApplicationUtil util(context, exception);
                if (!util.isFunction(onInstalled) || !util.isFunction(onUpdated) || !util.isFunction(onUninstalled)) {
                        LogError("Wrong parameters");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
                }
 
-               JSValueRef onError;
-               if (argumentCount == 2) {
-                       onError = arguments[1];
-               } else {
-                       onError =JSValueMakeUndefined(context);
+               JSContextRef gContext = priv->getContext();
+               JSCallbackManagerPtr onInstalledCbm = JSCallbackManager::createObject(gContext, onInstalled);
+               if (argumentCount > 1) {
+                       if (util.isFunction(arguments[1])) {
+                               onInstalledCbm->setOnError(arguments[1]);
+                       } else if (!util.isNullOrUndefined(arguments[1])) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+                       }
                }
-
-               JSCallbackManagerPtr onInstalledCbm = JSCallbackManager::createObject(gContext, onInstalled, onError);
                JSCallbackManagerPtr onUpdatedCbm   = JSCallbackManager::createObject(gContext, onUpdated);
                JSCallbackManagerPtr onUninstalledCbm = JSCallbackManager::createObject(gContext, onUninstalled);
 
@@ -740,7 +811,7 @@ JSValueRef JSApplication::addApplicationInformationEventListener(JSContextRef co
        }
 }
 
-JSValueRef JSApplication::removeApplicationInformationEventListener(JSContextRef context,
+JSValueRef JSApplication::removeAppInfoEventListener(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -748,23 +819,18 @@ JSValueRef JSApplication::removeApplicationInformationEventListener(JSContextRef
         JSValueRef* exception)
 {
     JSApplicationPriv *priv = static_cast<JSApplicationPriv*>(JSObjectGetPrivate(thisObject));
-    assert(priv && "Invalid private pointer.");
+    if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
        
-       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount != 1) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
        }
 
-       if (!JSValueIsNumber(context, arguments[0]) || 
-               JSValueIsNull(context, arguments[0]) ||
-               JSValueIsUndefined(context, arguments[0])) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-       }
-       
     ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
        
     Try {
index 48ccb01..887b140 100755 (executable)
@@ -76,37 +76,37 @@ private:
        /**
         * Gets the list of installed packages.
         */
-       static JSValueRef getApplicationsInformation(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getAppsInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Gets the list of running packages.
         */
-       static JSValueRef getRunningApplicationsContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getAppsContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);   
 
        /**
         * Gets the application information of based on the package name.
         */
-       static JSValueRef getApplicationInformation(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getAppInfo(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Gets the current application Context
         */
-       static JSValueRef getCurrentApplicationContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getAppContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Watch for changes on installed applicaiton.
         */
-       static JSValueRef addApplicationInformationEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef addAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Unset installed Applications listener
         */
-       static JSValueRef removeApplicationInformationEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef removeAppInfoEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
@@ -118,7 +118,7 @@ private:
        /**
         * get request application service
         */
-       static JSValueRef getApplicationService(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getAppService(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
index 1c03942..66e333a 100755 (executable)
@@ -53,7 +53,7 @@ JSClassDefinition JSApplicationContext::m_classInfo = {
     finalize,
     NULL,     //HasProperty,
     getProperty,       //GetProperty,
-    setProperty,    //SetProperty,
+    NULL,    //SetProperty,
     NULL,     //DeleteProperty,
     NULL,     //GetPropertyNames,
     NULL,     //CallAsFunction,
@@ -63,8 +63,8 @@ JSClassDefinition JSApplicationContext::m_classInfo = {
 };
 
 JSStaticValue JSApplicationContext::m_property[] = {
-    { APPLICATION_CONTEXT_APP_ID, getProperty, setProperty, kJSPropertyAttributeReadOnly },
-       { APPLICATION_CONTEXT_CONTEXT_ID, getProperty, setProperty, kJSPropertyAttributeReadOnly },
+    { APPLICATION_CONTEXT_APP_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { APPLICATION_CONTEXT_CONTEXT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
     { 0, 0, 0, 0 }
 };
 
@@ -172,32 +172,6 @@ JSValueRef JSApplicationContext::getProperty(JSContextRef context,
 }
 
 
-bool JSApplicationContext::setProperty(JSContextRef context,
-       JSObjectRef object,
-       JSStringRef propertyName,
-       JSValueRef value,
-       JSValueRef* exception)
-{
-       Try     {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationContextPtr privateData = getPrivData(object);
-       
-               if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_CONTEXT_APP_ID)) {
-                       privateData->setAppId(converter.toString(value));
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_CONTEXT_CONTEXT_ID)) {
-                       privateData->setContextId(converter.toString(value));
-                       return true;
-               } 
-
-       } Catch(WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-        JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-    }
-       
-       return false;
-}
-
 }
 }
 }
index b857de8..b99130f 100755 (executable)
@@ -79,12 +79,6 @@ private:
                JSStringRef propertyName,
                JSValueRef* exception);
 
-       static bool setProperty(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception);
-
 };
 
 }
index 507c307..dc2f895 100755 (executable)
@@ -106,7 +106,9 @@ void JSApplicationEvent::initialize(JSContextRef context,JSObjectRef object)
 
 void JSApplicationEvent::finalize(JSObjectRef object)
 {
-       
+       JSApplicationEventPriv* priv = static_cast<JSApplicationEventPriv*> (JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       delete priv;    
 }
 
 JSValueRef JSApplicationEvent::getProperty(JSContextRef context,
@@ -116,10 +118,16 @@ JSValueRef JSApplicationEvent::getProperty(JSContextRef context,
 {
     LogDebug("Enter");
     JSApplicationEventPriv *priv = static_cast<JSApplicationEventPriv*>(JSObjectGetPrivate(object));
-    assert(priv && "Private object not set.");
+    if (!priv) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
+
+       ApplicationEventPtr appEvent = priv->getObject();
+       if (!appEvent) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
     Try {
-        ApplicationEventPtr appEvent = priv->getObject();
         Converter convert(context);
 
         if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_EVENT_CODE)) {
index f767a6a..2947d6c 100755 (executable)
@@ -56,7 +56,7 @@ JSClassDefinition JSApplicationInformation::m_classInfo = {
     finalize,
     NULL,     //HasProperty,
     getProperty,       //GetProperty,
-    setProperty,     //SetProperty,
+    NULL,     //SetProperty,
     NULL,     //DeleteProperty,
     NULL,     //GetPropertyNames,
     NULL,     //CallAsFunction,
@@ -66,11 +66,11 @@ JSClassDefinition JSApplicationInformation::m_classInfo = {
 };
 
 JSStaticValue JSApplicationInformation::m_property[] = {
-    { APPLICATION_INFORMATION_NAME, getProperty, setProperty, kJSPropertyAttributeReadOnly },
-    { APPLICATION_INFORMATION_APP_ID, getProperty, setProperty, kJSPropertyAttributeReadOnly },
-    { APPLICATION_INFORMATION_ICONPATH, getProperty, setProperty, kJSPropertyAttributeReadOnly },
-    { APPLICATION_INFORMATION_VERSION, getProperty, setProperty, kJSPropertyAttributeReadOnly },
-       { APPLICATION_INFORMATION_SHOW, getProperty, setProperty, kJSPropertyAttributeReadOnly },       
+    { APPLICATION_INFORMATION_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_INFORMATION_APP_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_INFORMATION_ICONPATH, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_INFORMATION_VERSION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { APPLICATION_INFORMATION_SHOW, getProperty, NULL, kJSPropertyAttributeReadOnly },      
     { 0, 0, 0, 0 }
 };
 
@@ -187,239 +187,6 @@ JSValueRef JSApplicationInformation::getProperty(JSContextRef context,
 }
 
 
-bool JSApplicationInformation::setProperty(JSContextRef context,
-       JSObjectRef object,
-       JSStringRef propertyName,
-       JSValueRef value,
-       JSValueRef* exception)
-{
-       Try     {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-       
-               if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_INFORMATION_NAME)) {
-                       privateData->setName(converter.toString(value));
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_INFORMATION_APP_ID)) {
-                       privateData->setAppId(converter.toString(value));
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_INFORMATION_ICONPATH)) {
-                       privateData->setIconPath(converter.toString(value));
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_INFORMATION_VERSION)) {
-                       privateData->setVersion(converter.toString(value));
-                       return true;
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_INFORMATION_SHOW)) {
-                       privateData->setShow(converter.toBool(value));
-                       return true;
-               } 
-
-       } Catch(WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-        JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-    }
-       
-       return false;
-}
-
-#if 0
-
-JSValueRef JSApplicationInformation::getName(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       Try
-       {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getName());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSApplicationInformation::setName(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef name,
-               JSValueRef* exception)
-{
-       Try
-       {
-               ApplicationInformationPtr privateData = getPrivData(object);
-               CommonsJavaScript::Converter converter(context);
-               privateData->setName(converter.toString(name));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-       JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       return false;
-}
-
-JSValueRef JSApplicationInformation::getAppId(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       Try
-       {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getAppId());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSApplicationInformation::setAppId(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef appId,
-               JSValueRef* exception)
-{
-       Try
-       {
-               ApplicationInformationPtr privateData = getPrivData(object);
-               CommonsJavaScript::Converter converter(context);
-               privateData->setAppId(converter.toString(appId));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-       JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       return false;
-}
-
-JSValueRef JSApplicationInformation::getIconPath(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       Try
-       {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getIconPath());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSApplicationInformation::setIconPath(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef iconPath,
-               JSValueRef* exception)
-{
-       Try
-       {
-               ApplicationInformationPtr privateData = getPrivData(object);
-               CommonsJavaScript::Converter converter(context);
-               privateData->setIconPath(converter.toString(iconPath));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-       JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       return false;
-}
-
-JSValueRef JSApplicationInformation::getVersion(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       Try
-       {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getVersion());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSApplicationInformation::setVersion(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef version,
-               JSValueRef* exception)
-{
-       Try
-       {
-               ApplicationInformationPtr privateData = getPrivData(object);
-               CommonsJavaScript::Converter converter(context);
-               privateData->setVersion(converter.toString(version));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-       JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       return false;
-}
-
-JSValueRef JSApplicationInformation::getShow(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception)
-{
-       Try
-       {
-               CommonsJavaScript::Converter converter(context);
-               ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getShow());
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSApplicationInformation::setShow(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef show,
-               JSValueRef* exception)
-{
-       Try
-       {
-               ApplicationInformationPtr privateData = getPrivData(object);
-               CommonsJavaScript::Converter converter(context);
-               privateData->setShow(converter.toBool(show));
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
-       }
-       JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
-       return false;
-}
-#endif
-
 }
 }
 }
index f5daa3f..e906f38 100755 (executable)
@@ -83,70 +83,6 @@ private:
                JSStringRef propertyName,
                JSValueRef* exception);
 
-       static bool setProperty(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef value,
-               JSValueRef* exception);
-
-
-#if 0
-       static JSValueRef getName(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setName(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef name,
-                       JSValueRef* exception);
-
-       static JSValueRef getAppId(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef* exception);
-
-       static bool setAppId(JSContextRef context,
-                       JSObjectRef object,
-                       JSStringRef propertyName,
-                       JSValueRef appId,
-                       JSValueRef* exception);
-
-static JSValueRef getIconPath(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception);
-
-static bool setIconPath(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef iconPath,
-               JSValueRef* exception);
-
-static JSValueRef getVersion(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception);
-
-static bool setVersion(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef version,
-               JSValueRef* exception);
-
-static JSValueRef getShow(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef* exception);
-
-static bool setShow(JSContextRef context,
-               JSObjectRef object,
-               JSStringRef propertyName,
-               JSValueRef show,
-               JSValueRef* exception);
-#endif
-
 };
 
 }
index b16efc4..dfa1b0d 100755 (executable)
@@ -82,66 +82,77 @@ class JSApplicationInformationArray
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef join(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef pop(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef push(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef reverse(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef shift(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef slice(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef sort(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef splice(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef toString(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef unshift(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+       
     static JSValueRef valueOf(JSContextRef context,
             JSObjectRef function,
             JSObjectRef thisObject,
index 0a56094..a2f2370 100755 (executable)
@@ -45,7 +45,6 @@ namespace {
 const char* APPLICATION_SERVICE_OPERATION = "operation";
 const char* APPLICATION_SERVICE_URI = "uri";
 const char* APPLICATION_SERVICE_MIME = "mime";
-const char* APPLICATION_SERVICE_APPLICATION_ID = "id";
 const char* APPLICATION_SERVICE_DATA = "data";
 } //private namespace
 
@@ -72,11 +71,10 @@ JSClassDefinition JSApplicationService::m_classInfo = {
 };
 
 JSStaticValue JSApplicationService::m_property[] = {
-    { APPLICATION_SERVICE_OPERATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { APPLICATION_SERVICE_URI, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { APPLICATION_SERVICE_MIME, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { APPLICATION_SERVICE_APPLICATION_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
-    { APPLICATION_SERVICE_DATA, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_SERVICE_OPERATION, getProperty, NULL, kJSPropertyAttributeNone },
+    { APPLICATION_SERVICE_URI, getProperty, NULL, kJSPropertyAttributeNone },
+    { APPLICATION_SERVICE_MIME, getProperty, NULL, kJSPropertyAttributeNone },
+    { APPLICATION_SERVICE_DATA, getProperty, NULL, kJSPropertyAttributeNone },
     { 0, 0, 0, 0 }
 };
 
@@ -102,6 +100,7 @@ const JSClassRef JSApplicationService::getClassRef()
 
 JSObjectRef JSApplicationService::createJSObject(JSContextRef context, const ApplicationServicePtr &appsvc)
 {
+        LogInfo(">> createJSObject");
     JSApplicationServicePriv *priv = new JSApplicationServicePriv(context, appsvc);
 
     if (!priv) {
@@ -125,7 +124,7 @@ ApplicationServicePtr JSApplicationService::getApplicationService(JSContextRef c
        
        JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
        if (!priv) {
-               Throw(WrtDeviceApis::Commons::NullPointerException);
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
        }
        return priv->getObject();
 }
@@ -161,13 +160,7 @@ JSObjectRef JSApplicationService::constructor(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception)
 {
-       ApplicationUtil util(context, exception);
-       if ((argumentCount < 1) || (argumentCount > 5) ||
-               (!util.isString(arguments[0])) ||
-               (argumentCount > 1 && !util.isNullOrString(arguments[1])) ||
-               (argumentCount > 1 && !util.isNullOrString(arguments[2])) ||
-               (argumentCount > 1 && !util.isNullOrString(arguments[3])) ||
-               (argumentCount == 5 && !util.isNullOrArray(arguments[4]))) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                return NULL;
@@ -179,25 +172,21 @@ JSObjectRef JSApplicationService::constructor(JSContextRef context,
                std::string operation = "";
                std::string uri = "";
                std::string mime = "";
-               std::string appId = "";
                std::vector<ApplicationServiceDataPtr> serviceData;
 
                operation = converter->toString(arguments[0]);
-               // TODO: Should I check null ???
-               if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1])) {
+               ApplicationUtil util(context, exception);
+               if ((argumentCount > 1) && !util.isNullOrUndefined(arguments[1])) {
                        uri = converter->toString(arguments[1]);
                }
-               if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2])) {
+               if ((argumentCount > 2) && !util.isNullOrUndefined(arguments[2])) {
                        mime = converter->toString(arguments[2]);
                }
-               if ((argumentCount > 3) && !JSValueIsNull(context, arguments[3])) {
-                       appId = converter->toString(arguments[3]);
-               }
-               if ((argumentCount > 4) && !JSValueIsNull(context, arguments[4])) {
-                       serviceData = converter->toApplicationServiceDataArray(arguments[4]);
+               if (argumentCount > 3) {
+                       serviceData = converter->toApplicationServiceDataArray(arguments[3]);
                }
 
-               ApplicationServicePtr appsvc = ApplicationServicePtr(new ApplicationService(operation, uri, mime, appId, serviceData));
+               ApplicationServicePtr appsvc = ApplicationServicePtr(new ApplicationService(operation, uri, mime, serviceData));
                if (!appsvc) {
                        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknow error on constructor");
                        return NULL;
@@ -205,8 +194,8 @@ JSObjectRef JSApplicationService::constructor(JSContextRef context,
        
                return createJSObject(context, appsvc);
                
-       } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                return NULL;
                
        }
@@ -218,11 +207,27 @@ bool JSApplicationService::isObjectOfClass(JSContextRef context, JSValueRef valu
        return JSValueIsObjectOfClass(context, value, getClassRef());
 }
 
+ApplicationServicePtr JSApplicationService::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       ApplicationServicePtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
 
 JSValueRef JSApplicationService::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
 {
     JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
-    assert(priv && "Private object not set.");
+    if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
     Try {
         ApplicationServicePtr appsvc = priv->getObject();
@@ -232,16 +237,13 @@ JSValueRef JSApplicationService::getProperty(JSContextRef context, JSObjectRef o
             LogDebug("JSApplicationService::getProperty::operation " << appsvc->getOperation());
             return converter->toJSValueRef(appsvc->getOperation());
         } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_URI)) {
-            LogDebug("JSApplicationService::getProperty ::uri " << appsvc->getUri());
+            LogDebug("JSApplicationService::getProperty::uri " << appsvc->getUri());
             return converter->toJSValueRef(appsvc->getUri());
         } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_MIME)) {
-            LogDebug("JSApplicationService::getProperty ::mime " << appsvc->getMime());
+            LogDebug("JSApplicationService::getProperty::mime " << appsvc->getMime());
             return converter->toJSValueRef(appsvc->getMime());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_APPLICATION_ID)) {
-                       LogDebug("JSApplicationService::getProperty ::appId ");
-                       return converter->toJSValueRef(appsvc->getAppId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_DATA)) {
-                       LogDebug("JSApplicationService::getProperty ::extraData ");
+               }else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_DATA)) {
+                       LogDebug("JSApplicationService::getProperty::extraData ");
                        return converter->toJSValueRef(appsvc->getServiceDataArray());
                }
 
@@ -254,6 +256,35 @@ JSValueRef JSApplicationService::getProperty(JSContextRef context, JSObjectRef o
     return NULL;
 }
 
+bool JSApplicationService::setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+       Try     {
+               ApplicationServicePtr privateData = getPrivData(object);
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+       
+               if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_OPERATION)) {
+                       privateData->setOperation(converter->toString(value));
+                       return true;
+               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_URI)) {
+                       privateData->setUri(converter->toString(value));
+                       return true;
+               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_MIME)) {
+                       privateData->setMime(converter->toString(value));
+                       return true;
+               } else if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_DATA)) {
+                       privateData->setServiceDataArray(converter->toApplicationServiceDataArray(value));
+                       return true;
+               } 
+
+       } Catch(WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+        JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
+    }
+       
+       return false;
+}
+
+
 bool JSApplicationService::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
 {
     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
@@ -266,30 +297,23 @@ JSValueRef JSApplicationService::replyResult(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
-       return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported"); 
-#if 0  
        LogInfo(">> replyResult()");
        JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
-
-       //AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_REPLY_RESULT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       ApplicationUtil util(context, exception);
-       if (argumentCount > 1 ||
-           (argumentCount == 1 && !util.isNullOrObject(arguments[0]))) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
        }
 
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_REPLY_RESULT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
        Try {
+               ApplicationServicePtr appsvc = priv->getObject();
                std::vector<ApplicationServiceDataPtr> resultArray;
-               if (argumentCount == 1 && util.isObject(arguments[0])) {
+               if (argumentCount > 0) {
                        resultArray = converter->toApplicationServiceDataArray(arguments[0]);
                }
-               ApplicationServicePtr appsvc = priv->getObject();
                appsvc->replyResult(resultArray);
                
        } Catch (WrtDeviceApis::Commons::ConversionException) {
@@ -306,7 +330,6 @@ JSValueRef JSApplicationService::replyResult(JSContextRef context,
        }
        
        return JSValueMakeUndefined(context);
-#endif
 }
 
 JSValueRef JSApplicationService::replyFailure(JSContextRef context, 
@@ -316,20 +339,15 @@ JSValueRef JSApplicationService::replyFailure(JSContextRef context,
        const JSValueRef arguments[], 
        JSValueRef* exception) 
 {
-       return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_SUPPORTED_ERROR, "Not yet supported"); 
-#if 0  
        LogInfo(">> replyFailure()");
        JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(thisObject));
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error.");
+       }
 
-       //AceSecurityStatus status = APPLICATION_CHECK_ACCESS(priv->getContext(), APPLICATION_FUNCTION_API_REPLY_RESULT);
-       //TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(APPLICATION_FUNCTION_API_REPLY_RESULT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount != 0) {
-               LogError("Wrong parameters");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-       }
-       
        Try {
                ApplicationServicePtr appsvc = priv->getObject();
                appsvc->replyFailure();
@@ -348,7 +366,6 @@ JSValueRef JSApplicationService::replyFailure(JSContextRef context,
        }
        
        return JSValueMakeUndefined(context);
-#endif
 }
 
 
index eed15d1..0c36291 100755 (executable)
@@ -77,6 +77,8 @@ private:
         */
        static void finalize(JSObjectRef object);
 
+    static Api::Application::ApplicationServicePtr getPrivData(JSObjectRef object);
+
   /**
      * The callback invoked when getting a property's value.
      */
@@ -86,6 +88,16 @@ private:
             JSValueRef* exception);
 
   /**
+        * The callback invoked when setting a property's value.
+        */
+
+       static bool setProperty(JSContextRef context,
+                 JSObjectRef object,
+                 JSStringRef propertyName,
+                 JSValueRef value,
+                 JSValueRef* exception);
+
+  /**
      * The callback invoked when an object is used as the target of an 'instanceof' expression.
      */
     static bool hasInstance(JSContextRef context,
index 1182fb7..d48f1d0 100755 (executable)
@@ -63,8 +63,6 @@ JSClassDefinition JSApplicationServiceData::m_classInfo =
 };
 
 JSStaticValue JSApplicationServiceData::m_property[] = {
-//     { APPLICATION_SERVICE_DATA_KEY, getDataKey, setDataKey, kJSPropertyAttributeNone },
-//     { APPLICATION_SERVICE_DATA_VALUE, getDataValue, setDataValue, kJSPropertyAttributeNone },
        { APPLICATION_SERVICE_DATA_KEY, getProperty, setProperty, kJSPropertyAttributeNone },
        { APPLICATION_SERVICE_DATA_VALUE, getProperty, setProperty, kJSPropertyAttributeNone },
        { 0, 0, 0, 0 }
@@ -103,17 +101,33 @@ JSValueRef JSApplicationServiceData::createJSObject(JSContextRef context,
 
 JSObjectRef JSApplicationServiceData::constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-       ApplicationUtil util(context, exception);
-       
-       if (argumentCount != 2 ||
-               !util.isString(arguments[0]) || !util.isArray(arguments[1])) {
+       if (argumentCount == 0) {
                LogError("Wrong parameters");
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                return NULL;
-       }
+       }       
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
-       return JSValueToObject(context, createJSObject(context, converter->toString(arguments[0]), converter->toVectorOfStrings(arguments[1])), exception);
+       Try {
+               std::string key;
+               std::vector<std::string> value;
+               
+               if (argumentCount > 0) {
+                       key = converter->toString(arguments[0]);
+               }
+               if (argumentCount > 1) {
+                       if (JSIsArrayValue(context, arguments[1])) {
+                               value = converter->toVectorOfStrings(arguments[1]);
+                       } else {
+                               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+                               return NULL;
+                       }
+               }
+               return JSValueToObject(context, createJSObject(context, key, value), exception);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       }
 }
 
 void JSApplicationServiceData::initialize(JSContextRef context, JSObjectRef object)
@@ -212,7 +226,7 @@ bool JSApplicationServiceData::setProperty(JSContextRef context,
                } 
        } Catch(WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-        JSDOMExceptionFactory::UnknownException.make(context, exception);
+        JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR, "Invalid value error");
     }
        
        return false;
index 7197f6f..1e99566 100755 (executable)
@@ -38,13 +38,7 @@ const
 {
     return m_replyCallbackManager;
 }
-#if 0
-JSCallbackManagerPtr LaunchServicePrivateData::getReplyCancelCallbackManager()
-const
-{
-    return m_replyCancelCallbackManager;
-}
-#endif
+
 }
 }
 }
index 086e017..1db5eed 100755 (executable)
     <api-feature>
         <name>http://tizen.org/api/application.launch</name>
         <device-capability>application.launch</device-capability>
+        <device-capability>application.read</device-capability>
     </api-feature>
     
     <api-feature>
         <name>http://tizen.org/api/application.kill</name>
         <device-capability>application.kill</device-capability>
+        <device-capability>application.read</device-capability>
     </api-feature>   
     
     <api-feature>
index e81972d..02ff68c 100755 (executable)
@@ -82,8 +82,8 @@ static FunctionMapping createApplicationFunctions()
 
     ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION_READ);
        ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION);
-    ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_LAUNCH, FEATURE_APPLICATION_LAUNCH);
-    ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_KILL, FEATURE_APPLICATION_KILL);
+    ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION_LAUNCH);
+    ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION_KILL);
     ACE_ADD_API_FEATURE(APPLICATION_FEATURES_APPLICATION_READ, FEATURE_APPLICATION_READ);
 
        ACE_CREATE_FEATURE_LIST(APPLICATION_FEATURES_APPLICATION);
@@ -120,8 +120,8 @@ static FunctionMapping createApplicationFunctions()
     AceFunction getAppServiceFunc = ACE_CREATE_FUNCTION(
             FUNCTION_GET_APPLICATION_SERVICE,
             APPLICATION_FUNCTION_API_GET_APP_SERVICE,
-            APPLICATION_FEATURES_APPLICATION_LAUNCH,
-            DEVICE_LIST_APPLICATION_LAUNCH);
+            APPLICATION_FEATURES_APPLICATION_READ,
+            DEVICE_LIST_APPLICATION_READ);
 
     applicationMapping.insert(std::make_pair(
                                APPLICATION_FUNCTION_API_GET_APP_SERVICE,
@@ -131,8 +131,8 @@ static FunctionMapping createApplicationFunctions()
     AceFunction replyResultFunc = ACE_CREATE_FUNCTION(
             FUNCTION_REPLY_RESULT,
             APPLICATION_FUNCTION_API_REPLY_RESULT,
-            APPLICATION_FEATURES_APPLICATION_LAUNCH,
-            DEVICE_LIST_APPLICATION_LAUNCH);
+            APPLICATION_FEATURES_APPLICATION_READ,
+            DEVICE_LIST_APPLICATION_READ);
 
     applicationMapping.insert(std::make_pair(
                                APPLICATION_FUNCTION_API_REPLY_RESULT,
@@ -142,8 +142,8 @@ static FunctionMapping createApplicationFunctions()
     AceFunction replyFailureFunc = ACE_CREATE_FUNCTION(
             FUNCTION_REPLY_FAILURE,
             APPLICATION_FUNCTION_API_REPLY_FAILURE,
-            APPLICATION_FEATURES_APPLICATION_LAUNCH,
-            DEVICE_LIST_APPLICATION_LAUNCH);
+            APPLICATION_FEATURES_APPLICATION_READ,
+            DEVICE_LIST_APPLICATION_READ);
 
     applicationMapping.insert(std::make_pair(
                                APPLICATION_FUNCTION_API_REPLY_FAILURE,
@@ -239,7 +239,6 @@ static FunctionMapping createApplicationFunctions()
                                APPLICATION_FUNCTION_API_EXIT,
                                exitFunc));
 
-#if 0
     // hide
     AceFunction hideFunc = ACE_CREATE_FUNCTION(
             FUNCTION_HIDE,
@@ -250,7 +249,6 @@ static FunctionMapping createApplicationFunctions()
     applicationMapping.insert(std::make_pair(
                                APPLICATION_FUNCTION_API_HIDE,
                                hideFunc));
-#endif
 
        return applicationMapping;
 
index 6494d95..e000886 100755 (executable)
 #include <string>\r
 #include <Commons/FunctionDeclaration.h>\r
 \r
-// feature : manage\r
+// feature : launch\r
 #define APPLICATION_FUNCTION_API_LAUNCH                        "launch"\r
 #define APPLICATION_FUNCTION_API_LAUNCH_SERVICE                "launchService"\r
-#define APPLICATION_FUNCTION_API_GET_APP_SERVICE       "getApplicationService"\r
-#define APPLICATION_FUNCTION_API_REPLY_RESULT          "replyResult"\r
-#define APPLICATION_FUNCTION_API_REPLY_FAILURE         "replyFailure"\r
+\r
+// feature : kill\r
 #define APPLICATION_FUNCTION_API_KILL                          "kill"\r
 \r
 // feature : read\r
 #define APPLICATION_FUNCTION_API_ADD_APP_INFO_EVENT_LISTENER   "addApplicationInformationEventListener"\r
 #define APPLICATION_FUNCTION_API_REMOVE_APP_INFO_EVENT_LISTENER        "removeApplicationInformationEventListener"\r
 #define APPLICATION_FUNCTION_API_EXIT                                                  "exit"\r
-#if 0\r
 #define APPLICATION_FUNCTION_API_HIDE                                                  "hide"\r
-#endif\r
+#define APPLICATION_FUNCTION_API_GET_APP_SERVICE                               "getApplicationService"\r
+#define APPLICATION_FUNCTION_API_REPLY_RESULT                                  "replyResult"\r
+#define APPLICATION_FUNCTION_API_REPLY_FAILURE                                 "replyFailure"\r
+\r
 \r
 namespace TizenApis {\r
 namespace Tizen1_0 {\r
@@ -47,11 +48,11 @@ namespace Application {
 \r
 DECLARE_FUNCTION_GETTER(Application);\r
 \r
-#define APPLICATION_CHECK_ACCESS(globalContext, functionName)                     \\r
-    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \\r
-        globalContext,                     \\r
-        getApplicationFunctionData,           \\r
+#define APPLICATION_CHECK_ACCESS(functionName)                     \\r
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(     \\r
+        getApplicationFunctionData,                                \\r
         functionName)\r
+\r
 }\r
 }\r
 }\r
index acc3089..4f35180 100755 (executable)
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include "JSApplication.h"
 #include "JSApplicationService.h"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId) {
        LogDebug("[Tizen1_0\\Application] on_widget_start_callback ("<<widgetId<<")");
+    Try {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    } Catch(Commons::Exception) {
+        LogError("WrtAccess initialization failed");
+    }  
 }
 
 void on_widget_stop_callback(int widgetId) {
        LogDebug("[Tizen1_0\\Application] on_widget_stop_callback ("<<widgetId<<")");
+    Try {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    } Catch(Commons::Exception) {
+        LogError("WrtAccess deinitialization failed");
+    }  
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
-PLUGIN_CLASS_MAP_BEGIN 
+PLUGIN_CLASS_MAP_BEGIN
        PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN,
                "application",
@@ -40,13 +53,13 @@ PLUGIN_CLASS_MAP_BEGIN
                NULL) 
 
        PLUGIN_CLASS_MAP_ADD_CLASS(
-               "tizen.application",
+               WRT_JS_EXTENSION_OBJECT_TIZEN,
                "ApplicationService",
                TizenApis::Tizen1_0::Application::JSApplicationService::getClassRef(),
                NULL) 
 
        PLUGIN_CLASS_MAP_ADD_CLASS(
-               "tizen.application",
+               WRT_JS_EXTENSION_OBJECT_TIZEN,
                "ApplicationServiceData",
                TizenApis::Tizen1_0::Application::JSApplicationServiceData::getClassRef(),
                NULL) 
index 4094faf..1f1e14f 100644 (file)
@@ -29,6 +29,7 @@
 #include "BluetoothMultiCallback.h"
 #include "JSBluetoothSocket.h"
 #include "JSBluetoothServiceHandler.h"
+#include "JSBluetoothAdapter.h"
 #include "BluetoothConverter.h"
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
@@ -87,6 +88,13 @@ void BluetoothAdapterListener::MakeErrorJSCallBack(JSCallbackManagerPtr cbm, JSC
                        err = JSTizenExceptionFactory::makeErrorObject(globalContext,
                                JSTizenException::NOT_FOUND_ERROR, "not found error");
                        break;
+               case ExceptionCodes::AlreadyInUseException:
+                       err = JSTizenExceptionFactory::makeErrorObject(globalContext,
+                               JSTizenException::SERVICE_NOT_AVAILABLE, "service not available");
+                       break;
+               case ExceptionCodes::EventCancelledException:
+                       LogDebug("Enter - Event was cancled, callback will be silently discarded");
+                       return;
                case ExceptionCodes::UnknownException:
                default:                                
                        err = JSTizenExceptionFactory::makeErrorObject(globalContext,
@@ -99,7 +107,21 @@ void BluetoothAdapterListener::MakeErrorJSCallBack(JSCallbackManagerPtr cbm, JSC
 void BluetoothAdapterListener::OnAnswerReceived(const EventBTCreateDestroyBondingPtr& event)
 {
        LogDebug("Enter - EventBTCreateDestroyBondingPtr");
-       JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
+//     JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
+
+       BluetoothCreateBondingPrivateDataPtr privData;
+       JSCallbackManagerPtr callbackManager;
+
+       if (event->isCreateBonding() == true)
+       {
+               privData = DPL::StaticPointerCast<BluetoothCreateBondingPrivateData> (event->getPrivateData());
+               callbackManager = privData->getCallbackManager();
+       }
+       else 
+       {
+               callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
+       }
+       
        JSContextRef l_globalContext = callbackManager->getContext();
 
        if (event->getExceptionCode() == ExceptionCodes::None)
@@ -216,10 +238,10 @@ void BluetoothAdapterListener::onAnswerReceived(const EventBTOnDiscoveryDevicesP
        JSCallbackManagerPtr defaultCbm = multiCallbacks->getOnSuccess();
        std::vector<BluetoothDeviceData> devices;
 
-       assert(multiCallbacks != NULL);
+/*     assert(multiCallbacks != NULL);
        assert(defaultCbm != NULL);
        assert(multiCallbacks->getOnFound() != NULL);
-       assert(multiCallbacks->getOnFinished() != NULL);
+       assert(multiCallbacks->getOnFinished() != NULL);*/
        
        if (event->getExceptionCode() == ExceptionCodes::None)
        {
@@ -303,7 +325,7 @@ void BluetoothAdapterListener::OnAnswerReceived(const EventBTStopDiscoveryPtr& e
 
 void BluetoothAdapterListener::OnAnswerReceived(const EventBTSetNamePtr& event)
 {
-       LogDebug("Enter - EventBTStopDiscoveryPtr");
+       LogDebug("Enter - EventBTSetNamePtr");
        JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager > (event->getPrivateData());
        JSContextRef l_globalContext = callbackManager->getContext();
        
index 9a94700..e8d803b 100644 (file)
@@ -46,23 +46,24 @@ BluetoothConverter::~BluetoothConverter()
 
 JSValueRef BluetoothConverter::toFunctionOrNull(const JSValueRef& arg)
 {
-       if (JSValueIsNull(m_context, arg))
+       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg))
        {
                LogDebug("null.");
 
                return NULL;
        } 
-       else if (JSValueIsUndefined(m_context, arg) || JSValueIsObject(m_context, arg) == false)
+       else if (JSValueIsObject(m_context, arg) == false)
        {
                LogDebug("undefined, not object");
                ThrowMsg(ConversionException, "Not a function nor JS null.");
        }
        else if (Validator(m_context).isCallback(arg)) 
        {
+               LogDebug("Function OK");
                return arg;
        } 
 
-       ThrowMsg(InvalidArgumentException, "unexpected argument");
+       ThrowMsg(ConversionException, "Not a function nor JS null.");
        return NULL;
 }
 
@@ -75,10 +76,11 @@ JSValueRef BluetoothConverter::toFunction(const JSValueRef& arg)
        }       
        else if (Validator(m_context).isCallback(arg)) 
        {
+               LogDebug("Function OK");
                return arg;
        } 
 
-       ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
+       ThrowMsg(ConversionException, "Not a function nor JS null.");
        return NULL;
 }
 
@@ -100,14 +102,13 @@ EventBTOnDiscoveryDevicesPrivateDataPtr
 
        errorCalback = toFunctionOrNull(errorParam);
 
-       result.onSuccess = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onStarted");
-       result.onFound = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onDeviceFound");
+       result.onSuccess = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onstarted");
+       result.onFound = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "ondevicefound");
        /* bluez doesn't support device disappeared, we don't care onDeviceDisappeared */
-       result.onFinished = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onFinished");
+       result.onFinished = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onfinished");
                        
-       if ((!validator.isNullOrUndefined(result.onSuccess) && !validator.isCallback(result.onSuccess)) ||
-               (!validator.isNullOrUndefined(result.onFound) && !validator.isCallback(result.onFound)) ||
-               (!validator.isNullOrUndefined(result.onFinished) && !validator.isCallback(result.onFinished)))
+       if (!validator.isCallback(result.onSuccess) || !validator.isCallback(result.onFound) ||
+               !validator.isCallback(result.onFinished))
        {
                LogError("java script call back set error");
                Throw(ConversionException);
@@ -142,15 +143,15 @@ void BluetoothConverter::setBluetoothSocketNotifierCallback(JSStringRef property
 {
        JSValueRef successCallback = toFunction(value);
 
-       if(JSStringIsEqualToUTF8CString(propertyName, "onClose")) 
+       if(JSStringIsEqualToUTF8CString(propertyName, "onclose")) 
        {
                privData->getOnClose()->setOnSuccess(successCallback);
        }
-       else if(JSStringIsEqualToUTF8CString(propertyName, "onError")) 
+       else if(JSStringIsEqualToUTF8CString(propertyName, "onerror")) 
        {
                privData->getOnError()->setOnSuccess(successCallback);
        }
-       else if(JSStringIsEqualToUTF8CString(propertyName, "onMessage")) 
+       else if(JSStringIsEqualToUTF8CString(propertyName, "onmessage")) 
        {
                privData->getOnMessage()->setOnSuccess(successCallback);
                privData->setObject(object);
@@ -200,18 +201,13 @@ JSObjectRef BluetoothConverter::toBluetoothByteArray(std::vector<char>& data)
 }
 std::string BluetoothConverter::toBluetoothDeviceAddress(JSValueRef deviceAddress)
 {
-       if (!JSValueIsString(m_context, deviceAddress) || JSValueIsNull(m_context, deviceAddress))
-       {
-               ThrowMsg(ConversionException, "Not a string");
-       }
-
        std::string address = toString(deviceAddress);
        pcrecpp::RE re("(([0-9a-zA-Z]+):)+([0-9a-zA-Z]+)");
        std::string compareAddress = "00:12:47:08:9A:A6";
 
        if (!re.FullMatch(address))
        {
-               ThrowMsg(ConversionException, "not a bluetooth device address");
+               ThrowMsg(InvalidArgumentException, "not a bluetooth device address");
        }
 
        if (address.size() != compareAddress.size())
@@ -224,11 +220,6 @@ std::string BluetoothConverter::toBluetoothDeviceAddress(JSValueRef deviceAddres
 
 std::string BluetoothConverter::toBluetoothUUIDString(JSValueRef uuidString)
 {
-       if (!JSValueIsString(m_context, uuidString) || JSValueIsNull(m_context, uuidString))
-       {
-               ThrowMsg(ConversionException, "Not a string");
-       }
-
        std::string uuid = toString(uuidString);
        pcrecpp::RE re("(([0-9a-zA-Z]+)-)+([0-9a-zA-Z]+)");
        std::string compareUUID = "00001101-0000-1000-8000-00805F9B34FB";
@@ -236,7 +227,7 @@ std::string BluetoothConverter::toBluetoothUUIDString(JSValueRef uuidString)
        if (!re.FullMatch(uuid))
        {
                LogDebug("not a bluetooth service uuid");
-               ThrowMsg(ConversionException, "not a bluetooth service uuid");
+               ThrowMsg(InvalidArgumentException, "not a bluetooth service uuid");
        }
 
        if (uuid.size() != compareUUID.size())
@@ -250,19 +241,12 @@ std::string BluetoothConverter::toBluetoothUUIDString(JSValueRef uuidString)
 
 
 
-
-
 unsigned short BluetoothConverter::toBluetoothSecurityLevelInt(JSValueRef level)
 {
        unsigned short securityLevel= SECURITY_LEVEL_HIGH_VALUE_INT;
 
-       if (!JSValueIsNull(m_context, level))
+       if (!JSValueIsNull(m_context, level) && !JSValueIsUndefined(m_context, level))
        {
-               if (!JSValueIsString(m_context, level))
-               {
-                       ThrowMsg(ConversionException, "Not a string");
-               }
-       
                std::string securityLevelStr = toString(level);
                
                if(strcmp(securityLevelStr.c_str(), SECURITY_LEVEL_HIGH_VALUE) == 0) 
@@ -286,7 +270,36 @@ unsigned short BluetoothConverter::toBluetoothSecurityLevelInt(JSValueRef level)
 }
 
 
-
+unsigned short BluetoothConverter::toBluetoothProtocolInt(JSValueRef protocol)
+{
+       unsigned short bluetoothProtocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
+       std::string protocolString;
+       
+       if (JSValueIsNull(m_context, protocol) == true || JSValueIsUndefined(m_context, protocol) == true)
+       {
+               bluetoothProtocol  = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
+       }
+       else 
+       {
+               protocolString = toString(protocol);
+               LogDebug(protocolString.c_str());
+       
+               if (strcmp(protocolString.c_str(), PROTOCOL_TYPE_RFCOMM_VALUE) == 0)
+               {
+                       bluetoothProtocol = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
+               }
+               else if (strcmp(protocolString.c_str(), PROTOCOL_TYPE_L2CAP_VALUE) == 0)
+               {
+                       LogError("Not support protocol");
+                       Throw(UnsupportedException);    
+               }
+               else 
+               {
+                       Throw(InvalidArgumentException);        
+               }
+       }
+       return bluetoothProtocol;
+}
 JSValueRef BluetoothConverter::toBluetoothSecurityLevelJSValueRef(unsigned short level)
 {
        JSValueRef result;
@@ -303,6 +316,7 @@ JSValueRef BluetoothConverter::toBluetoothSecurityLevelJSValueRef(unsigned short
                result = toJSValueRef(SECURITY_LEVEL_LOW_VALUE);
                break;
        default:
+               ThrowMsg(InvalidArgumentException, "Not a security level value");
                result = toJSValueRef(SECURITY_LEVEL_HIGH_VALUE);               
        }
        return result;
@@ -321,7 +335,7 @@ JSValueRef BluetoothConverter::toBluetoothProtocolJSValue(unsigned short int pro
        }
        else
        {
-               ThrowMsg(ConversionException, "Not a protocol value");
+               ThrowMsg(InvalidArgumentException, "Not a protocol value");
        }
 }
 
@@ -338,8 +352,7 @@ JSValueRef BluetoothConverter::toBluetoothStateJSValue(unsigned short int state)
        }
        else
        {
-               ThrowMsg(ConversionException, "Not a state value");
-
+               ThrowMsg(InvalidArgumentException, "Not a state value");
        }
 }
 
index abdf7dd..76cb70c 100644 (file)
@@ -45,6 +45,7 @@ class BluetoothConverter : public WrtDeviceApis::CommonsJavaScript::Converter
        JSObjectRef toBluetoothDevices(const std::vector<TizenApis::Api::Bluetooth::BluetoothDeviceData>& devices);
        JSObjectRef toBluetoothByteArray(std::vector<char>& data);
        unsigned short toBluetoothSecurityLevelInt(JSValueRef level);
+       unsigned short toBluetoothProtocolInt(JSValueRef protocol);
        JSValueRef toBluetoothSecurityLevelJSValueRef(unsigned short level);
        std::string toBluetoothDeviceAddress(JSValueRef deviceAddress);
        std::string toBluetoothUUIDString(JSValueRef uuidString);
index 5a224ad..504b7fa 100644 (file)
@@ -44,7 +44,7 @@ JSCallbackManagerPtr EventBTOnDiscoveryDevicesPrivateData::getOnFinished() const
 BluetoothSocketNotifierPrivateData::BluetoothSocketNotifierPrivateData
                        (const JSCallbackManagerPtr& onMessage, const JSCallbackManagerPtr& onError,
                        const JSCallbackManagerPtr& onClose) :
-                       m_onMessage(onMessage), m_onError(onError), m_onClose(onClose){}
+                       m_onMessage(onMessage), m_onError(onError), m_onClose(onClose){ m_object = NULL;}
 
 JSCallbackManagerPtr BluetoothSocketNotifierPrivateData::getOnMessage() const
 {
index b366782..288f72e 100644 (file)
@@ -53,7 +53,7 @@ BluetoothSocketListener& BluetoothSocketListener::getInstance()
 void BluetoothSocketListener::onAnswerReceived(const EventBTSocketNotificationPtr& event)
 {
        LogDebug("Enter-Socket notification");
-
+       
        BluetoothSocketNotifierPrivateDataPtr multiCallbacks = 
                DPL::DynamicPointerCast<BluetoothSocketNotifierPrivateData>(event->getPrivateData());
 
@@ -65,6 +65,14 @@ void BluetoothSocketListener::onAnswerReceived(const EventBTSocketNotificationPt
        case EventBTSocketNotification::DATARECEIVED:
        {
                EventBTReadDataType readData;
+
+               if (multiCallbacks->getObject() == NULL)
+               {
+                       multiCallbacks->getOnError()->callOnSuccess(JSTizenExceptionFactory::makeErrorObject(multiCallbacks->getOnError()->getContext(), 
+                               JSTizenException::UNKNOWN_ERROR, "socket object is not set"));
+                       return;
+               }
+               
                JSBluetoothSocketPriv *priv = 
                        static_cast<JSBluetoothSocketPriv*>(JSObjectGetPrivate(multiCallbacks->getObject()));
                IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
index 82d97fd..324b4a1 100644 (file)
@@ -31,7 +31,6 @@
 #include "BluetoothAdapterListener.h"
 #include "BluetoothMultiCallback.h"
 #include "BluetoothConverter.h"
-
 #include "plugin_config.h"
 
 using namespace std;
@@ -105,7 +104,7 @@ JSValueRef JSBluetoothAdapter::getName(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                        
@@ -123,8 +122,8 @@ JSValueRef JSBluetoothAdapter::getName(JSContextRef context,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, "type mismatch error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -149,55 +148,51 @@ JSValueRef JSBluetoothAdapter::setName(JSContextRef context, JSObjectRef object,
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-       
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       JSValueRef reserveArguments[3];
+       size_t index = 0;
                
        Try 
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
+               }
+
+               for (index = 0; index < 3; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);
+                               
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               if (argumentCount < 1 || argumentCount > 3)
-               {
-                       Throw(InvalidArgumentException);        
-               }
-
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsString(context, arguments[0]) == false)
-               {
-                       Throw(ConversionException);     
-               }
-
                BluetoothConverter converter(priv->getContext());
 
-               if (argumentCount >= 2)
-               {
-                       successCallback = converter.toFunctionOrNull(arguments[1]);
-               }
+               successCallback = converter.toFunctionOrNull(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
 
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
-
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
-               
                if (cbm == NULL)
                {
                        Throw(UnknownException);
                }
-               
+
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
+
+               
+               
+
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
-               std::string name = converter.toString(arguments[0]);
+               std::string name = converter.toString(reserveArguments[0]);
+
 
                if (name != BluetoothAdapterManager->getName())
                {
@@ -214,7 +209,6 @@ JSValueRef JSBluetoothAdapter::setName(JSContextRef context, JSObjectRef object,
                        LogDebug("same name is already set");
                        cbm->callOnSuccess();
                }
-               return JSValueMakeNull(context);
        }       
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -226,8 +220,9 @@ JSValueRef JSBluetoothAdapter::setName(JSContextRef context, JSObjectRef object,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
+               
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -275,8 +270,8 @@ JSValueRef JSBluetoothAdapter::getAddress(JSContextRef context,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, "type mismatch error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -309,7 +304,7 @@ JSValueRef JSBluetoothAdapter::getVisible(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
@@ -326,8 +321,8 @@ JSValueRef JSBluetoothAdapter::getVisible(JSContextRef context,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, "type mismatch error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -431,7 +426,7 @@ JSValueRef JSBluetoothAdapter::getPowered(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
@@ -448,8 +443,8 @@ JSValueRef JSBluetoothAdapter::getPowered(JSContextRef context,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, "type mismatch error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -478,53 +473,47 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, JSObjectRef obje
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       
        Try     
        {
+               for (index = 0; index < 3; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);
+               }
+
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
                
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED]);
                
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (argumentCount < 1 || argumentCount > 3)
-               {
-                       Throw(InvalidArgumentException);        
-               }
-               
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsBoolean(context, arguments[0]) == false)
-               {
-                       Throw(ConversionException);     
-               }
                
                BluetoothConverter converter(priv->getContext());
 
-               if (argumentCount >= 2)
-               {
-                       successCallback = converter.toFunctionOrNull(arguments[1]);
-               }
-
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
-
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+               successCallback = converter.toFunctionOrNull(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
 
                if (cbm == NULL)
                {
                        Throw(UnknownException);        
                }
+
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
+
+
        
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTSetPoweredPtr event(new EventBTSetPowered);
@@ -535,20 +524,40 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, JSObjectRef obje
                        Throw(UnknownException);        
                }
 
-               if (converter.toBool(arguments[0]) == true)
+               bool powered = BluetoothAdapterManager->getPowered();
+               LogDebug(converter.toBool(reserveArguments[0]) << converter.toString(reserveArguments[0]));
+               
+               if (converter.toBool(reserveArguments[0]) == true)
                {
-                       event->setEnable();
+                       if (powered)
+                       {
+                               LogDebug("Already powered");
+                               cbm->callOnSuccess();
+                               return JSValueMakeUndefined(context);
+                       }
+                       else
+                       {
+                               event->setEnable();
+                       }
                }
                else
                {
-                       event->setDisable();
+                       if (powered == false)
+                       {
+                               LogDebug("Already power off");
+                               cbm->callOnSuccess();
+                               return JSValueMakeUndefined(context);
+                       }
+                       else
+                       {
+                               event->setDisable();
+                       }
                }
                
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
                BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
                event->setForAsynchronousCall(&listener);
                BluetoothAdapterManager->setPowered(event);
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -560,8 +569,8 @@ JSValueRef JSBluetoothAdapter::setPowered(JSContextRef context, JSObjectRef obje
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -585,45 +594,38 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
+       size_t index = 0;
+       JSValueRef reserveArguments[4];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
        Try     
        {
+               for (index = 0; index < 4; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+
+               }
+                       
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE]);
                
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                
-               if (argumentCount < 1 || argumentCount > 4)
-               {
-                       Throw(InvalidArgumentException);        
-               }
-
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsBoolean(context, arguments[0]) == false)
-               {
-                       Throw(ConversionException);
-               }
-               
                BluetoothConverter converter(priv->getContext());
 
-               if (argumentCount >= 2) 
-               {
-                       successCallback = converter.toFunctionOrNull(arguments[1]);
-               }
-
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
+               successCallback = converter.toFunctionOrNull(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
                
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
                if (cbm == NULL)
                {
@@ -633,11 +635,6 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
 
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsBoolean(context, arguments[0]) == false)
-               {
-                       LogError("Wrong parameter passed, type mismatch");
-                       Throw(ConversionException);     
-               }
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTSetVisiblePtr event(new EventBTSetVisible);
@@ -648,7 +645,7 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
                        Throw(UnknownException);        
                }
 
-               if (converter.toBool(arguments[0]) == true)
+               if (converter.toBool(reserveArguments[0]) == true)
                {
                        event->setVisible();
                }
@@ -659,20 +656,27 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
 
                if (argumentCount == 4)
                {
-                       if (JSValueIsNull(context, arguments[3]) == true)
+                       if (JSValueIsUndefined(context, reserveArguments[3]) == true || JSValueIsNull(context, reserveArguments[3]) == true)
                        {
                                event->setTimeout(0);
                        }
                        else
                        {
-                               if (JSValueIsNumber(context, arguments[3]) == false) 
+                               if (JSValueIsNumber(context, reserveArguments[3]) == false) 
                                {
                                        LogError("Wrong parameter passed");
                                        Throw(ConversionException);
                                }
                        }
-                       LogDebug("timeout " << (unsigned short)converter.toInt(arguments[3]));
-                       event->setTimeout((unsigned short)converter.toInt(arguments[3]));
+                       LogDebug("timeout " << (short)converter.toInt(reserveArguments[3]));
+                       short timeout = (short)converter.toInt(reserveArguments[3]);
+
+                       if (timeout < 0) 
+                       {
+                               LogError("Wrong parameter passed, timemut should be > 0");
+                               Throw(ConversionException);
+                       }
+                       event->setTimeout((unsigned short)converter.toInt(reserveArguments[3]));
                }
                else
                {
@@ -683,8 +687,6 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
                BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
                event->setForAsynchronousCall(&listener);
                BluetoothAdapterManager->setVisible(event);
-               
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -696,8 +698,8 @@ JSValueRef JSBluetoothAdapter::setVisible(JSContextRef context, JSObjectRef obje
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -721,25 +723,29 @@ JSValueRef JSBluetoothAdapter::discoveryDevices(JSContextRef context, JSObjectRe
 {
        LogDebug("discoveryDevices");
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
-
+       size_t index = 0;
+       JSValueRef reserveArguments[2];
+       
        Try     
        {
+               for (index = 0; index < 2; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+
+               }
+
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
                
-               if (argumentCount < 1 || argumentCount > 2)
-               {
-                       LogError("InvalidArgumentException");
-                       Throw(InvalidArgumentException);        
-               }
-
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES]);
                
 
@@ -747,14 +753,14 @@ JSValueRef JSBluetoothAdapter::discoveryDevices(JSContextRef context, JSObjectRe
                
                JSValueRef errorArgument = JSValueMakeNull(context);
 
-               if (argumentCount >= 2)
+               if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false)
                {
-                       errorArgument = arguments[1];
+                       errorArgument = reserveArguments[1];
                }
 
                BluetoothConverter converter(priv->getContext());
                EventBTOnDiscoveryDevicesPrivateDataPtr privData(
-                       converter.toEventBTOnDiscoveryDevicesPrivateData(thisObject, arguments[0], errorArgument));
+                       converter.toEventBTOnDiscoveryDevicesPrivateData(thisObject, reserveArguments[0], errorArgument));
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTOnDiscoveryDevicesEmitterPtr emitter(new EventBTOnDiscoveryDevicesEmitter);
@@ -767,9 +773,6 @@ JSValueRef JSBluetoothAdapter::discoveryDevices(JSContextRef context, JSObjectRe
                emitter->setListener(&BluetoothAdapterListener::getInstance());
                emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
                BluetoothAdapterManager->discoveryDevicesEmitter(emitter);
-
-               return JSValueMakeNull(context);
-
        }       
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -782,7 +785,7 @@ JSValueRef JSBluetoothAdapter::discoveryDevices(JSContextRef context, JSObjectRe
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -808,44 +811,46 @@ JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, JSObjectRef o
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-       
+       size_t index = 0;
+       JSValueRef reserveArguments[2];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
        Try     
        {
+               for (index = 0; index < 2; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+
+               }
+                       
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               if (argumentCount > 2)
-               {
-                       LogError("InvalidArgumentException");
-                       Throw(InvalidArgumentException);        
-               }
-
                BluetoothConverter converter(priv->getContext());
 
-               if (argumentCount >= 1)
+               if (argumentCount >= 1 && JSValueIsUndefined(context, reserveArguments[0]) == false)
                {
-                       successCallback = converter.toFunctionOrNull(arguments[0]);
+                       successCallback = converter.toFunctionOrNull(reserveArguments[0]);
                }
                
-               if (argumentCount >= 2)
+               if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false)
                {
-                       errorCallBack = converter.toFunctionOrNull(arguments[1]);
+                       errorCallBack = converter.toFunctionOrNull(reserveArguments[1]);
                }
 
-
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
                
                if (cbm == NULL)
                {
@@ -862,8 +867,6 @@ JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, JSObjectRef o
                BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
                event->setForAsynchronousCall(&listener);
                BluetoothAdapterManager->stopDiscovery(event);
-
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -875,8 +878,8 @@ JSValueRef JSBluetoothAdapter::stopDiscovery(JSContextRef context, JSObjectRef o
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -905,39 +908,41 @@ JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, JSObjectRef
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       size_t index = 0;
+       JSValueRef reserveArguments[2];
+       
        Try     
        {
+               for (index = 0; index < 2; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+
+               }
+               
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_GET_KNOWN_DEVICES]);
                
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               if (argumentCount < 1 || argumentCount > 2)
-               {
-                       LogError("InvalidArgumentException");
-                       Throw(InvalidArgumentException);
-               }
-
                BluetoothConverter converter(priv->getContext());
-               successCallback = converter.toFunction(arguments[0]);
+               successCallback = converter.toFunction(reserveArguments[0]);
                
-               if (argumentCount >= 2)
+               if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false)
                {
-                       errorCallBack = converter.toFunctionOrNull(arguments[1]);
+                       errorCallBack = converter.toFunctionOrNull(reserveArguments[1]);
                }
 
-
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
-               
                if (cbm == NULL)
                {
                        Throw(UnknownException);        
@@ -960,8 +965,6 @@ JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, JSObjectRef
                BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
                event->setForAsynchronousCall(&listener);
                BluetoothAdapterManager->getKownDevices(event);
-               
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -973,8 +976,8 @@ JSValueRef JSBluetoothAdapter::getKnownDevices(JSContextRef context, JSObjectRef
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -1000,48 +1003,48 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef objec
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
        Try     
        {
+               for (index = 0; index < 3; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+
+               }
+               
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER_GET_DEVICE]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                
-               if (argumentCount < 2 || argumentCount > 3)
-               {
-                       LogError("Wrong parameter count passed");
-                       Throw(InvalidArgumentException);
-               }
-
                BluetoothConverter converter(priv->getContext());
-               std::string address = converter.toBluetoothDeviceAddress(arguments[0]);
-               successCallback = converter.toFunction(arguments[1]);
-               
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
+               successCallback = converter.toFunction(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
 
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
-               
                if (cbm == NULL)
                {
                        Throw(UnknownException);        
                }
-                       
+
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
 
+               std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]);
+       
+
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTGetDevicePtr event(new EventBTGetDevice);
 
@@ -1056,8 +1059,6 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef objec
                event->setForAsynchronousCall(&listener);
                event->setAddress(address);
                BluetoothAdapterManager->getDevice(event);
-
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -1069,8 +1070,8 @@ JSValueRef JSBluetoothAdapter::getDevice(JSContextRef context, JSObjectRef objec
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -1098,42 +1099,39 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef o
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
+       size_t index = 0; 
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
        Try     
        {
 
+               for (index = 0; index < 3; index++)
+               {
+
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               }
+               
+
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_CREATE_BONDING]);
 
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               if (argumentCount < 2 || argumentCount > 3)
-               {
-                       LogError("Wrong parameter count passed");
-                       Throw(InvalidArgumentException);
-
-               }
-
-
                BluetoothConverter converter(priv->getContext());
-               std::string address = converter.toBluetoothDeviceAddress(arguments[0]);
-               successCallback = converter.toFunction(arguments[1]);
-               
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
+               successCallback = converter.toFunction(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
 
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
-               
                if (cbm == NULL)
                {
                        Throw(UnknownException);        
@@ -1142,6 +1140,8 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef o
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
 
+               std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]);
+
 
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTCreateDestroyBondingPtr event(new EventBTCreateDestroyBonding);
@@ -1151,14 +1151,19 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef o
                        LogError("BluetoothAdapterManager or event or listener NULL");
                        Throw(UnknownException);        
                }
+               BluetoothCreateBondingPrivateDataPtr privData(new BluetoothCreateBondingPrivateData(cbm, thisObject));
 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+//             event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (privData));
                BluetoothAdapterListener& listener = BluetoothAdapterListener::getInstance();
                event->setForAsynchronousCall(&listener);
                event->setAddress(address);
                event->setCreateBonding();
                BluetoothAdapterManager->createBonding(event);
-               return JSValueMakeNull(context);
+               // temporarily remove pending operation
+//             JSValueRef pendingOperation = makePendingOperation(context, event);
+                       //JSBluetoothDummyPendingOperation::createJSObject(context);
+       //      return pendingOperation;
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -1170,8 +1175,8 @@ JSValueRef JSBluetoothAdapter::createBonding(JSContextRef context, JSObjectRef o
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -1200,42 +1205,34 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       
        Try     
        {
+               for (index = 0; index < 3; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                
+               }
+               
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_DESTROY_BONDING]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               if (argumentCount < 1 || argumentCount > 3)
-               {
-                       LogError("Wrong parameter count passed");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
-               }
-
                BluetoothConverter converter(priv->getContext());
-               std::string address = converter.toBluetoothDeviceAddress(arguments[0]);
-
-               if (argumentCount >= 2)
-               {
-                       successCallback = converter.toFunctionOrNull(arguments[1]);
-               }
-               
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
-
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+               successCallback = converter.toFunctionOrNull(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
                
                if (cbm == NULL)
                {
@@ -1244,6 +1241,8 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
+
+               std::string address = converter.toBluetoothDeviceAddress(reserveArguments[0]);
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTCreateDestroyBondingPtr event(new EventBTCreateDestroyBonding);
@@ -1260,8 +1259,6 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef
                event->setDestroyBonding();
                event->setAddress(address);
                BluetoothAdapterManager->createBonding(event);
-               
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -1273,8 +1270,8 @@ JSValueRef JSBluetoothAdapter::destroyBonding(JSContextRef context, JSObjectRef
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -1303,9 +1300,20 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
        JSBluetoothAdapterPriv *priv = static_cast<JSBluetoothAdapterPriv*>(JSObjectGetPrivate(thisObject));    
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       size_t index = 0;
+       JSValueRef reserveArguments[5];
 
        Try     
        {
+               for (index = 0; index < 5; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                
+               }
+                       
                std::string serviceName, uuid;
                unsigned short securityLevel= SECURITY_LEVEL_HIGH_VALUE_INT;
                Validator validator(context);           
@@ -1315,51 +1323,37 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               
-               if (argumentCount < 3 || argumentCount > 5)
-               {
-                       LogError("Wrong parameter count passed");       
-                       Throw(InvalidArgumentException);
-               }
-
                BluetoothConverter converter(priv->getContext());
-               uuid = converter.toBluetoothUUIDString(arguments[0]);
+               successCallback = converter.toFunction(reserveArguments[2]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[3]);
 
-               if (!JSValueIsString(context, arguments[1]) || JSValueIsNull(context, arguments[1]))
-               {
-                       ThrowMsg(ConversionException, "Not a string");
-               }
-               serviceName = converter.toString(arguments[1]);
-               successCallback = converter.toFunction(arguments[2]);
-               
-               if (argumentCount >= 4)
+               if (cbm == NULL)
                {
-                       errorCallBack = converter.toFunctionOrNull(arguments[3]);
+                       Throw(UnknownException);        
                }
+
+               cbm->setOnSuccess(successCallback);
+               cbm->setOnError(errorCallBack);
+
+
+               uuid = converter.toBluetoothUUIDString(reserveArguments[0]);
+               serviceName = converter.toString(reserveArguments[1]);
+
                
                if (argumentCount >= 5)
                {
-                       securityLevel = converter.toBluetoothSecurityLevelInt(arguments[4]);
+                       securityLevel = converter.toBluetoothSecurityLevelInt(reserveArguments[4]);
                }
        
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
                
-               if (cbm == NULL)
-               {
-                       Throw(UnknownException);        
-               }
-
-               cbm->setOnSuccess(successCallback);
-               cbm->setOnError(errorCallBack);
                
                IBluetoothAdapterManagerPtr BluetoothAdapterManager(priv->getObject());
                EventBTRegisterRFCOMMPtr event(new EventBTRegisterRFCOMM);
@@ -1378,8 +1372,6 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
                event->setSecurityLevel(securityLevel); 
                event->setName(serviceName);
                BluetoothAdapterManager->registerRFCOMMServiceByUUID(event);
-
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -1391,8 +1383,8 @@ JSValueRef JSBluetoothAdapter::registerRFCOMMServiceByUUID(JSContextRef context,
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
index e21350c..34a8f42 100644 (file)
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <API/Bluetooth/IBluetoothAdapterManager.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
 
 using namespace TizenApis::Api::Bluetooth;
 using namespace WrtDeviceApis::CommonsJavaScript;
-
+using namespace WrtDeviceApis::Commons;
 
 namespace TizenApis {
 namespace Tizen1_0 {
 
 typedef PrivateObjectT<Api::Bluetooth::IBluetoothAdapterManagerPtr>::Type JSBluetoothAdapterPriv;
+
+class BluetoothCreateBondingPrivateData : public IEventPrivateData
+{
+public :
+       BluetoothCreateBondingPrivateData(const JSCallbackManagerPtr &callbackManager,
+               JSObjectRef object) : 
+               m_callbackManager(callbackManager),
+               m_object(object) {}
+
+       virtual ~BluetoothCreateBondingPrivateData() {}
+
+       JSCallbackManagerPtr getCallbackManager() const {return m_callbackManager;}
+       JSObjectRef getObject() const {return m_object;};
+private:
+       JSCallbackManagerPtr m_callbackManager;
+       JSObjectRef m_object;
+};
+
+typedef DPL::SharedPtr<BluetoothCreateBondingPrivateData> BluetoothCreateBondingPrivateDataPtr;
+
+
 class JSBluetoothAdapter {
 public:
        static const JSClassDefinition* getClassInfo();
index 03ea433..c4e27e2 100644 (file)
@@ -181,7 +181,7 @@ JSValueRef JSBluetoothClass::getProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
 
                BluetoothClassPtr btClass(priv->getObject());
@@ -239,26 +239,24 @@ JSValueRef JSBluetoothClass::hasService(JSContextRef context, JSObjectRef object
 
 {
        JSBluetoothClassPriv* priv = static_cast<JSBluetoothClassPriv*>(JSObjectGetPrivate(thisObject));        
-       
+       JSValueRef reserveArgument = JSValueMakeUndefined(context);
+
        try 
        {
                if (priv == NULL)
                {
                        LogError("priv null");
 
-                       Throw(WrtDeviceApis::Commons::UnknownException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
 
-               if (argumentCount != 1 || JSValueIsNull(context, arguments[0]) == true 
-                       || JSValueIsNumber(context, arguments[0]) == false)
+               if (argumentCount >= 1)
                {
-                       LogError("argument fail");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       reserveArgument = arguments[0];
                }
 
                
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
                                bluetoothExportedNames[BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -285,6 +283,12 @@ JSValueRef JSBluetoothClass::hasService(JSContextRef context, JSObjectRef object
                return JSTizenExceptionFactory::postException(context, exception, 
                        JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");     
        }       
+       Catch (WrtDeviceApis::Commons::ConversionException) 
+       {
+               LogError("TypemismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");  
+       }       
        Catch (WrtDeviceApis::Commons::SecurityException) 
        {
                LogError("permission denied error");
index a211af0..4811157 100644 (file)
@@ -154,7 +154,7 @@ JSValueRef JSBluetoothClassDeviceMajor::getProperty(JSContextRef context,
                
                if (priv == NULL)
                {
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
                
                Converter converter(context);
@@ -168,6 +168,12 @@ JSValueRef JSBluetoothClassDeviceMajor::getProperty(JSContextRef context,
                }
                return converter.toJSValueRef(value);
        }
+       Catch (WrtDeviceApis::Commons::ConversionException) 
+       {
+               LogError("TypemismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");  
+       }       
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
index 1748072..c84044a 100644 (file)
@@ -216,7 +216,7 @@ JSValueRef JSBluetoothClassDeviceMinor::getProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
                
                Converter converter(context);
@@ -230,6 +230,12 @@ JSValueRef JSBluetoothClassDeviceMinor::getProperty(JSContextRef context,
                }
                return converter.toJSValueRef(value);
        }
+       Catch (WrtDeviceApis::Commons::ConversionException) 
+       {
+               LogError("TypemismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");  
+       }       
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
index 5850885..3033551 100644 (file)
@@ -154,7 +154,7 @@ JSValueRef JSBluetoothClassDeviceService::getProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       Throw(WrtDeviceApis::Commons::ConversionException);
                }
 
                BluetoothClassPtr btClass(priv->getObject());
@@ -167,6 +167,12 @@ JSValueRef JSBluetoothClassDeviceService::getProperty(JSContextRef context,
                }
                return converter.toJSValueRef(value);
        }
+       Catch (WrtDeviceApis::Commons::ConversionException) 
+       {
+               LogError("TypemismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");  
+       }       
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
index ac0de97..a54f08d 100644 (file)
@@ -165,7 +165,7 @@ JSValueRef JSBluetoothDevice::getName(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
@@ -184,7 +184,7 @@ JSValueRef JSBluetoothDevice::getName(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -215,7 +215,7 @@ JSValueRef JSBluetoothDevice::getAddress(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
@@ -235,7 +235,7 @@ JSValueRef JSBluetoothDevice::getAddress(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -264,7 +264,7 @@ JSValueRef JSBluetoothDevice::getDeviceClass(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
                BluetoothDeviceDataClass devClass = BluetoothDeviceManager->getClass();
@@ -285,7 +285,7 @@ JSValueRef JSBluetoothDevice::getDeviceClass(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -316,7 +316,7 @@ JSValueRef JSBluetoothDevice::getBondProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
@@ -337,7 +337,7 @@ JSValueRef JSBluetoothDevice::getBondProperty(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -367,7 +367,7 @@ JSValueRef JSBluetoothDevice::getTrustProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
 
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
@@ -387,7 +387,7 @@ JSValueRef JSBluetoothDevice::getTrustProperty(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -417,7 +417,7 @@ JSValueRef JSBluetoothDevice::getConnectProperty(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
                bool isConnected = BluetoothDeviceManager->getConnectProperty();
@@ -436,7 +436,7 @@ JSValueRef JSBluetoothDevice::getConnectProperty(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -468,7 +468,7 @@ JSValueRef JSBluetoothDevice::getUuids(JSContextRef context,
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);
+                       Throw(ConversionException);
                }
                
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
@@ -504,7 +504,7 @@ JSValueRef JSBluetoothDevice::getUuids(JSContextRef context,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -534,48 +534,39 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObj
        JSBluetoothDevicePriv *priv = static_cast<JSBluetoothDevicePriv*>(JSObjectGetPrivate(thisObject));
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-
+       size_t index = 0;
+       JSValueRef reserveArguments[4];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
        Try     {
 
+               for (index = 0; index < 4; index++)
+               {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeNull(context);
+                       
+               }
 
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
 
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if (argumentCount < 2 || argumentCount > 4)
-               {
-                       LogError("InvalidArgumentException");
-                       return JSTizenExceptionFactory::postException(context, 
-                               exception, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
-
-               }
-               if (JSValueIsNull(context, arguments[0]) == true || JSValueIsString(context, arguments[0]) == false)
-               {
-                       LogError("hasInstance TypeMismatchException");
-                       return JSTizenExceptionFactory::postException(context, 
-                               exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-               }
                
                BluetoothConverter converter(context);
-               successCallback = converter.toFunction(arguments[1]);
+               successCallback = converter.toFunction(reserveArguments[1]);
+               errorCallBack = converter.toFunctionOrNull(reserveArguments[2]);
                
-               if (argumentCount >= 3)
-               {
-                       errorCallBack = converter.toFunctionOrNull(arguments[2]);
-               }
-               
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
 
                if (cbm == NULL)
                {
@@ -587,39 +578,12 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObj
                IBluetoothDeviceManagerPtr BluetoothDeviceManager(priv->getObject());
                EventBTConnectToServiceByUUIDPtr event(new EventBTConnectToServiceByUUID);
                BluetoothSocketData socketData;
-               socketData.uuid = converter.toString(arguments[0]);
+               socketData.uuid = converter.toBluetoothUUIDString(reserveArguments[0]);
                socketData.protocol  = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
 
                if (argumentCount >= 4)
                {
-                       if (JSValueIsNull(context, arguments[3]) == true)
-                       {
-                               socketData.protocol  = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
-                       }
-                       else 
-                       {
-                               if (JSValueIsString(context, arguments[3]) == false)
-                               {
-                                       
-                                       LogError("InvalidArgumentException");
-                                       return JSTizenExceptionFactory::postException(context, 
-                                               exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-                               }
-
-                               std::string protocol = converter.toString(arguments[3]);
-                               LogDebug(protocol.c_str());
-
-                               if (strcmp(protocol.c_str(), PROTOCOL_TYPE_RFCOMM_VALUE) == 0)
-                               {
-                                       socketData.protocol  = PROTOCOL_TYPE_RFCOMM_VALUE_INT;
-                               }
-                               else                    
-                               {
-                                       LogError("BluetoothDeviceManager or event or listener NULL");
-                                       Throw(WrtDeviceApis::Commons::UnsupportedException);    
-                               }
-
-                       }
+                       socketData.protocol = converter.toBluetoothProtocolInt(reserveArguments[3]);
                }
                
                if (BluetoothDeviceManager == NULL || event == NULL)
@@ -633,8 +597,6 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObj
                event->setForAsynchronousCall(&BluetoothDeviceManagerListener::getInstance());
                event->setSocketData(socketData);
                BluetoothDeviceManager->connectToServiceByUUID(event);
-
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -664,8 +626,6 @@ JSValueRef JSBluetoothDevice::connectToServiceByUUID(JSContextRef context, JSObj
 
        return JSValueMakeUndefined(context);
 }
-
-
 }
 }
 
index 1a1f735..2b63ca6 100644 (file)
@@ -22,6 +22,7 @@
 #include <CommonsJavaScript/Utils.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
 #include <API/Bluetooth/BluetoothFactory.h>
 #include <API/Bluetooth/IBluetoothAdapterManager.h>
 #include <API/Bluetooth/BluetoothProperty.h>
 #include "JSBluetoothClassDeviceMajor.h"
 #include "JSBluetoothClassDeviceMinor.h"
 #include "JSBluetoothClassDeviceService.h"
+#include "plugin_config.h"
 
 
 using namespace TizenApis::Api::Bluetooth;
 using namespace WrtDeviceApis::Commons;
 using namespace TizenApis::Commons;
 
-
+namespace {
+       #define DEVICE_MAJOR "deviceMajor"
+       #define DEVICE_MINOR "deviceMinor"
+       #define DEVICE_SERVICE "deviceService"
+}
 namespace TizenApis {
 namespace Tizen1_0 {
 
@@ -73,14 +79,9 @@ JSStaticFunction JSBluetoothManager::m_function[] =
 
 JSStaticValue JSBluetoothManager::m_properties[] = 
 {
-/*     {PROTOCOL_TYPE_RFCOMM, getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {PROTOCOL_TYPE_L2CAP, getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {SECURITY_LEVEL_LOW, getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {SECURITY_LEVEL_MEDIUM, getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {SECURITY_LEVEL_HIGH, getProperty, NULL, kJSPropertyAttributeReadOnly},*/
-       {"DeviceMajor", getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {"DeviceMinor", getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {"DeviceService", getProperty, NULL, kJSPropertyAttributeReadOnly},     
+       {DEVICE_MAJOR, getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {DEVICE_MINOR, getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {DEVICE_SERVICE, getProperty, NULL, kJSPropertyAttributeReadOnly},      
        {0, 0, 0, 0}
 };
 
@@ -101,12 +102,19 @@ JSValueRef JSBluetoothManager::getDefaultAdapter(JSContextRef context, JSObjectR
 {
        JSBluetoothManagerPriv* priv = static_cast<JSBluetoothManagerPriv*>(JSObjectGetPrivate(thisObject));
 
+       LogDebug("OK"); 
+
        Try     
        {
                if (priv == NULL)
                {
-                       Throw(UnknownException);        
+                       Throw(ConversionException);     
                }
+               
+               AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
+                               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
                JSContextRef globalContext = priv->getContext();
 
                return JSBluetoothAdapter::createJSObject(globalContext);
@@ -154,36 +162,15 @@ JSValueRef JSBluetoothManager::getProperty(JSContextRef context,
        
        try 
        {
-       /*
-               if(JSStringIsEqualToUTF8CString(propertyName, PROTOCOL_TYPE_RFCOMM)) 
-               {
-                       return converter.toJSValueRef(PROTOCOL_TYPE_RFCOMM_VALUE);
-               }
-               else if(JSStringIsEqualToUTF8CString(propertyName, PROTOCOL_TYPE_L2CAP)) 
-               {
-                       return converter.toJSValueRef(PROTOCOL_TYPE_L2CAP_VALUE);
-               }
-               else if(JSStringIsEqualToUTF8CString(propertyName, SECURITY_LEVEL_LOW)) 
-               {
-                       return converter.toJSValueRef(SECURITY_LEVEL_LOW_VALUE);
-               }
-               else if(JSStringIsEqualToUTF8CString(propertyName, SECURITY_LEVEL_MEDIUM)) 
-               {
-                       return converter.toJSValueRef(SECURITY_LEVEL_MEDIUM_VALUE);
-               }
-               else if(JSStringIsEqualToUTF8CString(propertyName, SECURITY_LEVEL_HIGH)) 
-               {
-                       return converter.toJSValueRef(SECURITY_LEVEL_HIGH_VALUE);
-               }
-               else*/ if(JSStringIsEqualToUTF8CString(propertyName, "DeviceMajor")) 
+               if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MAJOR)) 
                {
                        return JSBluetoothClassDeviceMajor::createJSObject(context);
                }
-               else if(JSStringIsEqualToUTF8CString(propertyName, "DeviceMinor")) 
+               else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_MINOR)) 
                {
                        return JSBluetoothClassDeviceMinor::createJSObject(context);
                }
-               else if(JSStringIsEqualToUTF8CString(propertyName, "DeviceService")) 
+               else if(JSStringIsEqualToUTF8CString(propertyName, DEVICE_SERVICE)) 
                {
                        return JSBluetoothClassDeviceService::createJSObject(context);
                }
index 06259da..3915afd 100644 (file)
@@ -69,7 +69,7 @@ JSClassDefinition JSBluetoothServiceHandler::m_classInfo =
 JSStaticValue JSBluetoothServiceHandler::m_properties[] = 
 {
        {"uuid", getUuid, NULL, kJSPropertyAttributeReadOnly},
-       {"onConnect", NULL, setOnConnect, kJSPropertyAttributeNone},
+       {"onconnect", NULL, setOnConnect, kJSPropertyAttributeNone},
        {"name", getName, NULL, kJSPropertyAttributeReadOnly},                  
        {"isConnected", getIsConnected, NULL, kJSPropertyAttributeReadOnly},                    
        {0, 0, 0, 0}
@@ -365,43 +365,45 @@ JSValueRef JSBluetoothServiceHandler::unregisterRFCOMMService(JSContextRef conte
        
        JSValueRef successCallback = NULL;
        JSValueRef errorCallBack = NULL;
-       
+       JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(thisObject));
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
+       size_t index = 0;
+       JSValueRef reserveArguments[2];
        Try     
        {
-               JSBluetoothServiceHandlerPriv *priv = static_cast<JSBluetoothServiceHandlerPriv*>(JSObjectGetPrivate(thisObject));
-
-               if (priv == NULL)
+               for (index = 0; index < 2; index++)
                {
-                       LogError("priv null");
-                       Throw(UnknownException);        
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);
                }
+               
 
-               if (argumentCount > 2)
+               if (priv == NULL)
                {
-                       LogError("Wrong parameter count passed");
-                       Throw(InvalidArgumentException);
+                       LogError("priv null");
+                       Throw(ConversionException);     
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                               priv->getContext(),
-                               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM]);
+                               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER]);
                
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
        
 
                BluetoothConverter converter(priv->getContext());
 
-               if (argumentCount >= 1)
+               if (argumentCount >= 1 && JSValueIsUndefined(context, reserveArguments[0]) == false)
                {
-                       successCallback = converter.toFunctionOrNull(arguments[0]);
+                       successCallback = converter.toFunctionOrNull(reserveArguments[0]);
                }
                
-               if (argumentCount >= 2)
+               if (argumentCount >= 2 && JSValueIsUndefined(context, reserveArguments[1]) == false)
                {
-                       errorCallBack = converter.toFunctionOrNull(arguments[1]);
+                       errorCallBack = converter.toFunctionOrNull(reserveArguments[1]);
                }
 
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(priv->getContext(), NULL, NULL);
                
                if (cbm == NULL)
                {
@@ -410,7 +412,6 @@ JSValueRef JSBluetoothServiceHandler::unregisterRFCOMMService(JSContextRef conte
                        
                cbm->setOnSuccess(successCallback);
                cbm->setOnError(errorCallBack);
-//             cbm->setObject(thisObject);
                
                IBluetoothServiceHandlerManagerPtr BluetoothServiceHandlerManager(priv->getObject());
                EventBTUnregisterRFCOMMServicePtr event(new EventBTUnregisterRFCOMMService);
@@ -426,7 +427,6 @@ JSValueRef JSBluetoothServiceHandler::unregisterRFCOMMService(JSContextRef conte
                event->setForAsynchronousCall(&listener);
                BluetoothServiceHandlerManager->unRegister(event);
                
-               return JSValueMakeNull(context);
        }
        Catch (WrtDeviceApis::Commons::ConversionException)
        {
@@ -438,16 +438,14 @@ JSValueRef JSBluetoothServiceHandler::unregisterRFCOMMService(JSContextRef conte
        Catch (WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::INVALID_VALUES_ERROR, "invalid parameter error");
-
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(priv->getContext(), 
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid values error"));       
        }
        Catch (WrtDeviceApis::Commons::Exception) 
        {
                LogError("Exception");
                return JSTizenExceptionFactory::postException(context, exception, 
                        JSTizenException::UNKNOWN_ERROR, "unknown error");
-
        }       
        return JSValueMakeUndefined(context);
 }
index c0b58b2..282b9cf 100644 (file)
@@ -72,9 +72,9 @@ JSStaticValue JSBluetoothSocket::m_properties[] =
        {"protocol", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"state", getProperty, NULL, kJSPropertyAttributeReadOnly},
        {"peer", getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {"onError", NULL, setProperty, kJSPropertyAttributeNone},
-       {"onMessage", NULL, setProperty, kJSPropertyAttributeNone},
-       {"onClose", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onerror", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onmessage", NULL, setProperty, kJSPropertyAttributeNone},
+       {"onclose", NULL, setProperty, kJSPropertyAttributeNone},
        {0, 0, 0, 0}
 };
 
@@ -270,7 +270,7 @@ JSValueRef JSBluetoothSocket::getProperty(JSContextRef context,
                if (priv == NULL)
                {
                        LogError("priv null");
-                       Throw(WrtDeviceApis::Commons::UnknownException);        
+                       Throw(WrtDeviceApis::Commons::ConversionException);     
                }
 
                if(JSStringIsEqualToUTF8CString(propertyName, "uuid")) 
@@ -345,17 +345,16 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
                if (priv == NULL) 
                {
                        LogError("priv null");
-                       Throw(WrtDeviceApis::Commons::UnknownException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
-               if (argumentCount < 1 || JSValueIsNull(context, arguments[0]) == true)
+               if (argumentCount < 1)
                {
                        LogError("argument wrong");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_WRITE_DATA]);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -367,7 +366,7 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
                if (data.size() == 0)
                {
                        LogError("size 0 array passed");
-                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);                                
+                       Throw(WrtDeviceApis::Commons::ConversionException);                             
                }
 
         DPL::ScopedArray<char> buffer(new char[data.size()]);
@@ -402,7 +401,7 @@ JSValueRef JSBluetoothSocket::writeData(JSContextRef context, JSObjectRef object
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -435,7 +434,6 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
                IBluetoothSocketManagerPtr BluetoothSocketManager(priv->getObject());
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA]);
                
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
@@ -473,7 +471,7 @@ JSValueRef JSBluetoothSocket::readData(JSContextRef context, JSObjectRef object,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
@@ -507,12 +505,18 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, JSObjectRef object,
                LogDebug(bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]);
 
                AceSecurityStatus status = BLUETOOTH_CHECK_ACCESS(
-                       priv->getContext(),
                        bluetoothExportedNames[BLUETOOTH_FUNCTION_API_SOCKET_CLOSE]);
 
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
+               if (BluetoothSocketManager->close() != BT_ERROR_NONE)
+               {
+                       Throw(WrtDeviceApis::Commons::UnknownException);        
+               }
+
+               return JSValueMakeNull(context);
+
        }
        Catch (WrtDeviceApis::Commons::SecurityException) 
        {
@@ -531,7 +535,7 @@ JSValueRef JSBluetoothSocket::close(JSContextRef context, JSObjectRef object,
        {
                LogError("InvalidArgumentException");
                return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::TYPE_MISMATCH_ERROR, "invalid value error");
+                               JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
        }
        Catch(WrtDeviceApis::Commons::UnsupportedException)
        {
index d44963c..4b84739 100644 (file)
@@ -6,70 +6,23 @@
        <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
        <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
        <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
-
        <api-feature>
                <name>http://tizen.org/api/bluetooth</name>
-               <device-capability>bluetooth</device-capability>
-               <Object name="bluetooth">
-               </Object>
+               <device-capability>bluetooth.admin</device-capability>
+               <device-capability>bluetooth.gap</device-capability>
+               <device-capability>bluetooth.spp</device-capability>
        </api-feature>
        <api-feature>
-               <name>http://tizen.org/api/bluetooth</name>
-               <Object name="adapter">
-                       <Function name="setPowered" />
-                       <Function name="setVisible" />
-                       <Function name="discoverDevices" />
-                       <Function name="stopDiscovery" />
-                       <Function name="getKnownDevices" />
-                       <Function name="getDevice" />
-                       <Function name="createBonding" />
-                       <Function name="destroyBonding" />
-                       <Function name="registerRFCOMMServiceByUUID" />
-                       <Function name="unregisterRFCOMMService" />
-               </Object>
-               <Object name="BluetoothDevice">
-                       <Function name="connectToServiceByUUID" />
-               </Object>
-               <Object name="BluetoothSocket">
-                       <Function name="setSocketNotifier" />
-                       <Function name="writeData" />
-                       <Function name="readData" />
-                       <Function name="close" />
-               </Object>
-               <Object name="BluetoothClass">
-                       <Function name="hasService" />
-               </Object>
+               <name>http://tizen.org/api/bluetooth.admin</name>
+               <device-capability>bluetooth.admin</device-capability>
        </api-feature>
        <api-feature>
                <name>http://tizen.org/api/bluetooth.gap</name>
                <device-capability>bluetooth.gap</device-capability>
-               <Object name="adapter">
-                       <Function name="setPowered" />
-                       <Function name="setVisible" />
-                       <Function name="discoverDevices" />
-                       <Function name="stopDiscovery" />
-                       <Function name="getKnownDevices" />
-                       <Function name="getDevice" />
-                       <Function name="createBonding" />
-                       <Function name="destroyBonding" />
-                       <Function name="registerRFCOMMServiceByUUID" />
-               </Object>
        </api-feature>
        <api-feature>
                <name>http://tizen.org/api/bluetooth.spp</name>
                <device-capability>bluetooth.spp</device-capability>
-               <Object name="BluetoothDevice">
-                       <Function name="connectToServiceByUUID" />
-               </Object>
-               <Object name="BluetoothSocket">
-                       <Function name="setSocketNotifier" />
-                       <Function name="writeData" />
-                       <Function name="readData" />
-                       <Function name="close" />
-               </Object>
-               <Object name="BluetoothClass">
-                       <Function name="hasService" />
-               </Object>
        </api-feature>
 </plugin-properties>
 
index 747f7b4..c9ec75f 100644 (file)
 #include "plugin_config.h"
 
 #define BLUETOOTH_FEATURE_API "http://tizen.org/api/bluetooth"
+#define BLUETOOTH_FEATURE_API_ADMIN "http://tizen.org/api/bluetooth.admin"
 #define BLUETOOTH_FEATURE_API_GAP "http://tizen.org/api/bluetooth.gap"
 #define BLUETOOTH_FEATURE_API_SPP "http://tizen.org/api/bluetooth.spp"
 
+#define BLUETOOTH_DEVICE_CAP_ADMIN "bluetooth.admin"
 #define BLUETOOTH_DEVICE_CAP_GAP "bluetooth.gap"
 #define BLUETOOTH_DEVICE_CAP_SPP "bluetooth.spp"
 
@@ -34,10 +36,10 @@ namespace Tizen1_0 {
 
 const char* bluetoothExportedNames[] = 
 {
-       "adapter",
+       "getDefaultAdapter",
+       "setName",
        "setPowered",
        "setVisible",
-       "setName",
        "discoverDevices",
        "stopDiscovery",
        "getKnownDevices",
@@ -45,9 +47,8 @@ const char* bluetoothExportedNames[] =
        "createBonding",
        "destroyBonding",
        "registerRFCOMMServiceByUUID",
-       "unregisterRFCOMMService",
+       "unregister",
        "connectToServiceByUUID",
-       "setSocketNotifier",
        "writeData",
        "readData",
        "close",
@@ -63,78 +64,123 @@ DEFINE_FUNCTION_GETTER(Bluetooth, BluetoothFunctions);
 
 static WrtDeviceApis::Commons::FunctionMapping createBluetoothFunctions()
 {
-    using namespace WrtDeviceApis::Commons;
+       using namespace WrtDeviceApis::Commons;
 
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_GAP, BLUETOOTH_DEVICE_CAP_GAP);
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_SPP, BLUETOOTH_DEVICE_CAP_SPP);
+       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_ADMIN, BLUETOOTH_DEVICE_CAP_ADMIN);
+       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_GAP, BLUETOOTH_DEVICE_CAP_GAP);
+       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_BLUETOOTH_SPP, BLUETOOTH_DEVICE_CAP_SPP);
 
-    ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
+       ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
 
-    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_GAP);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_GAP, DEVICE_CAP_BLUETOOTH_GAP);
+       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_ADMIN);
+       ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_ADMIN, DEVICE_CAP_BLUETOOTH_ADMIN);
 
-    ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_SPP);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_SPP, DEVICE_CAP_BLUETOOTH_SPP);
+       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_GAP);
+       ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_GAP, DEVICE_CAP_BLUETOOTH_GAP);
 
-    ACE_CREATE_FEATURE(FEATURE_BLUETOOTH, BLUETOOTH_FEATURE_API);
-    ACE_CREATE_FEATURE(FEATURE_GAP, BLUETOOTH_FEATURE_API_GAP);
-    ACE_CREATE_FEATURE(FEATURE_SPP, BLUETOOTH_FEATURE_API_SPP);
+       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_BLUETOOTH_SPP);
+       ACE_ADD_DEVICE_CAP(DEVICE_LIST_BLUETOOTH_SPP, DEVICE_CAP_BLUETOOTH_SPP);
 
-    ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_BLUETOOTH);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_GAP);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP, FEATURE_SPP);
+       ACE_CREATE_FEATURE(FEATURE_BLUETOOTH, BLUETOOTH_FEATURE_API);
+       ACE_CREATE_FEATURE(FEATURE_ADMIN, BLUETOOTH_FEATURE_API_ADMIN);
+       ACE_CREATE_FEATURE(FEATURE_GAP, BLUETOOTH_FEATURE_API_GAP);
+       ACE_CREATE_FEATURE(FEATURE_SPP, BLUETOOTH_FEATURE_API_SPP);
 
-    ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_GAP);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_BLUETOOTH);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_GAP);
+       ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN, FEATURE_BLUETOOTH);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN, FEATURE_ADMIN);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN, FEATURE_GAP);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN, FEATURE_SPP);
 
-    ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_BLUETOOTH);
-    ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_SPP);
+       ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_ADMIN);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, FEATURE_BLUETOOTH);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, FEATURE_ADMIN);
 
+       ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_GAP);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_BLUETOOTH);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_GAP, FEATURE_GAP);
 
-    FunctionMapping BluetoothFunctions;
+       ACE_CREATE_FEATURE_LIST(BLUETOOTH_FEATURES_BLUETOOTH_SPP);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_BLUETOOTH);
+       ACE_ADD_API_FEATURE(BLUETOOTH_FEATURES_BLUETOOTH_SPP, FEATURE_SPP);
 
-    AceFunction adapter = ACE_CREATE_FUNCTION(
-            FUNCTION_ADAPTER,
-            bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
-            BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP,
-            EMPTY_DEVICE_LIST);
 
-    BluetoothFunctions.insert(std::make_pair(
-                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_ADAPTER],
-                       adapter));
+       FunctionMapping BluetoothFunctions;
 
-       for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED; 
-               index <= BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM; index++)
-       {
-           AceFunction gapLoopFunc = ACE_CREATE_FUNCTION(
-               FUNCTION_GAP_DUMMY_FUNC_ID,
-               bluetoothExportedNames[index],
-               BLUETOOTH_FEATURES_BLUETOOTH_GAP,
-               DEVICE_LIST_BLUETOOTH_GAP);
+       AceFunction adapter = ACE_CREATE_FUNCTION(
+       FUNCTION_ADAPTER,
+       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER],
+       BLUETOOTH_FEATURES_BLUETOOTH_SPP_GAP_ADMIN,
+       EMPTY_DEVICE_LIST);
+
+       BluetoothFunctions.insert(std::make_pair(
+       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER],
+       adapter));
 
+
+       for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME; 
+               index <= BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE; index++)
+       {
+               AceFunction adminLoopFunc = 
+                       ACE_CREATE_FUNCTION(FUNCTION_ADMIN_DUMMY_FUNC_ID, bluetoothExportedNames[index], 
+                       BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, DEVICE_LIST_BLUETOOTH_ADMIN);
                BluetoothFunctions.insert(std::make_pair(
-                       bluetoothExportedNames[index],
-                       gapLoopFunc));
+                       bluetoothExportedNames[index], adminLoopFunc));
        }
 
-       for (int index = BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE; 
+       // allow getDefaultAdapter for bluetooth.admin feature
+       AceFunction adminDefaultAdapter = 
+               ACE_CREATE_FUNCTION(FUNCTION_ADMIN_DUMMY_FUNC_ID, 
+                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER],
+                       BLUETOOTH_FEATURES_BLUETOOTH_ADMIN, DEVICE_LIST_BLUETOOTH_ADMIN);
+       BluetoothFunctions.insert(
+               std::make_pair(
+                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER], 
+                       adminDefaultAdapter));
+
+
+       for (int index = BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES; 
                index <= BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE; index++)
        {
-               AceFunction sppLoopFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_SPP_DUMMY_FUNC_ID,
-                       bluetoothExportedNames[index],
-                       BLUETOOTH_FEATURES_BLUETOOTH_SPP,
-                       DEVICE_LIST_BLUETOOTH_SPP);
+               AceFunction gapLoopFunc = 
+                       ACE_CREATE_FUNCTION(FUNCTION_GAP_DUMMY_FUNC_ID, bluetoothExportedNames[index],
+                       BLUETOOTH_FEATURES_BLUETOOTH_GAP, DEVICE_LIST_BLUETOOTH_GAP);
+               BluetoothFunctions.insert(std::make_pair(
+                       bluetoothExportedNames[index], gapLoopFunc));
+       }
+
+       // allow getDefaultAdapter for bluetooth.gap feature
+       AceFunction gapDefaultAdapter = 
+               ACE_CREATE_FUNCTION(FUNCTION_GAP_DUMMY_FUNC_ID,
+                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER],
+                       BLUETOOTH_FEATURES_BLUETOOTH_GAP, DEVICE_LIST_BLUETOOTH_GAP);
+       BluetoothFunctions.insert(std::make_pair(
+               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER], 
+               gapDefaultAdapter));
+
 
+       for (int index = BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM; 
+               index <= BLUETOOTH_FUNCTION_API_SOCKET_CLOSE; index++)
+       {
+               AceFunction sppLoopFunc = 
+                       ACE_CREATE_FUNCTION(FUNCTION_SPP_DUMMY_FUNC_ID, bluetoothExportedNames[index],
+                       BLUETOOTH_FEATURES_BLUETOOTH_SPP, DEVICE_LIST_BLUETOOTH_SPP);
                BluetoothFunctions.insert(std::make_pair(
-                       bluetoothExportedNames[index],
-                       sppLoopFunc));
+                       bluetoothExportedNames[index], sppLoopFunc));
        }
 
-    return BluetoothFunctions;
+       // allow getDefaultAdapter for bluetooth.spp feature
+       AceFunction sppDefaultAdapter = 
+               ACE_CREATE_FUNCTION(FUNCTION_SPP_DUMMY_FUNC_ID,
+                       bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER],
+                       BLUETOOTH_FEATURES_BLUETOOTH_SPP, DEVICE_LIST_BLUETOOTH_SPP);
+
+       BluetoothFunctions.insert(std::make_pair(
+               bluetoothExportedNames[BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER], 
+               sppDefaultAdapter));
+
+
+       return BluetoothFunctions;
 }
 } 
 }
index d0a25f6..d13bf26 100644 (file)
@@ -24,24 +24,23 @@ namespace Tizen1_0 {
 
 typedef enum 
 {
-BLUETOOTH_FUNCTION_API_ADAPTER = 0,
+BLUETOOTH_FUNCTION_API_MANAGER_GET_DEFAULT_ADAPTER = 0,
+BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME,
 BLUETOOTH_FUNCTION_API_ADAPTER_SET_POWERED,
 BLUETOOTH_FUNCTION_API_ADAPTER_SET_VISIBLE,
-BLUETOOTH_FUNCTION_API_ADAPTER_SET_NAME,
 BLUETOOTH_FUNCTION_API_ADAPTER_DISCOVER_DEVICES,
 BLUETOOTH_FUNCTION_API_ADAPTER_STOP_DISCOVERY,
 BLUETOOTH_FUNCTION_API_ADAPTER_GET_KNOWN_DEVICES,
 BLUETOOTH_FUNCTION_API_ADAPTER_GET_DEVICE,
 BLUETOOTH_FUNCTION_API_ADPATER_CREATE_BONDING,
 BLUETOOTH_FUNCTION_API_ADPATER_DESTROY_BONDING,
+BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE,
 BLUETOOTH_FUNCTION_API_ADPATER_REGISTER_RFCOMM,
-BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER_RFCOMM,
+BLUETOOTH_FUNCTION_API_ADPATER_UNREGISTER,
 BLUETOOTH_FUNCTION_API_DEVICE_CONNECT_TO_SERVICE,
-BLUETOOTH_FUNCTION_API_SOCKET_SET_SOCKETNOTIFIER,
 BLUETOOTH_FUNCTION_API_SOCKET_WRITE_DATA,
 BLUETOOTH_FUNCTION_API_SOCKET_READ_DATA,
 BLUETOOTH_FUNCTION_API_SOCKET_CLOSE,
-BLUETOOTH_FUNCTION_API_BLUETOOTHCLASS_HAS_SERVICE
 } bluetoothFuncNames;
 
 
@@ -49,9 +48,8 @@ extern const char* bluetoothExportedNames[];
 
 DECLARE_FUNCTION_GETTER(Bluetooth);
 
-#define BLUETOOTH_CHECK_ACCESS(globalContext, functionName)                       \
+#define BLUETOOTH_CHECK_ACCESS(functionName)                       \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getBluetoothFunctionData,             \
         functionName)
 }
index 1be8a15..9db5d77 100644 (file)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 
 
 #include "JSBluetoothManager.h"
 #include "JSBluetoothAdapter.h"
 
-
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 
-
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId)
 {
        LogDebug("[Tizen\\Bluetooth ] on_widget_start_callback ("<<widgetId<<")");
-
        Try
        {
-               WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(widgetId,context,interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
        }
-       Catch(Exception)
+       Catch(Commons::Exception)
        {
-               LogError("Wrt wrapper registration failed");
+               LogError("WrtAccess initialization failed");
        }
-
 }
 
 void on_widget_stop_callback(int widgetId)
 {
        LogDebug("[Tizen\\Bluetooth] on_widget_stop_callback ("<<widgetId<<")");
-
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+       Try
+       {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+       }
+       Catch(Commons::Exception)
+       {
+               LogError("WrtAccess deinitialization failed");
+       }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index ca5e183..196f994 100755 (executable)
@@ -25,6 +25,7 @@ add_subdir(Tizen)
 add_subdir(Mediacontent)
 add_subdir(Calendar)
 add_subdir(Contact)
+add_subdir(LBS)
 add_subdir(Geocoder)
 add_subdir(Bluetooth)
 add_subdir(Application)
@@ -37,8 +38,10 @@ add_subdir(Sensors)
 add_subdir(Log)
 add_subdir(Filesystem)
 add_subdir(Alarm)
-#add_subdir(Account)
 
+#add_subdir(PowerManager)
+#add_subdir(Account)
+#add_subdir(SecureElement)
 #add_subdir(DeviceInteraction)
 #add_subdir(Accelerometer)
 #add_subdir(Orientation)
index 1d6e930..6e1d99b 100755 (executable)
@@ -5,6 +5,7 @@ set(CMAKE_INSTALL_RPATH
     ${CMAKE_INSTALL_RPATH}
     ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
     ${CMAKE_INSTALL_PREFIX}/tizen-1.0-time
+    ${CMAKE_INSTALL_PREFIX}/tizen-1.0-contact
 )
 
 set(SRCS
@@ -12,7 +13,6 @@ set(SRCS
   ${SRCS_PLATFORM_IMPLEMENTATION_CALENDAR}
   CalendarResponseDispatcher.cpp
   CalendarConverter.cpp
-  JSCalendarItem.cpp
   JSCalendarEvent.cpp
   JSCalendarTask.cpp
   JSCalendarItemProperties.cpp
@@ -22,7 +22,6 @@ set(SRCS
   JSCalendarAttendee.cpp
   JSCalendarRecurrenceRule.cpp
   JSCalendarAlarm.cpp
-  JSCalendarItemGeo.cpp
   plugin_initializer.cpp
   plugin_config.cpp
 )
@@ -37,6 +36,7 @@ target_link_libraries(${TARGET_NAME}
   ${LIBS_PLATFORM_IMPLEMENTATION_CALENDAR}
   wrt-plugins-tizen-1.0-tizen-impl
   wrt-plugins-tizen-1.0-time-impl
+  wrt-plugins-tizen-1.0-contact-impl
 )
 
 INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
index d5b4cd5..7c214e2 100755 (executable)
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/JSUtils.h>
-#include "JSCalendarItem.h"
 #include "JSCalendarEvent.h"
 #include "JSCalendarTask.h"
 #include "JSCalendarItemProperties.h"
 #include "JSCalendarEventId.h"
-#include "JSCalendarItemGeo.h"
 #include "CalendarConverter.h"
 #include "JSCalendar.h"
 #include "JSCalendarManager.h"
@@ -31,7 +29,9 @@
 #include "JSCalendarRecurrenceRule.h"
 #include "JSCalendarAlarm.h"
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
-#include "API/TimeUtil/DurationProperties.h"
+#include <API/TimeUtil/DurationProperties.h>
+#include <Tizen/Tizen/JSSimpleCoordinates.h>
+#include <Tizen/Contact/ContactConverter.h>
 
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
@@ -45,25 +45,11 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
-std::vector<std::string> CalendarConverter::m_allowedAttributes;
-
 CalendarConverter::CalendarConverter(JSContextRef context, CalendarEvent::CalendarType calendarType) : Converter(context)
 {
     LogDebug("entered");
 
     m_calendarType = calendarType;
-
-    // for WAC style search filter
-    if (m_allowedAttributes.size() == 0) {
-        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_ID);
-        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_SUMMARY);
-        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_DESCRIPTION);
-        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_LOCATION);
-        m_allowedAttributes.push_back("category");
-        m_allowedAttributes.push_back(TIZEN_CALENDAR_ITEM_STATUS);
-        m_allowedAttributes.push_back("initialStartDate");
-        m_allowedAttributes.push_back("endStartDate");
-    }
 }
 
 CalendarConverter::~CalendarConverter()
@@ -71,11 +57,6 @@ CalendarConverter::~CalendarConverter()
     LogDebug("entered");
 }
 
-JSValueRef CalendarConverter::toJSValueRefItem(const CalendarEventPtr& arg)
-{
-    return JSUtils::makeObject(m_context, JSCalendarItem::getClassRef(), arg);
-}
-
 JSValueRef CalendarConverter::toJSValueRefEvent(const CalendarEventPtr& arg)
 {
     return JSUtils::makeObject(m_context, JSCalendarEvent::getClassRef(), arg);
@@ -86,11 +67,6 @@ JSValueRef CalendarConverter::toJSValueRefTask(const CalendarEventPtr& arg)
     return JSUtils::makeObject(m_context, JSCalendarTask::getClassRef(), arg);
 }
 
-JSValueRef CalendarConverter::toJSValueRefItemArray(const CalendarEventListPtr &arg)
-{
-    return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefItem, this);
-}
-
 JSValueRef CalendarConverter::toJSValueRefEventArray(const CalendarEventListPtr &arg)
 {
     return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefEvent, this);
@@ -120,9 +96,9 @@ const
     else if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SOUND_ALARM))
         return CalendarEvent::SOUND_ALARM;
     else
-        Throw(ConversionException);
+        ThrowMsg(ConversionException, "Invalid alarm type.");
 
-    return CalendarEvent::SOUND_ALARM;
+    return CalendarEvent::UNDEFINED_ALARM_TYPE;
 }
 
 std::string CalendarConverter::toTizenValue(CalendarEvent::EventAlarmType abstractValue) const
@@ -152,13 +128,10 @@ CalendarEvent::EventStatus CalendarConverter::toEventStatus(std::string tizenVal
         return CalendarEvent::IN_PROCESS_STATUS;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS))
         return CalendarEvent::COMPLETED_STATUS;
+    else
+        ThrowMsg(ConversionException, "Invalid status type.");
 
-    // default value setting.
-    if(m_calendarType == CalendarEvent::EVENT_TYPE) {
-        return CalendarEvent::TENTATIVE_STATUS;
-    } else {
-        return CalendarEvent::NEEDS_ACTION_STATUS;
-    }
+    return CalendarEvent::UNDEFINED_STATUS;
 }
 
 std::string CalendarConverter::toTizenValue(CalendarEvent::EventStatus abstractValue)
@@ -178,7 +151,14 @@ const
     case CalendarEvent::COMPLETED_STATUS:
         return TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS;
     default:
-        break;
+        {
+            if (CalendarEvent::TASK_TYPE==m_calendarType) {
+                return TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS;
+            } else {
+                return TIZEN_CALENDAR_PROPERTY_CONFIRMED_STATUS;
+            }
+            break;
+        }
     }
 
     ThrowMsg(ConversionException, "Invalid status");
@@ -195,8 +175,10 @@ EventRecurrenceRule::EventRecurrence CalendarConverter::toRecurrenceFrequency(
         return EventRecurrenceRule::MONTHLY_RECURRENCE;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE))
         return EventRecurrenceRule::YEARLY_RECURRENCE;
+    else
+        ThrowMsg(ConversionException, "Invalid recurrence frequency type.");
 
-    return EventRecurrenceRule::NO_RECURRENCE;
+    return EventRecurrenceRule::UNDEFINED_RECURRENCE;
 }
 
 std::string CalendarConverter::toTizenValue(
@@ -228,10 +210,10 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     const ScopedJSStringRef intervalStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_INTERVAL));
     const ScopedJSStringRef untilDateStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_UNTIL_DATE));
     const ScopedJSStringRef occurrenceCountStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT));
-//    const ScopedJSStringRef daysOfTheMonthStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH));
+    //const ScopedJSStringRef daysOfTheMonthStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH));
     const ScopedJSStringRef daysOfTheWeekStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK));
-//    const ScopedJSStringRef daysOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR));
-//    const ScopedJSStringRef weeksOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR));
+    //const ScopedJSStringRef daysOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR));
+    //const ScopedJSStringRef weeksOfTheYearStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR));
     const ScopedJSStringRef setPositionStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_SET_POSITION));
     const ScopedJSStringRef exceptionsStr(JSStringCreateWithUTF8CString(TIZEN_RECURRENCE_RULE_EXCEPTIONS));
 
@@ -241,10 +223,10 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     JSValueRef intervalData = JSObjectGetProperty(m_context, arg, intervalStr.get(), NULL);
     JSValueRef untilDateData = JSObjectGetProperty(m_context, arg, untilDateStr.get(), NULL);
     JSValueRef occurrenceCountData = JSObjectGetProperty(m_context, arg, occurrenceCountStr.get(), NULL);
-//    JSValueRef daysOfTheMonthData = JSObjectGetProperty(m_context, arg, daysOfTheMonthStr.get(), NULL);
+    //JSValueRef daysOfTheMonthData = JSObjectGetProperty(m_context, arg, daysOfTheMonthStr.get(), NULL);
     JSValueRef daysOfTheWeekData = JSObjectGetProperty(m_context, arg, daysOfTheWeekStr.get(), NULL);
-//    JSValueRef daysOfTheYearData = JSObjectGetProperty(m_context, arg, daysOfTheYearStr.get(), NULL);
-//    JSValueRef weeksOfTheYearData = JSObjectGetProperty(m_context, arg, weeksOfTheYearStr.get(), NULL);
+    //JSValueRef daysOfTheYearData = JSObjectGetProperty(m_context, arg, daysOfTheYearStr.get(), NULL);
+    //JSValueRef weeksOfTheYearData = JSObjectGetProperty(m_context, arg, weeksOfTheYearStr.get(), NULL);
     JSValueRef setPositionData = JSObjectGetProperty(m_context, arg, setPositionStr.get(), NULL);
     JSValueRef exceptionsData = JSObjectGetProperty(m_context, arg, exceptionsStr.get(), NULL);
 
@@ -258,7 +240,8 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     }
     if (!JSValueIsUndefined(m_context, untilDateData)) {
         if (!JSValueIsNull(m_context, untilDateData)) {
-            result->setEndDate(toDateTimeT(untilDateData));
+            TimeUtilConverter timeUtilConverter(m_context);
+            result->setEndDate(timeUtilConverter.toTZDateTimeT(untilDateData));
         } else {
             result->setEndDate(0);
         }
@@ -266,24 +249,24 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
     if (!JSValueIsUndefined(m_context, occurrenceCountData)) {
         result->setOccurrenceCount(toLong(occurrenceCountData));
     }
-/*    if (!JSValueIsUndefined(m_context, daysOfTheMonthData)) {
+    /*if (!JSValueIsUndefined(m_context, daysOfTheMonthData)) {
         result->setDaysOfTheMonth(toVectorOfInts(daysOfTheMonthData));
     }*/
     if (!JSValueIsUndefined(m_context, daysOfTheWeekData)) {
         result->setDaysOfTheWeek(toVectorOfStrings(daysOfTheWeekData));
     }
-/*    if (!JSValueIsUndefined(m_context, daysOfTheYearData)) {
+    /*if (!JSValueIsUndefined(m_context, daysOfTheYearData)) {
         result->setDaysOfTheYear(toVectorOfInts(daysOfTheYearData));
     }
     if (!JSValueIsUndefined(m_context, weeksOfTheYearData)) {
         result->setWeeksOfTheYear(toVectorOfInts(weeksOfTheYearData));
     }*/
     if (!JSValueIsUndefined(m_context, setPositionData)) {
-        Throw(UnsupportedException);
+        ThrowMsg(UnsupportedException, "setPositions not supported yet.");
         //result->setSetPosition(toBool(setPositionData));
     }
     if (!JSValueIsUndefined(m_context, exceptionsData)) {
-        result->setExceptions(toVectorOfTimeT(exceptionsData));
+        result->setExceptions(toVectorOfTimeTFromTZDate(exceptionsData));
     }
 
     return result;
@@ -298,8 +281,10 @@ const
         return CalendarEvent::PRIVATE_VISIBILITY;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CONFIDENTIAL_VISIBILITY))
         return CalendarEvent::CONFIDENTIAL_VISIBILITY;
+    else
+        ThrowMsg(ConversionException, "Invalid visibility type.");
 
-    return CalendarEvent::PUBLIC_VISIBILITY;
+    return CalendarEvent::UNDEFINED_VISIBILITY;
 }
 
 std::string CalendarConverter::toTizenValue(
@@ -330,8 +315,10 @@ const
         return CalendarEvent::FREE_FB;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_BUSY_TENTATIVE))
         return CalendarEvent::BUSY_TENTATIVE_FB;
-  
-    return CalendarEvent::BUSY_FB;
+    else
+        ThrowMsg(ConversionException, "Invalid availability type.");
+
+    return CalendarEvent::UNDEFINED_AVAILABILITY;
 }
 
 std::string CalendarConverter::toTizenValue(
@@ -364,8 +351,10 @@ const
         return EventAttendee::NON_PARTICIPANT_ROLE;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_CHAIR_ROLE))
         return EventAttendee::CHAIR_ROLE;
+    else
+        ThrowMsg(ConversionException, "Invalid attendee role type.");
 
-    return EventAttendee::REQ_PARTICIPANT_ROLE;
+    return EventAttendee::UNDEFINED_ATTENDEE_ROLE;
 }
 
 std::string CalendarConverter::toTizenValue(
@@ -403,8 +392,10 @@ const
         return EventAttendee::COMPLETED_AT_STATUS;
     else if (!tizenValue.compare(TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS))
         return EventAttendee::IN_PROCESS_AT_STATUS;
+    else
+        ThrowMsg(ConversionException, "Invalid attendee status type.");
 
-    return EventAttendee::PENDING_AT_STATUS;
+    return EventAttendee::UNDEFINED_ATTENDEE_STATUS;
 }
 
 std::string CalendarConverter::toTizenValue(
@@ -475,7 +466,7 @@ JSValueRef CalendarConverter::toFunctionOrNull(const JSValueRef& arg)
         return arg;
     } else if (!JSValueIsNull(m_context,
                               arg) && !JSValueIsUndefined(m_context, arg)) {
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
+        ThrowMsg(ConversionException, "Not a function nor JS null.");
     }
     return NULL;
 }
@@ -484,181 +475,8 @@ JSValueRef CalendarConverter::toFunction(const JSValueRef& arg)
 {
     if (Validator(m_context).isCallback(arg)) {
         return arg;
-    } else if (JSValueIsNull(m_context,
-                             arg) || JSValueIsUndefined(m_context, arg)) {
-        ThrowMsg(ConversionException, "JS null passed as function.");
-    }
-    ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-}
-
-void CalendarConverter::toEventFilterConvertId(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef idStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_ID));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, idStr.get())) {
-        LogDebug("converting id");
-        JSValueRef value = JSObjectGetProperty(m_context, filterObj,
-                                               idStr.get(), NULL);
-        result->setIdFilter(toString(value));
-    }
-}
-
-void CalendarConverter::toEventFilterConvertSummary(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef summaryStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_SUMMARY));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, summaryStr.get())) {
-        LogDebug("converting summary");
-        JSValueRef value = JSObjectGetProperty(m_context,
-                                               filterObj,
-                                               summaryStr.get(),
-                                               NULL);
-        result->setSubjectFilter(toString(value));
-    }
-}
-
-void CalendarConverter::toEventFilterConvertDescription(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(
-                                               TIZEN_CALENDAR_ITEM_DESCRIPTION));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, descriptionStr.get())) {
-        LogDebug("converting description");
-        JSValueRef value = JSObjectGetProperty(m_context,
-                                               filterObj,
-                                               descriptionStr.get(),
-                                               NULL);
-        result->setDescriptionFilter(toString(value));
     }
-}
-
-void CalendarConverter::toEventFilterConvertLocation(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString(
-                                            TIZEN_CALENDAR_ITEM_LOCATION));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, locationStr.get())) {
-        LogDebug("converting location");
-        JSValueRef value = JSObjectGetProperty(m_context,
-                                               filterObj,
-                                               locationStr.get(),
-                                               NULL);
-        result->setLocationFilter(toString(value));
-    }
-}
-
-void CalendarConverter::toEventFilterConvertCategory(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef locationStr(JSStringCreateWithUTF8CString(
-                                            "category"));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, locationStr.get())) {
-        LogDebug("converting category");
-        JSValueRef value = JSObjectGetProperty(m_context,
-                                               filterObj,
-                                               locationStr.get(),
-                                               NULL);
-        result->setCategoryFilter(toString(value));
-    }
-}
-
-void CalendarConverter::toEventFilterConvertStatus(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef statusStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_STATUS));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, statusStr.get())) {
-        LogDebug("converting status");
-        JSValueRef value = JSObjectGetProperty(m_context,
-                                               filterObj,
-                                               statusStr.get(),
-                                               NULL);
-        std::vector<std::string> statuses = toVectorOfStrings(value);
-        for (std::size_t i = 0; i < statuses.size(); ++i) {
-            CalendarEvent::EventStatus status(toEventStatus(statuses[i]));
-            if (status == CalendarEvent::INVALID_STATUS) {
-                ThrowMsg(InvalidArgumentException,
-                         "Status filter has wrong value");
-            }
-            result->addStatusFilter(status);
-        }
-    }
-}
-
-void CalendarConverter::toEventFilterConvertStartTime(
-        const EventFilterPtr &result,
-        const JSValueRef &filters)
-{
-    const ScopedJSStringRef initialStartDateStr(JSStringCreateWithUTF8CString(
-                                                    "initialStartDate"));
-    const ScopedJSStringRef endStartDateStr(JSStringCreateWithUTF8CString(
-                                                "endStartDate"));
-    JSObjectRef filterObj = toJSObjectRef(filters);
-    if (JSObjectHasProperty(m_context, filterObj, initialStartDateStr.get()) ||
-        JSObjectHasProperty(m_context, filterObj, endStartDateStr.get())) {
-        LogDebug("converting startTime");
-        JSValueRef valueStart = JSObjectGetProperty(m_context,
-                                                    filterObj,
-                                                    initialStartDateStr.get(),
-                                                    NULL);
-        JSValueRef valueEnd = JSObjectGetProperty(m_context,
-                                                  filterObj,
-                                                  endStartDateStr.get(),
-                                                  NULL);
-        //no filters
-        if ((JSValueIsNull(m_context,
-                           valueStart) ||
-             JSValueIsUndefined(m_context, valueStart)) &&
-            (JSValueIsNull(m_context,
-                           valueEnd) ||
-             JSValueIsUndefined(m_context, valueEnd))) {
-            return;
-        }
-        //start
-        if (!JSValueIsNull(m_context, valueStart) &&
-            !JSValueIsUndefined(m_context, valueStart)) {
-            result->setStartTimeMinFilter(toDateTimeT(valueStart));
-        }
-        //end
-        if (!JSValueIsNull(m_context, valueEnd) &&
-            !JSValueIsUndefined(m_context, valueEnd)) {
-            result->setStartTimeMaxFilter(toDateTimeT(valueEnd));
-        }
-    }
-}
-
-EventFilterPtr CalendarConverter::toEventFilter(const JSValueRef &filters)
-{
-    LogDebug("entered");
-    EventFilterPtr result(new EventFilter());
-    Validator validator(m_context);
-    if (!JSValueIsObject(m_context, filters)) {
-        LogError("Wrong filter parameter");
-        Throw(InvalidArgumentException);
-    }
-    if (!validator.checkArrayKeys(m_allowedAttributes, filters)) {
-        LogError("Wrong filter's attribue");
-        Throw(ConversionException);
-    }
-    toEventFilterConvertId(result, filters);
-    toEventFilterConvertSummary(result, filters);
-    toEventFilterConvertDescription(result, filters);
-    toEventFilterConvertLocation(result, filters);
-    toEventFilterConvertCategory(result, filters);
-    toEventFilterConvertStatus(result, filters);
-    toEventFilterConvertStartTime(result, filters);
-    return result;
+    ThrowMsg(ConversionException, "Not a function.");
 }
 
 CategoryListPtr CalendarConverter::toCategories(JSValueRef categories)
@@ -725,7 +543,9 @@ EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee)
         result->setDelegateURI(toString(delegateURIData));
     }
     if (!JSValueIsUndefined(m_context, contactRefData)) {
-        result->setContactId(toString(contactRefData));
+        TizenApis::Tizen1_0::Contact::ContactConverter contactConverter(m_context);
+        result->setContactId(contactConverter.toContactRef(contactRefData)->getContactId());
+        result->setAddressBookId(contactConverter.toContactRef(contactRefData)->getAddressBookId());
     }
 
     return result;
@@ -856,6 +676,7 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     const ScopedJSStringRef availabilityStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_AVAILABILITY));
     const ScopedJSStringRef recurrenceRuleStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_RECURRENCE_RULE));
     const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ITEM_PRIORITY));
+    const ScopedJSStringRef endDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_END_DATE));
     const ScopedJSStringRef dueDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_DUE_DATE));
     const ScopedJSStringRef completedDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_COMPLETED_DATE));
     const ScopedJSStringRef progressStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_TASK_PROGRESS));
@@ -878,6 +699,7 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     JSValueRef availabilityData = JSObjectGetProperty(m_context, arg, availabilityStr.get(), NULL);
     JSValueRef recurrenceRuleData = JSObjectGetProperty(m_context, arg, recurrenceRuleStr.get(), NULL);
     JSValueRef priorityData = JSObjectGetProperty(m_context, arg, priorityStr.get(), NULL);
+    JSValueRef endDateData = JSObjectGetProperty(m_context, arg, endDateStr.get(), NULL);
     JSValueRef dueDateData = JSObjectGetProperty(m_context, arg, dueDateStr.get(), NULL);
     JSValueRef completedDateData = JSObjectGetProperty(m_context, arg, completedDateStr.get(), NULL);
     JSValueRef progressData = JSObjectGetProperty(m_context, arg, progressStr.get(), NULL);
@@ -987,7 +809,10 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setAttendees(attendees);
     }
     if (!JSValueIsUndefined(m_context, geolocationData)) {
-        result->setGeolocation(toGeolocation(geolocationData));
+        TizenApis::Api::Tizen::SimpleCoordinatesPtr geoLocation =
+            TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getSimpleCoordinates(m_context, geolocationData);
+        result->setLatitude(geoLocation->getLatitude());
+        result->setLongitude(geoLocation->getLongitude());
     }
     if (!JSValueIsUndefined(m_context, visibilityData)) {
         result->setVisibility(toEventVisibility(toString(visibilityData)));
@@ -1001,6 +826,9 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
     if (!JSValueIsUndefined(m_context, priorityData)) {
         result->setPriority(toTaskPriority(toString(priorityData)));
     }
+    if (!JSValueIsUndefined(m_context, endDateData)) {
+        result->setEndTime(timeUtilConverter.toTZDateTimeT(endDateData));
+    }
     if (!JSValueIsUndefined(m_context, dueDateData)) {
         result->setEndTime(timeUtilConverter.toTZDateTimeT(dueDateData));
     }
@@ -1025,7 +853,7 @@ CalendarEventListPtr CalendarConverter::toVectorOfEvents(JSValueRef events)
     for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); i++) {
         JSValueRef element = JSGetArrayElement(m_context, objArg, i);
         JSObjectRef arg = JSValueToObject(m_context, element, NULL);
-        resultVector.push_back(JSCalendarItem::getPrivateObject(arg));
+        resultVector.push_back(JSCalendarEvent::getPrivateObject(arg));
     }
 
     *result = resultVector;
@@ -1052,8 +880,8 @@ EventIdPtr CalendarConverter::toEventId(JSValueRef eventId)
 {
     LogDebug("entered");
     EventIdPtr result(new EventId());
-    const ScopedJSStringRef uidStr(JSStringCreateWithUTF8CString("uid"));
-    const ScopedJSStringRef recurrenceIdStr(JSStringCreateWithUTF8CString("recurrenceId"));
+    const ScopedJSStringRef uidStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_ID_UID));
+    const ScopedJSStringRef recurrenceIdStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_EVENT_ID_RECURRENCEID));
 
     JSObjectRef arg = toJSObjectRef(eventId);
 
@@ -1064,30 +892,7 @@ EventIdPtr CalendarConverter::toEventId(JSValueRef eventId)
         result->setUId(toString(uidData));
     }
     if (!JSValueIsUndefined(m_context, recurrenceIdData)) {
-        TimeUtilConverter timeUtilConverter(m_context);
-        result->setRecurrenceId(timeUtilConverter.toTZDateTimeT(recurrenceIdData));
-   }
-
-    return result;
-}
-
-CalendarItemGeoPtr CalendarConverter::toGeolocation(JSValueRef geoInfo)
-{
-    LogDebug("entered");
-    CalendarItemGeoPtr result(new CalendarItemGeo());
-    const ScopedJSStringRef latStr(JSStringCreateWithUTF8CString("latitude"));
-    const ScopedJSStringRef lonStr(JSStringCreateWithUTF8CString("longitude"));
-
-    JSObjectRef arg = toJSObjectRef(geoInfo);
-
-    JSValueRef latData = JSObjectGetProperty(m_context, arg, latStr.get(), NULL);
-    JSValueRef lonData = JSObjectGetProperty(m_context, arg, lonStr.get(), NULL);
-
-    if (!JSValueIsUndefined(m_context, latData)) {
-        result->setLatitude(toDouble(latData));
-    }
-    if (!JSValueIsUndefined(m_context, lonData)) {
-        result->setLongitude(toDouble(lonData));
+        result->setRecurrenceId(toString(recurrenceIdData));
    }
 
     return result;
@@ -1152,9 +957,9 @@ CalendarEvent::TaskPriority CalendarConverter::toTaskPriority(std::string priori
     else if (!priority.compare(TIZEN_CALENDAR_PROPERTY_LOW_PRIORITY))
         return CalendarEvent::LOW_PRIORITY;
     else
-        Throw(ConversionException);
+        ThrowMsg(ConversionException, "Invalid priority type.");
 
-    return CalendarEvent::LOW_PRIORITY;
+    return CalendarEvent::UNDEFINED_PRIORITY;
 }
 
 CalendarEvent::CalendarType CalendarConverter::toCalendarType(std::string type) const
@@ -1164,9 +969,9 @@ CalendarEvent::CalendarType CalendarConverter::toCalendarType(std::string type)
     else if (!type.compare(TIZEN_CALENDAR_PROPERTY_TYPE_TASK))
         return CalendarEvent::TASK_TYPE;
     else
-        Throw(ConversionException);
+        ThrowMsg(ConversionException, "Invalid calendar type.");
 
-    return CalendarEvent::EVENT_TYPE;
+    return CalendarEvent::UNDEFINED_TYPE;
 }
 
 CalendarEvent::VObjectFormat CalendarConverter::toVObjectFormat(std::string format) const
@@ -1175,8 +980,10 @@ CalendarEvent::VObjectFormat CalendarConverter::toVObjectFormat(std::string form
         return CalendarEvent::ICALENDAR_20;
     else if (!format.compare(TIZEN_CALENDAR_PROPERTY_VCALENDAR_10_FORMAT))
         return CalendarEvent::VCALENDAR_10;
+    else
+        ThrowMsg(ConversionException, "Invalid format type.");
 
-    return CalendarEvent::ICALENDAR_20;
+    return CalendarEvent::UNDEFINED_FORMAT;
 }
 
 }
index 741dcd9..bc193bf 100755 (executable)
 
 #include <vector>
 #include <string>
-#include <API/Calendar/EventFilter.h>
 #include <API/Calendar/ICalendar.h>
 #include <API/Calendar/EventAttendee.h>
 #include <API/Calendar/EventAlarm.h>
-#include <API/Calendar/CalendarItemGeo.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 
@@ -39,7 +37,7 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
   public:
     explicit CalendarConverter(JSContextRef context, TizenApis::Api::Calendar::CalendarEvent::CalendarType calendarType=TizenApis::Api::Calendar::CalendarEvent::EVENT_TYPE);
     virtual ~CalendarConverter();
-    TizenApis::Api::Calendar::EventFilterPtr toEventFilter(const JSValueRef &filters);
+
     TizenApis::Api::Calendar::CalendarEventPtr toEvent(const JSValueRef event);
     TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEvents(JSValueRef events);
     TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
@@ -69,10 +67,8 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     std::string toTizenValue(TizenApis::Api::Calendar::EventAttendee::EventAttendeeType abstractValue) const;
     std::string toTizenValue(TizenApis::Api::Calendar::CalendarEvent::TaskPriority abstractValue) const;
 
-    JSValueRef toJSValueRefItem(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
     JSValueRef toJSValueRefEvent(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
     JSValueRef toJSValueRefTask(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
-    JSValueRef toJSValueRefItemArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
     JSValueRef toJSValueRefEventArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
     JSValueRef toJSValueRefTaskArray(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
     JSValueRef toJSValueRefCalendar(const TizenApis::Api::Calendar::ICalendarPtr& arg);
@@ -83,7 +79,6 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::EventAlarmListPtr toVectorOfEventAlarmsFromReference(JSValueRef alarms);
     TizenApis::Api::Calendar::EventIdPtr toEventId(JSValueRef eventId);
     TizenApis::Api::Calendar::EventIdListPtr toVectorOfEventIds(JSValueRef eventIds);
-    TizenApis::Api::Calendar::CalendarItemGeoPtr toGeolocation(JSValueRef geoInfo);
     std::vector<time_t> toVectorOfTimeTFromTZDate(JSValueRef dates);
     TizenApis::Api::Calendar::CalendarEvent::TaskPriority toTaskPriority(std::string priority) const;
        TizenApis::Api::Calendar::CalendarEvent::CalendarType toCalendarType(std::string type) const;
@@ -101,27 +96,9 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     JSValueRef toFunction(const JSValueRef& arg);
 
   private:
-    void toEventFilterConvertId(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertSummary(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertDescription(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertLocation(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertCategory(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertStatus(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-    void toEventFilterConvertStartTime(const TizenApis::Api::Calendar::EventFilterPtr &result,
-            const JSValueRef &filters);
-
-    static std::vector<std::string> m_allowedAttributes;
     TizenApis::Api::Calendar::CalendarEvent::CalendarType m_calendarType;
 };
 
-typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<CalendarConverter> CalendarConverterFactory;
-
 }
 }
 }
index cbe90b5..49d24e9 100755 (executable)
@@ -21,7 +21,6 @@
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include "CalendarConverter.h"
-#include "JSCalendarItem.h"
 #include "JSCalendarEventId.h"
 #include "CalendarMultiCallback.h"
 #include <API/Calendar/EventId.h>
@@ -47,9 +46,6 @@ CalendarResponseDispatcher::CalendarResponseDispatcher() :
     CalendarEventsEventAnswerReceiverUpdates(ThreadEnum::NULL_THREAD),
     CalendarEventsEventAnswerReceiverFind(ThreadEnum::NULL_THREAD),
     CalendarEventsEventAnswerReceiverExpand(ThreadEnum::NULL_THREAD),
-    OnAddEventsChangedListener(ThreadEnum::NULL_THREAD),
-    OnUpdateEventsChangedListener(ThreadEnum::NULL_THREAD),
-    OnDeleteEventsChangedListener(ThreadEnum::NULL_THREAD),
     OnEventsChangedListener(ThreadEnum::NULL_THREAD)
 {
     LogDebug("entered");
@@ -73,11 +69,10 @@ void CalendarResponseDispatcher::OnAnswerReceived(
     Try
     {
         if (event->getResult()) {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(cbm->getContext());
+            CalendarConverter converter(cbm->getContext());
             const std::vector<ICalendarPtr> &results = event->getCalendars();
             LogDebug("found calendars: " << results.size());
-            JSValueRef result = converter->toJSValueRef(results);
+            JSValueRef result = converter.toJSValueRef(results);
             cbm->callOnSuccess(result);
             return;
         }
@@ -104,14 +99,13 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventAddEventsPtr &even
         }
         if (event->getResult()) {
             LogDebug("result success");
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(cbm->getContext());
+            CalendarConverter converter(cbm->getContext());
 
             JSValueRef result;
             if (CalendarEvent::TASK_TYPE==event->getCalendarType()) {
-                result = converter->toJSValueRefTaskArray(event->getEvents());
+                result = converter.toJSValueRefTaskArray(event->getEvents());
             } else {
-                result = converter->toJSValueRefEventArray(event->getEvents());
+                result = converter.toJSValueRefEventArray(event->getEvents());
             }
 
             cbm->callOnSuccess(result);
@@ -128,44 +122,6 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventAddEventsPtr &even
     cbm->callOnError(errorObject);
 }
 
-void CalendarResponseDispatcher::onAnswerReceived(const OnAddEventsChangedPtr& event)
-{
-    LogDebug("entered");
-    CalendarEventsCallbackPrivateDataPtr multiCallbacks =
-        DPL::StaticPointerCast<CalendarEventsCallbackPrivateData>(event->getPrivateData());
-    JSContextRef context = multiCallbacks->getOnEvent()->getContext();
-
-    switch (event->getStatus())
-    {
-        case OnAddEventsChanged::EVENT_ADD_SUCCESS:
-        {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(context);
-            multiCallbacks->getOnEvent()->callOnSuccess(converter->toJSValueRefItem(event->getEvent()));
-            break;
-        }
-        case OnAddEventsChanged::EVENT_ADD_FAIL:
-        {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(context);
-            JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            JSValueRef eventObject = converter->toJSValueRefItem(event->getEvent());
-            JSValueRef obj[] = {errorObject, eventObject};
-            multiCallbacks->getOnEvent()->callOnError(obj, 2);
-            break;
-        }
-        default:
-        {
-            LogDebug("Invalid status!");
-            JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            multiCallbacks->getOnEvent()->callOnError(errorObject);
-            break;
-        }
-    }
-}
-
 void CalendarResponseDispatcher::OnAnswerReceived(const IEventUpdateEventsPtr &event)
 {
     JSCallbackManagerPtr cbm =
@@ -183,44 +139,6 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventUpdateEventsPtr &e
     }
 }
 
-void CalendarResponseDispatcher::onAnswerReceived(const OnUpdateEventsChangedPtr& event)
-{
-    LogDebug("entered");
-    CalendarEventsCallbackPrivateDataPtr multiCallbacks =
-        DPL::StaticPointerCast<CalendarEventsCallbackPrivateData>(event->getPrivateData());
-    JSContextRef context = multiCallbacks->getOnEvent()->getContext();
-
-    switch (event->getStatus())
-    {
-        case OnUpdateEventsChanged::EVENT_UPDATE_SUCCESS:
-        {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(context);
-            multiCallbacks->getOnEvent()->callOnSuccess(converter->toJSValueRefItem(event->getEvent()));
-            break;
-        }
-        case OnUpdateEventsChanged::EVENT_UPDATE_FAIL:
-        {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(context);
-            JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            JSValueRef eventObject = converter->toJSValueRefItem(event->getEvent());
-            JSValueRef obj[] = {errorObject, eventObject};
-            multiCallbacks->getOnEvent()->callOnError(obj, 2);
-            break;
-        }
-        default:
-        {
-            LogDebug("Invalid status!");
-            JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            multiCallbacks->getOnEvent()->callOnError(errorObject);
-            break;
-        }
-    }
-}
-
 void CalendarResponseDispatcher::OnAnswerReceived(const IEventDeleteEventsPtr &event)
 {
     LogDebug("entered");
@@ -246,51 +164,9 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventDeleteEventsPtr &e
     }
 }
 
-void CalendarResponseDispatcher::onAnswerReceived(const OnDeleteEventsChangedPtr& event)
-{
-    LogDebug("entered");
-    CalendarEventsCallbackPrivateDataPtr multiCallbacks =
-        DPL::StaticPointerCast<CalendarEventsCallbackPrivateData>(event->getPrivateData());
-    JSContextRef context = multiCallbacks->getOnEvent()->getContext();
-
-    switch (event->getStatus())
-    {
-        case OnDeleteEventsChanged::EVENT_DELETE_SUCCESS:
-        {
-            multiCallbacks->getOnEvent()->callOnSuccess(
-                JSCalendarEventId::createJSCalendarEventId(context, event->getEventId()));
-            break;
-        }
-        case OnDeleteEventsChanged::EVENT_DELETE_FAIL:
-        {
-            JSValueRef errorObject;
-            if (event->getExceptionCode() == ExceptionCodes::NotFoundException) {
-                
-                errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                        context, TizenApis::Commons::JSTizenException::NOT_FOUND_ERROR);
-            } else {
-                errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                        context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            }
-
-            JSValueRef eventObject = JSCalendarEventId::createJSCalendarEventId(context, event->getEventId());
-            JSValueRef obj[] = {errorObject, eventObject};
-            multiCallbacks->getOnEvent()->callOnError(obj, 2);
-            break;
-        }
-        default:
-        {
-            LogDebug("Invalid status!");
-            JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-                    context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-            multiCallbacks->getOnEvent()->callOnError(errorObject);
-            break;
-        }
-    }
-}
-
 void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &event)
 {
+    LogDebug("entered");
     JSCallbackManagerPtr cbm =
         DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
     if (!cbm) {
@@ -300,14 +176,13 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventFindEventsPtr &eve
     Try
     {
         if (event->getResult()) {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(cbm->getContext());
+            CalendarConverter converter(cbm->getContext());
 
             JSValueRef result;
             if (CalendarEvent::TASK_TYPE==event->getCalendarType()) {
-                result = converter->toJSValueRefTaskArray(event->getEvents());
+                result = converter.toJSValueRefTaskArray(event->getEvents());
             } else {
-                result = converter->toJSValueRefEventArray(event->getEvents());
+                result = converter.toJSValueRefEventArray(event->getEvents());
             }
             cbm->callOnSuccess(result);
             return;
@@ -348,9 +223,8 @@ void CalendarResponseDispatcher::OnAnswerReceived(const IEventExpandEventRecurre
             return;
         }
         if (event->getResult()) {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(cbm->getContext());
-            cbm->callOnSuccess(converter->toJSValueRefEventArray(event->getExpandedEventList()));
+            CalendarConverter converter(cbm->getContext());
+            cbm->callOnSuccess(converter.toJSValueRefEventArray(event->getExpandedEventList()));
             return;
         } else {
             JSValueRef errorObject;
@@ -383,7 +257,7 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even
         DPL::StaticPointerCast<CalendarChangeCallbackPrivateData>(event->getPrivateData());
     JSContextRef context = multiCallbacks->getOnAdded()->getContext();
 
-    CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+    CalendarConverter converter(context);
     JSValueRef result;
 
     Try
@@ -393,9 +267,9 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even
             case OnEventsChanged::ON_ADD:
             {
                 if (CalendarEvent::TASK_TYPE==event->getCalendarType()) {
-                    result = converter->toJSValueRefTaskArray(event->getEventList());
+                    result = converter.toJSValueRefTaskArray(event->getEventList());
                 } else {
-                    result = converter->toJSValueRefEventArray(event->getEventList());
+                    result = converter.toJSValueRefEventArray(event->getEventList());
                 }
 
                 multiCallbacks->getOnAdded()->callOnSuccess(result);
@@ -404,9 +278,9 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even
             case OnEventsChanged::ON_UPDATE:
             {
                 if (CalendarEvent::TASK_TYPE==event->getCalendarType()) {
-                    result = converter->toJSValueRefTaskArray(event->getEventList());
+                    result = converter.toJSValueRefTaskArray(event->getEventList());
                 } else {
-                    result = converter->toJSValueRefEventArray(event->getEventList());
+                    result = converter.toJSValueRefEventArray(event->getEventList());
                 }
                 multiCallbacks->getOnUpdated()->callOnSuccess(result);
                 break;
@@ -423,7 +297,10 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even
                 for (std::size_t i = 0; i < eventList->size(); i++) {
                     EventIdPtr eventId( new EventId() );
                     eventId->setUId(eventList->at(i)->getUId());
-                    eventId->setRecurrenceId(eventList->at(i)->getRecurrenceId());
+                    std::stringstream ss;
+                    std::time_t rid = eventList->at(i)->getRecurrenceId();
+                    ss<<rid;
+                    eventId->setRecurrenceId(ss.str());
                     JSValueRef tmpVal =JSCalendarEventId::createJSCalendarEventId(context, eventId);
                     if (!JSSetArrayElement(context, jsResult, i, tmpVal)) {
                         ThrowMsg(ConversionException, "Could not create js array element");
index aac2267..8e66ef3 100755 (executable)
@@ -26,9 +26,6 @@
 #include <API/Calendar/IEventFindEvents.h>
 #include <API/Calendar/IEventUpdateEvents.h>
 #include <API/Calendar/IEventExpandEventRecurrence.h>
-#include <API/Calendar/OnAddEventsChanged.h>
-#include <API/Calendar/OnUpdateEventsChanged.h>
-#include <API/Calendar/OnDeleteEventsChanged.h>
 #include <API/Calendar/OnEventsChanged.h>
 
 namespace TizenApis {
@@ -47,12 +44,6 @@ typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Calendar::IE
 CalendarEventsEventAnswerReceiverFind;
 typedef WrtDeviceApis::Commons::EventAnswerReceiver<TizenApis::Api::Calendar::IEventExpandEventRecurrence>
 CalendarEventsEventAnswerReceiverExpand;
-typedef WrtDeviceApis::Commons::EventListener<TizenApis::Api::Calendar::OnAddEventsChanged>
-OnAddEventsChangedListener;
-typedef WrtDeviceApis::Commons::EventListener<TizenApis::Api::Calendar::OnUpdateEventsChanged>
-OnUpdateEventsChangedListener;
-typedef WrtDeviceApis::Commons::EventListener<TizenApis::Api::Calendar::OnDeleteEventsChanged>
-OnDeleteEventsChangedListener;
 typedef WrtDeviceApis::Commons::EventListener<TizenApis::Api::Calendar::OnEventsChanged>
 OnEventsChangedListener;
 
@@ -63,16 +54,10 @@ class CalendarResponseDispatcher :
     public CalendarEventsEventAnswerReceiverUpdates,
     public CalendarEventsEventAnswerReceiverFind,
     public CalendarEventsEventAnswerReceiverExpand,
-    public OnAddEventsChangedListener,
-    public OnUpdateEventsChangedListener,
-    public OnDeleteEventsChangedListener,
     public OnEventsChangedListener
 {
   public:
     static CalendarResponseDispatcher& getInstance();
-    void onAnswerReceived(const TizenApis::Api::Calendar::OnAddEventsChangedPtr& event);
-    void onAnswerReceived(const TizenApis::Api::Calendar::OnUpdateEventsChangedPtr& event);
-    void onAnswerReceived(const TizenApis::Api::Calendar::OnDeleteEventsChangedPtr& event);
     void onAnswerReceived(const TizenApis::Api::Calendar::OnEventsChangedPtr& event);
   private:
     CalendarResponseDispatcher();
index 5bdb7b0..738fbcd 100755 (executable)
@@ -35,7 +35,6 @@
 #include "JSCalendarManager.h"
 #include "CalendarConverter.h"
 #include "JSCalendar.h"
-#include "JSCalendarItem.h"
 #include "JSCalendarEvent.h"
 #include "JSCalendarTask.h"
 #include "JSCalendarItemProperties.h"
@@ -49,22 +48,6 @@ using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Commons;
 
-namespace {
-/**
- * @throw InvalidArgumentException If not a callback nor JS null nor JS undefined.
- */
-JSValueRef getFunctionOrNull(JSContextRef ctx,
-        JSValueRef arg)
-{
-    if (Validator(ctx).isCallback(arg)) {
-        return arg;
-    } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-}
-
 #define TIZEN_CALENDAR_ATTRIBUTENAME "Calendar"
 
 namespace TizenApis {
@@ -94,7 +77,7 @@ JSClassDefinition JSCalendar::m_classInfo = {
 JSStaticValue JSCalendar::m_property[] = {
     { TIZEN_CALENDAR_PROPERTY_NAME, JSCalendar::getPropertyName,
       NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID, JSCalendar::getPropertyAccountId,
+    { TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID, JSCalendar::getPropertyAccountServiceId,
       NULL, kJSPropertyAttributeReadOnly },
     { TIZEN_CALENDAR_PROPERTY_ID, JSCalendar::getPropertyId,
       NULL, kJSPropertyAttributeReadOnly },
@@ -109,7 +92,6 @@ JSStaticFunction JSCalendar::m_function[] = {
     { CALENDAR_FUNCTION_API_REMOVE, remove, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_REMOVE_BATCH, removeBatch, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_FIND, find, kJSPropertyAttributeNone },
-    //{ "convertFromString", convertFromString, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER, addChangeListener, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER, removeChangeListener, kJSPropertyAttributeNone },
     { CALENDAR_FUNCTION_API_GET, get, kJSPropertyAttributeNone },
@@ -119,32 +101,28 @@ JSStaticFunction JSCalendar::m_function[] = {
 
 JSClassRef JSCalendar::m_jsClassRef = JSClassCreate(JSCalendar::getClassInfo());
 
-void JSCalendar::initialize(JSContextRef context,
-        JSObjectRef object)
+void JSCalendar::initialize(JSContextRef context, JSObjectRef object)
 {
-    LogDebug("entered");
-    CalendarPrivObject *priv =
-        static_cast<CalendarPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        LogWarning("create default instance");
-        ICalendarPtr calendar =
-            Api::Calendar::CalendarFactory::getInstance().createCalendarObject();
-        priv = new CalendarPrivObject(context, calendar);
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar private object.");
+        ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject();
+        CalendarPrivObject *priv = new CalendarPrivObject(context, calendar);
         if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
             delete priv;
         }
     } else {
-        //can be set by JSMakeObject inside getCalendars method
-        LogDebug("private object alrerady exists");
+        LogDebug("Private object already set.");
     }
 }
 
 void JSCalendar::finalize(JSObjectRef object)
 {
     LogDebug("entered");
-    CalendarPrivObject *priv =
-        static_cast<CalendarPrivObject*>(JSObjectGetPrivate(object));
-    delete priv;
+    CalendarPrivObject *priv = static_cast<CalendarPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 const JSClassRef JSCalendar::getClassRef()
@@ -171,32 +149,30 @@ JSValueRef JSCalendar::add(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
-
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+        ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
+
+        if (argumentCount<1) {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(privateObject->getContext());
+        if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEvent::getClassRef()) &&
+        !JSValueIsObjectOfClass(context, arguments[0], JSCalendarTask::getClassRef())) {
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
+        }
 
         JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-        CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
-        if (!JSCalendarItem::validate(context, arg, exception)) {
-            ThrowMsg(InvalidArgumentException, "Wrong parameter value.");
-        }
+        CalendarEventPtr event = JSCalendarEvent::getPrivateObject(arg);
         if (!event) {
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
@@ -209,7 +185,7 @@ JSValueRef JSCalendar::add(JSContextRef context,
         if (dplEvent->getResult()) {
             return JSValueMakeUndefined(context);
         } else {
-            ThrowMsg(UnknownException, "Adding failed by unkown reason.");
+            ThrowMsg(UnknownException, "Adding failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -247,53 +223,47 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    JSCallbackManagerPtr cbm(NULL);
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD_BATCH);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_BATCH);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
+        }
+
         ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
 
-        if (argumentCount>3 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
+        JSContextRef globalContext = privateObject->getContext();
+        CalendarConverter converter(context);
 
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+        if (argumentCount<1) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
+        }
 
         CalendarEventListPtr events;
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+        if (!JSIsArrayValue(context, arguments[0])) {
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
-        events = converter->toVectorOfEvents(arguments[0]);
+        events = converter.toVectorOfEvents(arguments[0]);
         if (!events) {
-            LogError("Failed to create events.");
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
+            ThrowMsg(ConversionException, "First parameter conversion failed.");
         }
 
-        JSValueRef onError = NULL;
-        if (argumentCount > 2) {
-            onError = getFunctionOrNull(context, arguments[2]);
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+        if (argumentCount>=2) {
+            cbm->setOnSuccess(converter.toFunctionOrNull(arguments[1]));
         }
-        JSContextRef globalContext = privateObject->getContext();
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-        CalendarEventsSuccessCallback result;
-        if (argumentCount > 1) {
-            result.onSuccess = getFunctionOrNull(context, arguments[1]);
+        if (argumentCount>=3) {
+            cbm->setOnError(converter.toFunctionOrNull(arguments[2]));
         }
-        cbm->setOnSuccess(result.onSuccess);
 
-        LogDebug("Proceed the event to the platform.");
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
 
-        //CalendarEventsCallbackPrivateDataPtr privData(new CalendarEventsCallbackPrivateData(cbm, onAddEventCbm));
-        //OnAddEventsChangedEmitterPtr emitter(new OnAddEventsChangedEmitter());
-        //emitter->setListener(&CalendarResponseDispatcher::getInstance());
-        //emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(privData));
-        //calendar->setAddEmitter(emitter);
+        LogDebug("Proceed the event to the platform.");
 
         IEventAddEventsPtr dplEvent(new IEventAddEvents());
         dplEvent->setCalendarType(calendar->getType());
@@ -339,49 +309,46 @@ JSValueRef JSCalendar::update(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_UPDATE);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
+        }
+
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
-        if (argumentCount>2 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (argumentCount<1) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "First parameter is undefined or null.");
-        } else if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarItem::getClassRef()) &&
-        !JSValueIsObjectOfClass(context, arguments[0], JSCalendarEvent::getClassRef()) &&
-        !JSValueIsObjectOfClass(context, arguments[0], JSCalendarTask::getClassRef())) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+        if (argumentCount>=1) {
+            if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEvent::getClassRef()) &&
+            !JSValueIsObjectOfClass(context, arguments[0], JSCalendarTask::getClassRef())) {
+                ThrowMsg(ConversionException, "Wrong first parameter type.");
+            }
+        } else {
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
 
         JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-        CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
-        if (!JSCalendarItem::validate(context, arg, exception)) {
-            ThrowMsg(InvalidArgumentException, "Wrong parameter value.");
-        }
-        if (!event) {
+        CalendarEventPtr item = JSCalendarEvent::getPrivateObject(arg);
+        if (!item) {
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
-        bool updateAllInstances = true;
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-        if( argumentCount > 1 ) {
-            if (JSValueIsBoolean(context, arguments[1])) {
-                updateAllInstances = converter->toBool(arguments[1]);
-            } else {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
+        bool updateAllInstances = true; // Set the default value.
+        CalendarConverter converter(context);
+        if (argumentCount>=2) {
+            updateAllInstances = converter.toBool(arguments[1]);
         }
 
         IEventUpdateEventPtr dplEvent(new IEventUpdateEvent());
-        dplEvent->setEvent(event);
+        dplEvent->setEvent(item);
         dplEvent->setUpdateAllInstances(updateAllInstances);
         dplEvent->setForSynchronousCall();
         calendar->updateEvent(dplEvent);
@@ -389,7 +356,7 @@ JSValueRef JSCalendar::update(JSContextRef context,
         if (dplEvent->getResult()) {
             return JSValueMakeUndefined(context);
         } else {
-            ThrowMsg(UnknownException, "Updating failed by unkown reason.");
+            ThrowMsg(UnknownException, "Updating failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -432,55 +399,54 @@ JSValueRef JSCalendar::updateBatch(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_UPDATE_BATCH);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_UPDATE_BATCH);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    JSCallbackManagerPtr cbm(NULL);
-
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-
-        if (argumentCount>4 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+        JSContextRef globalContext = privateObject->getContext();
+
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
+
+        CalendarConverter converter(context);
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+        if (argumentCount>=1) {
+            if (!JSIsArrayValue(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong first parameter type.");
+            }
+        } else {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
-
         CalendarEventListPtr events;
-        events = converter->toVectorOfEvents(arguments[0]);
+        events = converter.toVectorOfEvents(arguments[0]);
         if (!events) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
+            ThrowMsg(ConversionException, "Third parameter conversion failed.");
         }
 
-        JSValueRef onError = NULL;
-        if (argumentCount > 2) {
-            onError = getFunctionOrNull(context, arguments[2]);
+        JSValueRef onSuccess = NULL;
+        if (argumentCount>=2) {
+            onSuccess = converter.toFunctionOrNull(arguments[1]);
         }
-        JSContextRef globalContext = privateObject->getContext();
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-        CalendarEventsSuccessCallback result;
-        if (argumentCount > 1) {
-            result.onSuccess = getFunctionOrNull(context, arguments[1]);
+        JSValueRef onError = NULL;
+        if (argumentCount>=3) {
+            onError = converter.toFunctionOrNull(arguments[2]);
         }
-        cbm->setOnSuccess(result.onSuccess);
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError);
 
-        bool updateAllInstances = true;
-        if( argumentCount > 3 ) {
-            if (JSValueIsBoolean(context, arguments[3])) {
-                updateAllInstances = converter->toBool(arguments[3]);
-            } else {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
+        bool updateAllInstances = true; // Set the default value.
+        if( argumentCount>=4 ) {
+            updateAllInstances = converter.toBool(arguments[3]);
         }
 
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
+
         LogDebug("Proceed the event to the platform.");
 
         IEventUpdateEventsPtr dplEvent(new IEventUpdateEvents());
@@ -531,42 +497,44 @@ JSValueRef JSCalendar::remove(JSContextRef context,
     LogDebug("entered");
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_REMOVE);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
-
-        if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
         EventIdPtr itemId;
-        JSContextRef globalContext = privateObject->getContext();
-        CalendarConverter converter(globalContext);
-        if (JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
+        CalendarConverter converter(context);
+
+        if (CalendarEvent::EVENT_TYPE==calendar->getType()) {
+            if (argumentCount<1) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+
+            if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
             itemId = JSCalendarEventId::getPrivateObject(JSValueToObject(context, arguments[0], NULL));
             if (!itemId) {
                 ThrowMsg(ConversionException, "Parameter conversion failed.");
             }
             itemId->setCalendarType(CalendarEvent::EVENT_TYPE);
-        } else if (JSValueIsString(context, arguments[0])) {
-            itemId->setUId(converter.toString(arguments[0]));
+        } else if (CalendarEvent::TASK_TYPE==calendar->getType()) {
+            if (argumentCount>=1) {
+                EventIdPtr result( new EventId() );
+                itemId = result;
+                itemId->setUId(converter.toString(arguments[0]));
+            }
             itemId->setCalendarType(CalendarEvent::TASK_TYPE);
         } else {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
         IEventDeleteEventPtr dplEvent(new IEventDeleteEvent());
@@ -579,9 +547,9 @@ JSValueRef JSCalendar::remove(JSContextRef context,
             return JSValueMakeUndefined(context);
         } else {
             if (dplEvent->getExceptionCode() == ExceptionCodes::NotFoundException) {
-                ThrowMsg(ConversionException, "Item not found.");
+                ThrowMsg(NotFoundException, "Item not found.");
             } else {
-                ThrowMsg(UnknownException, "Removing failed by unkown reason.");
+                ThrowMsg(UnknownException, "Removing failed by unnkown reason.");
             }
         }
     }
@@ -622,47 +590,50 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
+
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    JSCallbackManagerPtr cbm(NULL);
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_REMOVE_BATCH);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_BATCH);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-
-        if (argumentCount>3 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
+        JSContextRef globalContext = privateObject->getContext();
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+        CalendarConverter converter(context);
+
+        if (argumentCount>=1) {
+            if (!JSIsArrayValue(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong first parameter type.");
+            }
+        } else {
+                       ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         // Pick one array element to determine its type.
-        JSObjectRef objArg = converter->toJSObjectRef(arguments[0]);
+        JSObjectRef objArg = converter.toJSObjectRef(arguments[0]);
         JSValueRef element;
         if (JSGetArrayLength(context, objArg)>0) {
             element = JSGetArrayElement(context, objArg, 0);
         } else {
-            ThrowMsg(InvalidArgumentException, "Invalid length ID array length.");
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
 
         EventIdListPtr itemIds;
         if (JSValueIsObjectOfClass(context, element, JSCalendarEventId::getClassRef())) {
-            itemIds = converter->toVectorOfEventIds(arguments[0]);
+            itemIds = converter.toVectorOfEventIds(arguments[0]);
             if (!itemIds) {
                 ThrowMsg(ConversionException, "Parameter conversion failed.");
             }
         } else if (JSValueIsString(context, element)) {
-            std::vector<std::string> idStrings = converter->toVectorOfStrings(arguments[0]);
+            std::vector<std::string> idStrings = converter.toVectorOfStrings(arguments[0]);
             for (unsigned int i=0; i<idStrings.size(); i++) {
                 EventIdPtr idPtr( new EventId() );
                 idPtr->setUId(idStrings[i]);
@@ -676,17 +647,18 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        JSValueRef onError = NULL;
-        if (argumentCount > 2) {
-            onError = getFunctionOrNull(context, arguments[2]);
+        JSValueRef onSuccess = NULL;
+        if (argumentCount>=2) {
+            onSuccess = converter.toFunctionOrNull(arguments[1]);
         }
-        JSContextRef globalContext = privateObject->getContext();
-        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-        CalendarEventsSuccessCallback result;
-        if (argumentCount > 1) {
-            result.onSuccess = getFunctionOrNull(context, arguments[1]);
+        JSValueRef onError = NULL;
+        if (argumentCount>=3) {
+            onError = converter.toFunctionOrNull(arguments[2]);
         }
-        cbm->setOnSuccess(result.onSuccess);
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError);
+
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
 
         LogDebug("Proceed the event to the platform.");
 
@@ -727,87 +699,6 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendar::findWithWACFilter(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    CalendarPrivObject *privateObject =
-        static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_FIND);
-
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-    JSCallbackManagerPtr cbm(NULL);
-    Try
-    {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount<1 || argumentCount>4) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
-        JSValueRef onError = (argumentCount > 1 ? getFunctionOrNull(context, arguments[1]) : NULL);
-        JSContextRef globalContext = privateObject->getContext();
-        cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-
-        Validator validator(context);
-        if (validator.isCallback(arguments[0])) {
-            cbm->setOnSuccess(arguments[0]);
-        } else if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
-        //setup filters
-        EventFilterPtr filter(NULL);
-        if (argumentCount >= 3) {
-            LogDebug("setting some filters");
-            CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-            if (!JSValueIsUndefined(context, arguments[2]) && !JSValueIsNull(context, arguments[2])) {
-                filter = converter->toEventFilter(arguments[2]);
-            }
-        }
-        IEventFindEventsPtr dplEvent(new IEventFindEvents());
-        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
-        dplEvent->setFilter(filter);
-        calendar->findEvents(dplEvent);
-
-        return JSValueMakeUndefined(context);
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch (NotFoundException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
-
-    return JSValueMakeUndefined(context);
-}
-
 JSValueRef JSCalendar::find(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
@@ -819,64 +710,74 @@ JSValueRef JSCalendar::find(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_FIND);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_FIND);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        if (argumentCount<1 || argumentCount>4) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        JSCallbackManagerPtr cbm(NULL);
-
-        Validator validator(context, exception);
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-        TizenApis::Tizen1_0::Tizen::FilterConverterFactory::ConverterType filterConverter = TizenApis::Tizen1_0::Tizen::FilterConverterFactory::getConverter(context);
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
 
         JSContextRef globalContext = privateObject->getContext();
-        cbm = JSCallbackManager::createObject(globalContext);
 
-        if ((!validator.isCallback(arguments[0])) ||
-            (argumentCount >= 2 && (!validator.isCallback(arguments[1]) && !validator.isNullOrUndefined(arguments[1]))) ||
-            (argumentCount >= 3 && (!JSValueIsObject(context, arguments[2]) && !validator.isNullOrUndefined(arguments[2]))) ||
-            (argumentCount >= 4 && (!JSValueIsObject(context, arguments[3]) && !validator.isNullOrUndefined(arguments[3])))) {
+        Validator validator(context, exception);
+        CalendarConverter converter(context);
+        TizenApis::Tizen1_0::Tizen::FilterConverterFactory::ConverterType filterConverter = TizenApis::Tizen1_0::Tizen::FilterConverterFactory::getConverter(context);
+
+        if (argumentCount<1) {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        if (cbm) {
-            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-            onSuccessForCbm = arguments[0];
-            if (argumentCount >= 2) {
-                onErrorForCbm = arguments[1];
-            }
-            cbm->setOnSuccess(onSuccessForCbm);
-            cbm->setOnError(onErrorForCbm);
+        JSValueRef onSuccess = NULL;
+        if (argumentCount>=1) {
+            onSuccess = converter.toFunction(arguments[0]);
+        }
+        JSValueRef onError = NULL;
+        if (argumentCount>=2) {
+            onError = converter.toFunctionOrNull(arguments[1]);
         }
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, onSuccess, onError);
+
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
+
+        LogDebug("Proceed the find event to the platform.");
 
         IEventFindEventsPtr dplEvent(new IEventFindEvents());
         dplEvent->setCalendarType(calendar->getType());
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
 
-        if (argumentCount >= 3 && !validator.isNullOrUndefined(arguments[2])) {
-            dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2]));
+        if (argumentCount>=3) {
+            if (JSValueIsObject(context, arguments[2])) {
+                dplEvent->setGenericFilter(filterConverter->toFilter(arguments[2]));
+            } else if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2])) {
+                               LogDebug("Use default filter.");
+            } else {
+                ThrowMsg(ConversionException, "Wrong third parameter type.");
+            }
         }
-        if (argumentCount >= 4 && !validator.isNullOrUndefined(arguments[3])) {
-            // Though the sortMode is a single type, we save it in an array internally.
-            TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
-            sortModes->push_back(filterConverter->toSortMode(arguments[3]));
-            dplEvent->setSortModes(sortModes);
+        if (argumentCount>=4) {
+            if (JSValueIsObject(context, arguments[3])) {
+                // Though the sortMode is a single type, we save it in an array internally.
+                TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
+                sortModes->push_back(filterConverter->toSortMode(arguments[3]));
+                dplEvent->setSortModes(sortModes);
+                       } else if (JSValueIsNull(context, arguments[3]) || JSValueIsUndefined(context, arguments[3])) {
+                               LogDebug("Use default sort mode.");
+            } else {
+                ThrowMsg(ConversionException, "Wrong fourth parameter type.");
+            }
         }
-        /*if (argumentCount >= 5 && !validator.isNullOrUndefined(arguments[4])) {
-            dplEvent->setAttributesOfInterest(converter->toVectorOfStrings(arguments[4]));
-        }*/
 
         calendar->findEvents(dplEvent);
+
+               return JSValueMakeUndefined(context);
     }
     Catch(UnsupportedException)
     {
@@ -918,38 +819,44 @@ JSValueRef JSCalendar::get(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_GET);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
         ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        JSContextRef globalContext = privateObject->getContext();
-
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
 
         EventIdPtr itemId;
-        CalendarConverter converter(globalContext);
-        if (JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
-            itemId = JSCalendarEventId::getPrivateObject(JSValueToObject(context, arguments[0], NULL));
-            if (!itemId) {
-                ThrowMsg(ConversionException, "Parameter conversion failed.");
+        CalendarConverter converter(context);
+        if (CalendarEvent::EVENT_TYPE==calendar->getType()) {
+            if (argumentCount<1) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+
+            if (JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
+                itemId = JSCalendarEventId::getPrivateObject(JSValueToObject(context, arguments[0], NULL));
+                if (!itemId) {
+                    ThrowMsg(ConversionException, "Parameter conversion failed.");
+                }
+                itemId->setCalendarType(CalendarEvent::EVENT_TYPE);
+            } else {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+        } else if (CalendarEvent::TASK_TYPE==calendar->getType()) {
+            EventIdPtr result( new EventId() );
+            itemId = result;
+            if (argumentCount>=1) {
+                itemId->setUId(converter.toString(arguments[0]));
             }
-            itemId->setCalendarType(CalendarEvent::EVENT_TYPE);
-        } else if (JSValueIsString(context, arguments[0])) {
-            itemId->setUId(converter.toString(arguments[0]));
             itemId->setCalendarType(CalendarEvent::TASK_TYPE);
         } else {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
+            ThrowMsg(ConversionException, "Wrong calendar type.");
         }
 
         IEventGetPtr dplEvent(new IEventGet());
@@ -959,10 +866,19 @@ JSValueRef JSCalendar::get(JSContextRef context,
 
         // Process the found item.
         if (dplEvent->getResult()) {
-            LogInfo("Successfully found an item.");
-            return JSCalendarItem::createJSCalendarItem(globalContext, dplEvent->getItem());
+                       if (CalendarEvent::EVENT_TYPE==calendar->getType()) {
+                   return JSCalendarEvent::createJSCalendarEvent(context, dplEvent->getItem());
+                       } else if (CalendarEvent::TASK_TYPE==calendar->getType()) {
+                   return JSCalendarTask::createJSCalendarTask(context, dplEvent->getItem());
+                       } else {
+                   ThrowMsg(UnknownException, "Wrong calendar type.");
+                       }
         } else {
-            ThrowMsg(UnknownException, "Getting an item failed by unkown reason.");
+            if(ExceptionCodes::NotFoundException==dplEvent->getExceptionCode()) {
+                ThrowMsg(NotFoundException, "Item not found.");
+            } else {
+                ThrowMsg(UnknownException, "Getting an item failed by unknown reason.");
+            }
         }
     }
     Catch(UnsupportedException)
@@ -994,7 +910,7 @@ JSValueRef JSCalendar::get(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendar::convertFromString(JSContextRef context,
+JSValueRef JSCalendar::addChangeListener(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -1005,155 +921,53 @@ JSValueRef JSCalendar::convertFromString(JSContextRef context,
 
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-
-    JSContextRef globalContext = privateObject->getContext();
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_CONVERT_FROM_STRING);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, NULL);
-        if (argumentCount!=2) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
-
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
-        else if (!JSValueIsString(context, arguments[0])) {
-            ThrowMsg(ConversionException, "First parameter is not a string type.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        if (JSValueIsUndefined(context, arguments[1]) || JSValueIsNull(context, arguments[1])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
-        else if (!JSValueIsString(context, arguments[1])) {
-            ThrowMsg(ConversionException, "Second parameter is not a CalendarTextFormat type.");
-        }
-
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(globalContext);
-
-        std::string eventStr;
-        CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
+        JSContextRef globalContext = privateObject->getContext();
 
-        eventStr = converter->toString(arguments[0]);
+        CalendarConverter converter(context);
 
-        if( argumentCount>1 )
-        {
-            if (JSValueIsString(context, arguments[1])) {
-                format = converter->toVObjectFormat(converter->toString(arguments[1]));
-            } else {
-                ThrowMsg(ConversionException, "Second parameter is not a CalendarTextFormat type.");
+        if (argumentCount>=1) {
+            if (!JSValueIsObject(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong first parameter type.");
             }
-        }
-
-        IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString());
-        dplEvent->setEventString(eventStr);
-        dplEvent->setFormat(format);
-        dplEvent->setForSynchronousCall();
-        calendar->createEventFromString(dplEvent);
-
-        if (dplEvent->getResult()) {
-            LogInfo("Successfully created an event.");
-            return JSCalendarItemProperties::createJSCalendarItemProperties(globalContext, dplEvent->getEvent());
         } else {
-            ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
-    }
-    Catch(UnsupportedException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(InvalidArgumentException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(ConversionException)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
-    }
-    Catch(Exception)
-    {
-               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
-    }
 
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSCalendar::addChangeListener(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    CalendarPrivObject *privateObject =
-        static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER);
-
-    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-    JSCallbackManagerPtr cbm(NULL);
-    Try
-    {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount>2 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
-
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
         JSValueRef onError = NULL;
-        if (argumentCount > 1) {
-            onError = getFunctionOrNull(context, arguments[1]);
+        if (argumentCount>=2) {
+            onError = converter.toFunctionOrNull(arguments[1]);
         }
-        JSContextRef globalContext = privateObject->getContext();
         JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-        JSObjectRef objectCallbacks = converter->toJSObjectRef(arguments[0]);
+
+        JSObjectRef objectCallbacks = converter.toJSObjectRef(arguments[0]);
         CalendarChangeCallback result;
-        result.onAdded = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onItemsAdded");
-        result.onUpdated = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onItemsUpdated");
-        result.onDeleted = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onItemsRemoved");
+        result.onAdded = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsadded");
+        result.onUpdated = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsupdated");
+        result.onDeleted = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onitemsremoved");
         Validator validator(context);
         if ((!validator.isNullOrUndefined(result.onAdded) && !validator.isCallback(result.onAdded)) ||
            (!validator.isNullOrUndefined(result.onUpdated) && !validator.isCallback(result.onUpdated)) ||
            (!validator.isNullOrUndefined(result.onDeleted) && !validator.isCallback(result.onDeleted)))
         {
-            ThrowMsg(InvalidArgumentException, "Wrong successCallback parameter value.");
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
         JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(globalContext, result.onAdded, NULL);
         JSCallbackManagerPtr onUpdatedCbm = JSCallbackManager::createObject(globalContext, result.onUpdated, NULL);
         JSCallbackManagerPtr onDeletedCbm = JSCallbackManager::createObject(globalContext, result.onDeleted, NULL);
 
-        /* The interested attributes are not supported in platform.
-        AttributeListPtr attributes;
-        if( argumentCount >= 3 ) {
-            try
-            {
-                *attributes = converter->toVectorOfStrings(arguments[2]);
-                if (!attributes) {
-                    LogError("watchChanges: Failed to get interested attributes");
-                    Throw(InvalidArgumentException);
-                }
-            }
-            Catch(Exception)
-            {
-                LogError("Error while converting the attributes");
-                Throw(InvalidArgumentException);
-            }
-        }*/
-
-        LogDebug("Make change emitter and sync operation");
+        LogDebug("Make change emitter and process sync operation.");
 
         CalendarChangeCallbackPrivateDataPtr privData(new CalendarChangeCallbackPrivateData(
             onAddedCbm, onUpdatedCbm, onDeletedCbm));
@@ -1161,7 +975,6 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
         emitter->setListener(&CalendarResponseDispatcher::getInstance());
         emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(privData));
 
-        // return sync operation and process the events and emit results while processing them
         IEventWatchChangesPtr dplEvent(new IEventWatchChanges());
         dplEvent->setEmitter(emitter);
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
@@ -1172,9 +985,9 @@ JSValueRef JSCalendar::addChangeListener(JSContextRef context,
         if (dplEvent->getResult()) {
             watchId = dplEvent->getWatchId();
             LogDebug("Returning the watchId "<<watchId);
-            return converter->toJSValueRefLong(watchId);
+            return converter.toJSValueRefLong(watchId);
         } else {
-            ThrowMsg(UnknownException, "Adding change listener failed by unkown reason.");
+            ThrowMsg(UnknownException, "Adding change listener failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -1209,27 +1022,28 @@ JSValueRef JSCalendar::removeChangeListener(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
+
     CalendarPrivObject *privateObject =
         static_cast<CalendarPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
+
         long watchId = -1;
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-        if (JSValueIsNumber(context, arguments[0])) {
-            watchId = converter->toLong(arguments[0]);
+        CalendarConverter converter(context);
+        if (argumentCount>=1) {
+            watchId = converter.toLong(arguments[0]);
         } else {
-            ThrowMsg(ConversionException, "Wrong watchId type.");
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         LogDebug("Make sync operation");
@@ -1288,7 +1102,7 @@ JSValueRef JSCalendar::getPropertyName(JSContextRef context,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSCalendar::getPropertyAccountId(JSContextRef context,
+JSValueRef JSCalendar::getPropertyAccountServiceId(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
         JSValueRef* exception)
index 1ed11b8..a040594 100755 (executable)
@@ -30,7 +30,7 @@ namespace Tizen1_0 {
 namespace Calendar {
 
 #define TIZEN_CALENDAR_PROPERTY_NAME "name"
-#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_ID "accountId"
+#define TIZEN_CALENDAR_PROPERTY_ACCOUNT_SERVICE_ID "accountServiceId"
 #define TIZEN_CALENDAR_PROPERTY_ID "id"
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::ICalendarPtr,
@@ -81,7 +81,7 @@ class JSCalendar
             JSStringRef propertyName,
             JSValueRef* exception);
 
-    static JSValueRef getPropertyAccountId(JSContextRef context,
+    static JSValueRef getPropertyAccountServiceId(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
             JSValueRef* exception);
@@ -152,16 +152,6 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Search for calendar items using old wac2.0 stype filter.
-     */
-    static JSValueRef findWithWACFilter(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
      * Search for calendar items using tizen generic filter.
      */
     static JSValueRef find(JSContextRef context,
@@ -172,16 +162,6 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Create an event from string
-     */
-    static JSValueRef convertFromString(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
      * Watch changes
      */
     static JSValueRef addChangeListener(JSContextRef context,
index bffc974..6d2221f 100755 (executable)
@@ -131,58 +131,48 @@ JSObjectRef JSCalendarAlarm::constructor(JSContextRef context,
 
     Try
     {
-        if (argumentCount<2 || argumentCount>3) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (argumentCount<1) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        EventAlarmPrivateObject* privateObject = static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(constructor));
-        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+        CalendarConverter converter(context);
+        TimeUtilConverter timeConverter(context);
 
-        CalendarConverter converter(globalContext);
-        EventAlarmPtr alarm( new EventAlarm());
+        EventAlarmPtr alarm( new EventAlarm() );
 
-        TimeUtilConverter timeConverter(context);
-        if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())){ // absoluteDate case
+        if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())){
+            LogDebug("absoluteDate case");
             std::time_t absoluteDate = timeConverter.toTZDateTimeT(arguments[0]);
             alarm->setAbsoluteDate(absoluteDate);
             alarm->setTimeZone(timeConverter.getPropertiesInTZDate(arguments[0]).timezone);
-            if (JSValueIsString(context, arguments[1])) {
+
+            if (argumentCount>=2) {
                 std::string method = converter.toString(arguments[1]);
                 std::vector<CalendarEvent::EventAlarmType> convertedMethods;
                 convertedMethods.push_back(converter.toEventAlarmType(method));
                 alarm->setMethods(convertedMethods);
-            } else {
-                ThrowMsg(ConversionException, "Second parameter conversion failed.");
             }
-            if (argumentCount==3) {
-                if (JSValueIsString(context, arguments[2])) {
-                    alarm->setDescription(converter.toString(arguments[2]));
-                } else {
-                    ThrowMsg(ConversionException, "Third parameter conversion failed.");
-                }
+            if (argumentCount>=3) {
+                alarm->setDescription(converter.toString(arguments[2]));
             }
-        } else if (JSValueIsObjectOfClass(context, arguments[0], JSTimeDuration::getClassRef())){ // before case
+        } else if (JSValueIsObjectOfClass(context, arguments[0], JSTimeDuration::getClassRef())){
+            LogDebug("before case");
             alarm->setDuration(timeConverter.getDurationPropertis(arguments[0]));
-            if (JSValueIsString(context, arguments[1])) {
+
+            if (argumentCount>=2) {
                 std::string method = converter.toString(arguments[1]);
                 std::vector<CalendarEvent::EventAlarmType> convertedMethods;
                 convertedMethods.push_back(converter.toEventAlarmType(method));
                 alarm->setMethods(convertedMethods);
-            } else {
-                ThrowMsg(ConversionException, "Second parameter conversion failed.");
             }
-            if (argumentCount==3) {
-                if (JSValueIsString(context, arguments[2])) {
-                    alarm->setDescription(converter.toString(arguments[2]));
-                } else {
-                    ThrowMsg(ConversionException, "Thrid parameter conversion failed.");
-                }
+            if (argumentCount>=3) {
+                alarm->setDescription(converter.toString(arguments[2]));
             }
         } else {
-            ThrowMsg(ConversionException, "First parameter conversion failed.");
+            ThrowMsg(ConversionException, "Wrong first parameter type.");
         }
 
-        return createJSCalendarAlarm(globalContext, alarm);
+        return createJSCalendarAlarm(context, alarm);
     }
     Catch(UnsupportedException)
     {
@@ -211,16 +201,26 @@ JSObjectRef JSCalendarAlarm::constructor(JSContextRef context,
 void JSCalendarAlarm::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("enter");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar alarm private object.");
+        EventAlarmPtr alarm( new EventAlarm() );
+        EventAlarmPrivateObject *priv = new EventAlarmPrivateObject(context, alarm);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    } else {
+        LogDebug("Private object alrerady set.");
+    }
 }
 
 void JSCalendarAlarm::finalize(JSObjectRef object)
 {
-    LogDebug("enter");
-    EventAlarmPrivateObject* priv =
-        static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
+    LogDebug("entered");
+    EventAlarmPrivateObject* priv = static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 JSValueRef JSCalendarAlarm::getProperty(JSContextRef context,
@@ -229,7 +229,7 @@ JSValueRef JSCalendarAlarm::getProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("enter");
-    WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+    CalendarConverter converter(context);
     Try
     {
         EventAlarmPrivateObject* priv =
@@ -243,22 +243,18 @@ JSValueRef JSCalendarAlarm::getProperty(JSContextRef context,
             if (!alarm) {
                 Throw(WrtDeviceApis::Commons::NullPointerException);
             }
-            if (alarm->getAbsoluteDate() != 0) {
-                // Use the global context saved in the event struct.
-                return JSTZDate::createJSObject(priv->getContext(), alarm->getAbsoluteDate(), alarm->getTimeZone());
+
+            if (UNDEFINED_TIME==alarm->getAbsoluteDate()) {
+                return JSValueMakeNull(context);
             } else {
-                return JSValueMakeUndefined(context);
+                return JSTZDate::createJSObject(context, alarm->getAbsoluteDate(), alarm->getTimeZone());
             }
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) {
-            return JSTimeDuration::createJSObject(priv->getContext(), alarm->getDuration());
+            return JSTimeDuration::createJSObject(context, alarm->getDuration());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_DESCRIPTION)) {
             return converter.toJSValueRef(alarm->getDescription());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHOD)) {
-            std::vector<JSValueRef> result;
-            std::vector<CalendarEvent::EventAlarmType> methods = alarm->getMethods();
-            for(std::vector<CalendarEvent::EventAlarmType>::iterator i = methods.begin(); i != methods.end(); i++)
-                result.push_back(converter.toJSValueRef(*i));
-            return converter.toJSValueRef(result);
+            return converter.toJSValueRef(converter.toTizenValue(alarm->getMethods().at(0)));
         }
     }
     Catch(WrtDeviceApis::Commons::Exception)
index ce9c803..c9f528c 100755 (executable)
 #include <CommonsJavaScript/Converter.h>
 #include "CalendarConverter.h"
 
+#include "Tizen/Contact/JSContactRef.h"
+#include <Tizen/Contact/ContactConverter.h>
+#include <API/Contact/ContactRef.h>
+#include <API/TimeUtil/DurationProperties.h>
+
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
@@ -91,16 +96,26 @@ JSObjectRef JSCalendarAttendee::createJSCalendarAttendee(JSContextRef context, E
 void JSCalendarAttendee::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("enter");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar attendee private object.");
+        EventAttendeePtr attendee( new EventAttendee() );
+        AttendeePrivateObject *priv = new AttendeePrivateObject(context, attendee);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    } else {
+        LogDebug("Private object alrerady set.");
+    }
 }
 
 void JSCalendarAttendee::finalize(JSObjectRef object)
 {
     LogDebug("enter");
-    AttendeePrivateObject* priv =
-        static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
+    AttendeePrivateObject* priv = static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 EventAttendeePtr JSCalendarAttendee::getPrivateObject(JSObjectRef object)
@@ -149,38 +164,34 @@ JSObjectRef JSCalendarAttendee::constructor(JSContextRef context,
 
     Try
     {
-        AttendeePrivateObject* privateObject = static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(constructor));
-        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
-
-        CalendarConverter converter(globalContext);
+        CalendarConverter converter(context);
         EventAttendeePtr attendee;
 
-        if (argumentCount==1) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        if (argumentCount==0) {
+            EventAttendeePtr result(new EventAttendee());
+            attendee = result;
+        } else if (argumentCount==1) {
             EventAttendeePtr result(new EventAttendee());
             attendee = result;
             attendee->setURI(converter.toString(arguments[0]));
-            if (!attendee) {
-                ThrowMsg(ConversionException, "Parameter conversion failed.");
-            }
-        } else if (argumentCount==2) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
+        } else if (argumentCount>=2) {
+            if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) {
+                EventAttendeePtr result(new EventAttendee());
+                attendee = result;
+            } else {
+                if (!JSValueIsObject(context, arguments[1])) {
+                    ThrowMsg(ConversionException, "Wrong second parameter type.");
+                }
 
-            attendee = converter.toAttendee(arguments[1]);
-            if (!attendee) {
-                ThrowMsg(ConversionException, "Parameter conversion failed.");
+                attendee = converter.toAttendee(arguments[1]);
+                if (!attendee) {
+                    ThrowMsg(ConversionException, "Parameter conversion failed.");
+                }
             }
             attendee->setURI(converter.toString(arguments[0]));
-        } else {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        return createJSCalendarAttendee(globalContext, attendee);
+        return createJSCalendarAttendee(context, attendee);
     }
     Catch(UnsupportedException)
     {
@@ -212,8 +223,7 @@ JSValueRef JSCalendarAttendee::getProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("enter");
-    CalendarConverterFactory::ConverterType converter =
-        CalendarConverterFactory::getConverter(context);
+    CalendarConverter converter(context);
     Try
     {
         AttendeePrivateObject* priv =
@@ -224,25 +234,29 @@ JSValueRef JSCalendarAttendee::getProperty(JSContextRef context,
         EventAttendeePtr attendee = priv->getObject();
 
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_NAME)) {
-            return converter->toJSValueRef(attendee->getName());
+            return converter.toJSValueRef(attendee->getName());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_URI)) {
-            return converter->toJSValueRef(attendee->getURI());
+            return converter.toJSValueRef(attendee->getURI());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_ROLE)) {
-            return converter->toJSValueRef(converter->toTizenValue(attendee->getRole()));
+            return converter.toJSValueRef(converter.toTizenValue(attendee->getRole()));
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_STATUS)) {
-            return converter->toJSValueRef(converter->toTizenValue(attendee->getStatus()));
+            return converter.toJSValueRef(converter.toTizenValue(attendee->getStatus()));
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) {
-            return converter->toJSValueRef(attendee->getRSVP());
+            return converter.toJSValueRef(attendee->getRSVP());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_TYPE)) {
-           return converter->toJSValueRef(converter->toTizenValue(attendee->getType()));
+           return converter.toJSValueRef(converter.toTizenValue(attendee->getType()));
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) {
-            return converter->toJSValueRef(attendee->getGroup());
+            return converter.toJSValueRef(attendee->getGroup());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATORURI)) {
-            return converter->toJSValueRef(attendee->getDelegatorURI());
+            return converter.toJSValueRef(attendee->getDelegatorURI());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) {
-            return converter->toJSValueRef(attendee->getDelegateURI());
+            return converter.toJSValueRef(attendee->getDelegateURI());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_CONTACT_REF)) {
-            return converter->toJSValueRef(attendee->getContactId());
+            TizenApis::Tizen1_0::Contact::ContactConverter contactConverter(context);
+            TizenApis::Api::Contact::ContactRefPtr contactRefPtr( new TizenApis::Api::Contact::ContactRef() );
+            contactRefPtr->setContactId(attendee->getContactId());
+            contactRefPtr->setAddressBookId(attendee->getAddressBookId());
+            return contactConverter.toJSValueRef(contactRefPtr);
         }
     }
     Catch(Exception)
@@ -259,8 +273,7 @@ bool JSCalendarAttendee::setProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    CalendarConverterFactory::ConverterType converter =
-        CalendarConverterFactory::getConverter(context);
+    CalendarConverter converter(context);
     Try
     {
         AttendeePrivateObject* priv =
@@ -274,71 +287,73 @@ bool JSCalendarAttendee::setProperty(JSContextRef context,
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string name = converter->toString(value);
+            std::string name = converter.toString(value);
             attendee->setName(name);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_URI)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string uri = converter->toString(value);
+            std::string uri = converter.toString(value);
             attendee->setURI(uri);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_ROLE)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string role = converter->toString(value);
-            attendee->setRole(converter->toEventAttendeeRole(role));
+            std::string role = converter.toString(value);
+            attendee->setRole(converter.toEventAttendeeRole(role));
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_STATUS)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string status = converter->toString(value);
-            attendee->setStatus(converter->toEventAttendeeStatus(status));
+            std::string status = converter.toString(value);
+            attendee->setStatus(converter.toEventAttendeeStatus(status));
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) {
             if (!JSValueIsBoolean(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            bool RSVP = converter->toBool(value);
+            bool RSVP = converter.toBool(value);
             attendee->setRSVP(RSVP);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_TYPE)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string type = converter->toString(value);
-            attendee->setType(converter->toEventAttendeeType(type));
+            std::string type = converter.toString(value);
+            attendee->setType(converter.toEventAttendeeType(type));
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string group = converter->toString(value);
+            std::string group = converter.toString(value);
             attendee->setGroup(group);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATORURI)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string delegatorURI = converter->toString(value);
+            std::string delegatorURI = converter.toString(value);
             attendee->setDelegatorURI(delegatorURI);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string delegateURI = converter->toString(value);
+            std::string delegateURI = converter.toString(value);
             attendee->setDelegateURI(delegateURI);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_CONTACT_REF)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string uid = converter->toString(value);
-            attendee->setContactId(uid);
+
+            TizenApis::Tizen1_0::Contact::ContactConverter contactConverter(context);
+            attendee->setContactId(contactConverter.toContactRef(value)->getContactId());
+            attendee->setAddressBookId(contactConverter.toContactRef(value)->getAddressBookId());
             return true;
         }
     }
index acdc93d..eac5832 100755 (executable)
@@ -20,6 +20,7 @@
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Utils.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Calendar/EventId.h>
@@ -40,22 +41,6 @@ using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Commons;
 
-namespace {
-/**
- * @throw InvalidArgumentException If not a callback nor JS null nor JS undefined.
- */
-JSValueRef getFunctionOrNull(JSContextRef ctx,
-        JSValueRef arg)
-{
-    if (Validator(ctx).isCallback(arg)) {
-        return arg;
-    } else if (!JSValueIsNull(ctx, arg) && !JSValueIsUndefined(ctx, arg)) {
-        ThrowMsg(InvalidArgumentException, "Not a function nor JS null.");
-    }
-    return NULL;
-}
-}
-
 namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
@@ -104,29 +89,31 @@ ICalendarPtr JSCalendarEvent::m_calendar = CalendarFactory::getInstance().create
 void JSCalendarEvent::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("entered");
-    CalendarEventPrivObject *priv =
-        static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        CalendarEventPtr privateData(new CalendarEvent());
-        priv = new CalendarEventPrivObject(context, privateData);
-        JSObjectSetPrivate(object, static_cast<void*>(priv));
-        LogDebug("New event is created.");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar event private object.");
+        CalendarEventPtr event( new CalendarEvent() );
+        CalendarEventPrivObject *priv = new CalendarEventPrivObject(context, event);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
     } else {
-        LogDebug("Private object already exists.");
+        LogDebug("Private object alrerady set.");
     }
 
-    if (!m_calendar) {
-        LogDebug("Calendar object does not exist!");
-    } else {
+    if (m_calendar) {
         m_calendar->setType(CalendarEvent::EVENT_TYPE);
-        LogDebug("Calendar object type is set.");
+        LogDebug("Calendar object type is set to event.");
     }
 }
 
 void JSCalendarEvent::finalize(JSObjectRef object)
 {
-    LogDebug("entered");
+    LogDebug("enter");
+    CalendarEventPrivObject* priv = static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 JSObjectRef JSCalendarEvent::constructor(JSContextRef context,
@@ -140,7 +127,7 @@ JSObjectRef JSCalendarEvent::constructor(JSContextRef context,
     Try
     {
                CalendarEventPrivObject* privateObject = static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(constructor));
-               JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+               JSContextRef globalContext = privateObject->getContext();
 
         CalendarConverter converter(globalContext);
         CalendarEventPtr event;
@@ -148,18 +135,23 @@ JSObjectRef JSCalendarEvent::constructor(JSContextRef context,
         if (argumentCount==0) {
             CalendarEventPtr result(new CalendarEvent());
             event = result;
-        } else if (argumentCount==1) { // eventInitDict case
-            event = converter.toEvent(arguments[0]);
-            if (!event) {
+        } else if (argumentCount==1) {
+            LogInfo("eventInitDict case");
+            if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+                CalendarEventPtr result(new CalendarEvent());
+                event = result;
+            } else if (JSValueIsObject(context, arguments[0])) {
+                event = converter.toEvent(arguments[0]);
+                if (!event) {
+                    ThrowMsg(ConversionException, "Parameter conversion failed.");
+                }
+            } else {
                 ThrowMsg(ConversionException, "Parameter conversion failed.");
             }
-        } else if (argumentCount==2) { // stringRepresentation case
-            if (!JSValueIsString(context, arguments[0]) || !JSValueIsString(context, arguments[1])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        } else if (argumentCount>=2) {
+            LogInfo("event stringRepresentation case");
             std::string eventStr;
-            CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
+            CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT;
             eventStr = converter.toString(arguments[0]);
             format = converter.toVObjectFormat(converter.toString(arguments[1]));
 
@@ -171,13 +163,15 @@ JSObjectRef JSCalendarEvent::constructor(JSContextRef context,
 
             // Process the returned object.
             if (dplEvent->getResult()) {
-                LogInfo("Successfully created an item.");
+                LogInfo("Successfully created an event.");
                 event = dplEvent->getEvent();
             } else {
-                ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
+                if (dplEvent->getExceptionCode()==ExceptionCodes::InvalidArgumentException) {
+                    ThrowMsg(InvalidArgumentException, "Wrong string to convert.");
+                } else {
+                    ThrowMsg(UnknownException, "Converting string failed.");
+                }
             }
-        } else {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
         return createJSCalendarEvent(globalContext, event);
@@ -269,20 +263,18 @@ JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
+
     CalendarEventPrivObject *privateObject =
         static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_EXPAND_RECURRENCE);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_EXPAND_RECURRENCE);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    JSCallbackManagerPtr cbm(NULL);
-
     Try
     {
-        if (argumentCount<3 || argumentCount>4) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
         CalendarEventPtr event = privateObject->getObject();
@@ -290,34 +282,45 @@ JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context,
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
-        JSValueRef onError =(argumentCount > 3 ? getFunctionOrNull(context, arguments[3]) : NULL);
         JSContextRef globalContext = privateObject->getContext();
-        cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
-
-        Validator validator(context);
-        if (validator.isCallback(arguments[2])) {
-            cbm->setOnSuccess(arguments[2]);
-        } else if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
+        CalendarConverter converter(context);
 
         std::time_t startDate = 0;
         std::time_t endDate = INT_MAX; // about 60 years in 4 bytes system.
-        Converter converter(context);
         TimeUtilConverter timeConverter(context);
-        if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())) {
-            startDate = timeConverter.toTZDateTimeT(arguments[0]);
-        } else {
-            ThrowMsg(ConversionException, "Wrong first parameter type.");
+        if (argumentCount>=1) {
+            if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())) {
+                startDate = timeConverter.toTZDateTimeT(arguments[0]);
+                LogInfo("startDate: "<<startDate);
+            } else {
+                ThrowMsg(ConversionException, "Wrong first parameter type.");
+            }
+        }
+        if (argumentCount>=2) {
+            if (JSValueIsObjectOfClass(context, arguments[1], JSTZDate::getClassRef())) {
+                endDate = timeConverter.toTZDateTimeT(arguments[1]);
+                LogInfo("endDate: "<<endDate);
+            } else {
+                ThrowMsg(ConversionException, "Wrong second parameter type.");
+            }
         }
-        if (JSValueIsObjectOfClass(context, arguments[1], JSTZDate::getClassRef())) {
-            endDate = timeConverter.toDateTimeT(arguments[1]);
+
+        JSValueRef onError = argumentCount > 1 ? converter.toFunctionOrNull(arguments[3]) : NULL;
+
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
+
+        Validator validator(context);
+        if (validator.isCallback(arguments[2])) {
+            cbm->setOnSuccess(arguments[2]);
         } else {
-            ThrowMsg(ConversionException, "Wrong second parameter type.");
+            ThrowMsg(ConversionException, "Wrong third parameter type.");
         }
 
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
+
+        LogDebug("Proceed the expand event to the platform.");
+
         IEventExpandEventRecurrencePtr dplEvent(new IEventExpandEventRecurrence());
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
@@ -370,10 +373,18 @@ JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context,
         CalendarEventPtr event = privateObject->getObject();
 
         EventIdPtr eventId( new EventId() );
-        eventId->setUId(event->getUId());
-        eventId->setRecurrenceId(event->getRecurrenceId());
-        eventId->setTimeZone(event->getTimeZone());
-        return JSCalendarEventId::createJSCalendarEventId(privateObject->getContext(), eventId);
+               if (0<event->getParentId()) {
+                       std::stringstream ss;
+                       ss<<event->getParentId();
+                       eventId->setUId(ss.str());
+               } else {
+               eventId->setUId(event->getUId());
+               }
+        std::stringstream ss;
+        std::time_t rid = event->getRecurrenceId();
+        ss<<rid;
+        eventId->setRecurrenceId(ss.str());
+        return JSCalendarEventId::createJSCalendarEventId(context, eventId);
     }
     Catch(Exception)
     {
@@ -393,15 +404,14 @@ JSValueRef JSCalendarEvent::getPropertyLastModificationDate(JSContextRef context
         CalendarEventPrivObject *privateObject =
             static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
         CalendarEventPtr event = privateObject->getObject();
-
         if (!event) {
             Throw(NullPointerException);
         }
-        if (event->getLastModifiedDate() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), event->getLastModifiedDate(), event->getTimeZone());
+
+        if (UNDEFINED_TIME==event->getLastModifiedDate()) {
+            return JSValueMakeNull(context);
         } else {
-            return JSValueMakeUndefined(context);
+            return JSTZDate::createJSObject(context, event->getLastModifiedDate(), event->getTimeZone());
         }
     }
     Catch(Exception)
index 73d0965..15b131a 100755 (executable)
@@ -23,6 +23,7 @@
 #include <CommonsJavaScript/Converter.h>
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <Tizen/TimeUtil/JSTZDate.h>
+#include <sstream>
 
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
@@ -120,16 +121,26 @@ JSObjectRef JSCalendarEventId::createJSCalendarEventId(JSContextRef context, Eve
 void JSCalendarEventId::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("enter");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar event id private object.");
+        EventIdPtr eventId( new EventId() );
+        EventIdPrivateObject *priv = new EventIdPrivateObject(context, eventId);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    } else {
+        LogDebug("Private object alrerady set.");
+    }
 }
 
 void JSCalendarEventId::finalize(JSObjectRef object)
 {
     LogDebug("enter");
-    EventIdPrivateObject* priv =
-        static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
+    EventIdPrivateObject* priv = static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 JSObjectRef JSCalendarEventId::constructor(JSContextRef context,
@@ -142,39 +153,24 @@ JSObjectRef JSCalendarEventId::constructor(JSContextRef context,
 
     Try
     {
-        EventIdPrivateObject* privateObject = static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(constructor));
-        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
-
-        CalendarConverter converter(globalContext);
+        CalendarConverter converter(context);
         EventIdPtr eventId;
 
-        if (argumentCount==1) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        if (argumentCount==0) {
+            EventIdPtr result( new EventId());
+            eventId = result;
+        } else if (argumentCount==1) {
             EventIdPtr result( new EventId());
             eventId = result;
             eventId->setUId(converter.toString(arguments[0]));
-        } else if (argumentCount==2) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-            if (!JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        } else if (argumentCount>=2) {
             EventIdPtr result( new EventId());
             eventId = result;
             eventId->setUId(converter.toString(arguments[0]));
-
-            TimeUtilConverter timeUtilConverter(globalContext);
-            eventId->setRecurrenceId(timeUtilConverter.toTZDateTimeT(arguments[1]));
-        } else {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+            eventId->setRecurrenceId(converter.toString(arguments[1]));
         }
 
-        return createJSCalendarEventId(globalContext, eventId);
+        return createJSCalendarEventId(context, eventId);
     }
     Catch(UnsupportedException)
     {
@@ -206,27 +202,30 @@ JSValueRef JSCalendarEventId::getProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("enter");
-    Converter converter(context);
     Try
     {
-        EventIdPrivateObject* priv =
-            static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+        EventIdPrivateObject* priv = static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
+
         EventIdPtr eventId = priv->getObject();
+        if (!eventId) {
+            Throw(NullPointerException);
+        }
 
+        Converter converter(context);
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_UID)) {
-            return converter.toJSValueRef(eventId->getUId());
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) {
-            if (!eventId) {
-                Throw(NullPointerException);
-            }
-            if (eventId->getRecurrenceId() != 0) {
-                // Use the global context saved in the event struct.
-                return JSTZDate::createJSObject(priv->getContext(), eventId->getRecurrenceId(), eventId->getTimeZone());
+            if (eventId->getUId()==UNDEFINED_ID) {
+                return JSValueMakeUndefined(context);
             } else {
+                return converter.toJSValueRef(eventId->getUId());
+            }
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) {
+            if (eventId->getRecurrenceId()==UNDEFINED_ID) {
                 return JSValueMakeUndefined(context);
+            } else {
+                return converter.toJSValueRef(eventId->getRecurrenceId());
             }
         }
     }
@@ -244,16 +243,16 @@ bool JSCalendarEventId::setProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    Converter converter(context);
     Try
     {
-        EventIdPrivateObject* priv =
-            static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+        EventIdPrivateObject* priv = static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
         if (!priv) {
             Throw(NullPointerException);
         }
-        EventIdPtr eventId = priv->getObject();
 
+        // Basically id attributre is read-only.
+        EventIdPtr eventId = priv->getObject();
+        Converter converter(context);
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_UID)) {
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
@@ -262,17 +261,11 @@ bool JSCalendarEventId::setProperty(JSContextRef context,
             eventId->setUId(uid);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) {
-            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+            if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            TimeUtilConverter timeConverter(context);
-            std::time_t recurrenceId = timeConverter.toTZDateTimeT(value);
+            std::string recurrenceId = converter.toString(value);
             eventId->setRecurrenceId(recurrenceId);
-
-            if( eventId->getTimeZone().empty() ) {
-                std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
-                eventId->setTimeZone(timeZone);
-            }
             return true;
         }
     }
index 347367f..5e61dee 100755 (executable)
@@ -29,7 +29,7 @@ namespace Calendar {
 #define TIZEN_INTERFACE_CALENDAR_EVENT_ID "CalendarEventId"
 
 #define TIZEN_CALENDAR_EVENT_ID_UID "uid"
-#define TIZEN_CALENDAR_EVENT_ID_RECURRENCEID "recurrenceId"
+#define TIZEN_CALENDAR_EVENT_ID_RECURRENCEID "rid"
 
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventIdPtr,
                                WrtDeviceApis::CommonsJavaScript::NoOwnership> EventIdPrivateObject;
diff --git a/src/standards/Tizen/Calendar/JSCalendarItem.cpp b/src/standards/Tizen/Calendar/JSCalendarItem.cpp
deleted file mode 100755 (executable)
index 4f30327..0000000
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include <ctime>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <API/Calendar/EventId.h>
-#include "JSCalendarItem.h"
-#include "JSCalendarItemProperties.h"
-#include "CalendarConverter.h"
-#include "JSCalendarEventId.h"
-#include <Tizen/TimeUtil/TimeUtilConverter.h>
-#include <Tizen/TimeUtil/JSTZDate.h>
-
-using namespace TizenApis::Api::Calendar;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Calendar {
-
-#define TIZEN_CALENDAR_ITEM_ATTRIBUTENAME "CalendarItem"
-
-JSClassDefinition JSCalendarItem::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    TIZEN_CALENDAR_ITEM_ATTRIBUTENAME,
-    JSCalendarItemProperties::getClassRef(),
-    m_property,
-    NULL,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL, //getProperty,
-    NULL, //setProperty,
-    NULL, //DeleteProperty,
-    NULL, //GetPropertyNames,
-    NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    NULL, //HasInstance,
-    NULL  //ConvertToType
-};
-
-JSStaticValue JSCalendarItem::m_property[] = {
-    //EventProperties
-    { TIZEN_CALENDAR_ITEM_ID, getPropertyId,
-      NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_ITEM_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
-      NULL, kJSPropertyAttributeReadOnly },
-    { TIZEN_CALENDAR_ITEM_IS_DETACHED, getPropertyIsDetached,
-      NULL, kJSPropertyAttributeReadOnly },
-
-    { 0, 0, 0, 0 }
-};
-
-JSClassRef JSCalendarItem::m_jsClassRef = JSClassCreate(JSCalendarItem::getClassInfo());
-
-void JSCalendarItem::initialize(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("entered");
-    CalendarItemPrivObject *priv =
-        static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        CalendarEventPtr privateData(new CalendarEvent());
-        priv = new CalendarItemPrivObject(context, privateData);
-        JSObjectSetPrivate(object, static_cast<void*>(priv));
-        LogDebug("new event is created");
-    } else {
-        LogDebug("private object already exists");
-    }
-}
-
-void JSCalendarItem::finalize(JSObjectRef object)
-{
-    LogDebug("entered");
-}
-
-const JSClassRef JSCalendarItem::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-const JSClassDefinition* JSCalendarItem::getClassInfo()
-{
-    return &m_classInfo;
-}
-
-CalendarEventPtr JSCalendarItem::getPrivateObject(JSObjectRef object)
-{
-    LogDebug("entered");
-    CalendarItemPrivObject *priv =
-        static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    CalendarEventPtr result = priv->getObject();
-    if (!result) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    return result;
-}
-
-void JSCalendarItem::setPrivateObject(const CalendarEventPtr &event,
-        JSContextRef ctx,
-        const JSObjectRef object)
-{
-    LogDebug("entered");
-    Try
-    {
-        CalendarItemPrivObject *priv =
-            static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-        delete priv;
-        priv = new CalendarItemPrivObject(ctx, event);
-        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-            delete priv;
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("Error during replacing event object");
-    }
-}
-
-JSObjectRef JSCalendarItem::createJSCalendarItem(JSContextRef context, CalendarEventPtr item)
-{
-    CalendarItemPrivObject *priv = new CalendarItemPrivObject(context, item);
-    return JSObjectMake(context, getClassRef(), priv);
-}
-
-JSValueRef JSCalendarItem::getPropertyId(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        CalendarItemPrivObject *privateObject =
-            static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-        CalendarEventPtr item = privateObject->getObject();
-
-        if (CalendarEvent::TASK_TYPE == item->getCalendarType()) {
-            Converter converter(context);
-            converter.toJSValueRef(item->getUId());
-        } else {
-            EventIdPtr eventId( new EventId() );
-            eventId->setUId(item->getUId());
-            LogDebug("item->getRecurrenceId() : " << item->getRecurrenceId());
-            eventId->setRecurrenceId(item->getRecurrenceId());
-            eventId->setTimeZone(item->getTimeZone());
-            return JSCalendarEventId::createJSCalendarEventId(privateObject->getContext(), eventId);
-        }
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to get incorrect value");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSCalendarItem::getPropertyLastModificationDate(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        CalendarItemPrivObject *privateObject =
-            static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-        CalendarEventPtr item = privateObject->getObject();
-
-        if (!item) {
-            Throw(NullPointerException);
-        }
-        if (item->getLastModifiedDate() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), item->getLastModifiedDate(), item->getTimeZone());
-        } else {
-            return JSValueMakeUndefined(context);
-        }
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to get incorrect value");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSCalendarItem::getPropertyIsDetached(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Try
-    {
-        CalendarEventPtr item = getPrivateObject(object);
-        if(CalendarEvent::EVENT_TYPE != item->getCalendarType()) {
-            return JSValueMakeUndefined(context);
-        }
-
-        Converter converter(context);
-        return converter.toJSValueRef(item->getIsDetached());
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to get incorrect value");
-    }
-    return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItem::validate(JSContextRef ctx,
-        const JSObjectRef object,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    CalendarItemPrivObject *priv =
-        static_cast<CalendarItemPrivObject*>(JSObjectGetPrivate(object));
-    if (priv == NULL) {
-        return false;
-    }
-    CalendarEventPtr event = priv->getObject();
-    if (!event) {
-        return false;
-    }
-    return event->validate();
-}
-
-}
-}
-}
diff --git a/src/standards/Tizen/Calendar/JSCalendarItem.h b/src/standards/Tizen/Calendar/JSCalendarItem.h
deleted file mode 100755 (executable)
index d98f2de..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#ifndef _JS_CALENDAR_ITEM_H_
-#define _JS_CALENDAR_ITEM_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <API/Calendar/CalendarEvent.h>
-#include <CommonsJavaScript/PrivateObject.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Calendar {
-
-#define TIZEN_CALENDAR_ITEM_ID "id"
-#define TIZEN_CALENDAR_ITEM_LAST_MODIFICATION_DATE "lastModificationDate"
-#define TIZEN_CALENDAR_ITEM_IS_DETACHED "isDetached"
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarEventPtr,
-       WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemPrivObject;
-
-class JSCalendarItem
-{
-  public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static const JSClassRef getClassRef();
-
-    static TizenApis::Api::Calendar::CalendarEventPtr getPrivateObject(JSObjectRef object);
-
-    static void setPrivateObject(const TizenApis::Api::Calendar::CalendarEventPtr &event,
-            JSContextRef ctx,
-            const JSObjectRef object);
-
-       static JSObjectRef createJSCalendarItem(JSContextRef context, TizenApis::Api::Calendar::CalendarEventPtr item);
-
-    static bool validate(JSContextRef ctx,
-            const JSObjectRef object,
-            JSValueRef* exception);
-
-  private:
-    /**
-     * This member variable contains the values which has to be passed when
-     * the this class is embedded into JS Engine.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This member variable contains the initialization values for the
-     * properties of this class. The values are given according to the
-     * data structure JSPropertySpec.
-     */
-    static JSStaticValue m_property[];
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context,
-            JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    /**
-     * Getters and setters for properties
-     */
-    static JSValueRef getPropertyId(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-    static JSValueRef getPropertyLastModificationDate(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-    static JSValueRef getPropertyIsDetached(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-};
-
-}
-}
-}
-
-#endif /* _JS_CALENDAR_ITEM_H_ */
diff --git a/src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp b/src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp
deleted file mode 100755 (executable)
index 49f4f37..0000000
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "JSCalendarItemGeo.h"
-#include <dpl/log/log.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <CommonsJavaScript/Converter.h>
-
-using namespace TizenApis::Api::Calendar;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Calendar {
-
-#define TIZEN_CALENDAR_ITEM_GEO_ATTRIBUTENAME "CalendarItemGeo"
-
-JSClassDefinition JSCalendarItemGeo::m_classInfo = {
-    0,
-    kJSClassAttributeNone,
-    TIZEN_CALENDAR_ITEM_GEO_ATTRIBUTENAME,
-    0,
-    m_property,
-    NULL, //m_function,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL, //getProperty,
-    NULL, //setProperty,
-    NULL, //deleteProperty,
-    NULL, //getPropertyNames,
-    NULL, //callAsFunction,
-    NULL, //callAsConstructor,
-    NULL, //hasInstance,
-    NULL, //convertToType,
-};
-
-JSStaticValue JSCalendarItemGeo::m_property[] = {
-    { TIZEN_CALENDAR_ITEM_GEO_LATITUDE, getProperty, setProperty, kJSPropertyAttributeNone },
-    { TIZEN_CALENDAR_ITEM_GEO_LONGITUDE, getProperty, setProperty, kJSPropertyAttributeNone },
-    { 0, 0, 0, 0 }
-};
-
-JSClassRef JSCalendarItemGeo::m_jsClassRef = JSClassCreate(
-        JSCalendarItemGeo::getClassInfo());
-
-const JSClassDefinition* JSCalendarItemGeo::getClassInfo()
-{
-    return &(m_classInfo);
-}
-
-JSClassRef JSCalendarItemGeo::getClassRef()
-{
-    if (!m_jsClassRef) {
-        m_jsClassRef = JSClassCreate(&m_classInfo);
-    }
-    return m_jsClassRef;
-}
-
-CalendarItemGeoPtr JSCalendarItemGeo::getPrivateObject(JSObjectRef object)
-{
-    LogDebug("entered");
-    CalendarItemGeoPrivateObject *priv =
-        static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    CalendarItemGeoPtr result = priv->getObject();
-    if (!result) {
-        ThrowMsg(NullPointerException, "Private object is null");
-    }
-    return result;
-}
-
-void JSCalendarItemGeo::initialize(JSContextRef context,
-        JSObjectRef object)
-{
-    LogDebug("enter");
-}
-
-void JSCalendarItemGeo::finalize(JSObjectRef object)
-{
-    LogDebug("enter");
-    CalendarItemGeoPrivateObject* priv =
-        static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
-}
-
-JSObjectRef JSCalendarItemGeo::createJSCalendarItemGeo(JSContextRef context, CalendarItemGeoPtr geo)
-{
-    CalendarItemGeoPrivateObject *priv = new CalendarItemGeoPrivateObject(context, geo);
-    return JSObjectMake(context, getClassRef(), priv);
-}
-
-JSValueRef JSCalendarItemGeo::getProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef* exception)
-{
-    LogDebug("enter");
-    Converter converter(context);
-    Try
-    {
-        CalendarItemGeoPrivateObject* priv =
-            static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        CalendarItemGeoPtr geoInfo = priv->getObject();
-
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LATITUDE)) {
-            double latitude = geoInfo->getLatitude();
-            if( latitude==CalendarItemGeo::GEO_UNDEFINED ) {
-                return JSValueMakeUndefined(context);
-            } else {
-                return converter.toJSValueRef(geoInfo->getLatitude());
-            }
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LONGITUDE)) {
-            double longitude = geoInfo->getLongitude();
-            if( longitude==CalendarItemGeo::GEO_UNDEFINED ) {
-                return JSValueMakeUndefined(context);
-            } else {
-                return converter.toJSValueRef(geoInfo->getLongitude());
-            }
-        }
-    }
-    Catch(Exception)
-    {
-        LogError("invalid property");
-    }
-
-    return JSValueMakeUndefined(context);
-}
-
-bool JSCalendarItemGeo::setProperty(JSContextRef context,
-        JSObjectRef object,
-        JSStringRef propertyName,
-        JSValueRef value,
-        JSValueRef* exception)
-{
-    LogDebug("entered");
-    Converter converter(context);
-    Try
-    {
-        CalendarItemGeoPrivateObject* priv =
-            static_cast<CalendarItemGeoPrivateObject*>(JSObjectGetPrivate(object));
-        if (!priv) {
-            Throw(NullPointerException);
-        }
-        CalendarItemGeoPtr geoInfo = priv->getObject();
-
-        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LATITUDE)) {
-            if (!JSValueIsNumber(context, value)) {
-                Throw(InvalidArgumentException);
-            }
-            double latitude = converter.toDouble(value);
-            if( latitude>CalendarItemGeo::GEO_LATITUDE_MAX ) {
-                geoInfo->setLatitude(CalendarItemGeo::GEO_LATITUDE_MAX);
-            } else if( latitude<CalendarItemGeo::GEO_LATITUDE_MIN ) {
-                geoInfo->setLatitude(CalendarItemGeo::GEO_LATITUDE_MIN);
-            } else {
-                geoInfo->setLatitude(latitude);
-            }
-            return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ITEM_GEO_LONGITUDE)) {
-            if (!JSValueIsNumber(context, value)) {
-                Throw(InvalidArgumentException);
-            }
-            double longitude = converter.toDouble(value);
-            if( longitude>CalendarItemGeo::GEO_LONGITUDE_MAX ) {
-                geoInfo->setLongitude(CalendarItemGeo::GEO_LONGITUDE_MAX);
-            } else if( longitude<CalendarItemGeo::GEO_LONGITUDE_MIN ) {
-                geoInfo->setLongitude(CalendarItemGeo::GEO_LONGITUDE_MIN);
-            } else {
-                geoInfo->setLongitude(longitude);
-            }
-            return true;
-        }
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to set incorrect value");
-    }
-
-    TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-    return false;
-}
-
-}
-}
-}
diff --git a/src/standards/Tizen/Calendar/JSCalendarItemGeo.h b/src/standards/Tizen/Calendar/JSCalendarItemGeo.h
deleted file mode 100755 (executable)
index 7bdf35b..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef _JS_CALENDAR_ITEM_GEO_H_
-#define _JS_CALENDAR_ITEM_GEO_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Calendar/CalendarItemGeo.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-namespace Calendar {
-
-#define TIZEN_CALENDAR_ITEM_GEO_LATITUDE "latitude"
-#define TIZEN_CALENDAR_ITEM_GEO_LONGITUDE "longitude"
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::CalendarItemGeoPtr,
-                               WrtDeviceApis::CommonsJavaScript::NoOwnership> CalendarItemGeoPrivateObject;
-
-class JSCalendarItemGeo
-{
-  public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static JSClassRef getClassRef();
-
-    static TizenApis::Api::Calendar::CalendarItemGeoPtr getPrivateObject(JSObjectRef object);
-
-       static JSObjectRef createJSCalendarItemGeo(JSContextRef context, TizenApis::Api::Calendar::CalendarItemGeoPtr geo);
-
-  private:
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context, JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    static JSValueRef getProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef* exception);
-
-    static bool setProperty(JSContextRef context,
-            JSObjectRef object,
-            JSStringRef propertyName,
-            JSValueRef value,
-            JSValueRef* exception);
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This structure contains properties and callbacks that define a type of object.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This member variable contains the initialization values for the static properties of this class.
-     * The values are given according to the data structure JSPropertySpec
-     */
-    static JSStaticValue m_property[];
-};
-
-}
-}
-}
-
-#endif /* _JS_CALENDAR_ITEM_GEO_H_ */
index 7dba891..c3dffe6 100755 (executable)
@@ -25,6 +25,7 @@
 #include <Tizen/Common/SecurityExceptions.h>
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <Tizen/TimeUtil/JSTZDate.h>
+#include <Tizen/Tizen/JSSimpleCoordinates.h>
 #include <API/Calendar/EventAlarm.h>
 #include <API/Calendar/EventId.h>
 #include <API/Calendar/ICalendar.h>
@@ -36,8 +37,8 @@
 #include "JSCalendarAlarm.h"
 #include "JSCalendarRecurrenceRule.h"
 #include "JSCalendarAttendee.h"
-#include "JSCalendarItemGeo.h"
-#include "JSCalendarItem.h"
+#include "JSCalendarEvent.h"
+#include "JSCalendarTask.h"
 #include "plugin_config.h"
 
 using namespace TizenApis::Api::Calendar;
@@ -129,25 +130,26 @@ JSClassRef JSCalendarItemProperties::m_jsClassRef = JSClassCreate(JSCalendarItem
 void JSCalendarItemProperties::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("entered");
-    CalendarItemPropertiesPrivObject *priv =
-        static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        CalendarEventPtr privateData(new CalendarEvent());
-        priv = new CalendarItemPropertiesPrivObject(context, privateData);
-        JSObjectSetPrivate(object, static_cast<void*>(priv));
-        LogDebug("New CalendarItemPropertiesPrivObject is created.");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar item private object.");
+        CalendarEventPtr item( new CalendarEvent() );
+        CalendarItemPropertiesPrivObject *priv = new CalendarItemPropertiesPrivObject(context, item);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
     } else {
-        LogDebug("CalendarItemPropertiesPrivObject already exists.");
+        LogDebug("Private object alrerady set.");
     }
 }
 
 void JSCalendarItemProperties::finalize(JSObjectRef object)
 {
     LogDebug("entered");
-    CalendarItemPropertiesPrivObject *priv =
-        static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-    delete priv;
+    CalendarItemPropertiesPrivObject *priv = static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 const JSClassRef JSCalendarItemProperties::getClassRef()
@@ -216,32 +218,31 @@ JSValueRef JSCalendarItemProperties::convertToString(JSContextRef context,
 
     CalendarItemPropertiesPrivObject *privateObject =
         static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(),
-            CALENDAR_FUNCTION_API_CONVERT_TO_STRING);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CONVERT_TO_STRING);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
+        }
+
         CalendarEventPtr item = privateObject->getObject();
         if (!item) {
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
+        CalendarConverter converter(context);
 
-        if (!JSValueIsString(context, arguments[0])) {
+        CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT;
+        if (argumentCount>=1) {
+            format = converter.toVObjectFormat(converter.toString(arguments[0]));
+        } else {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
-        CalendarConverter converter(context);
-        format = converter.toVObjectFormat(converter.toString(arguments[0]));
-
         ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject();
         calendar->setType(item->getCalendarType());
 
@@ -254,7 +255,7 @@ JSValueRef JSCalendarItemProperties::convertToString(JSContextRef context,
         if (dplEvent->getResult()) {
             return converter.toJSValueRef(dplEvent->getEventString());
         } else {
-            ThrowMsg(UnknownException, "Converting to string failed by unkown reason.");
+            ThrowMsg(UnknownException, "Converting to string failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -297,26 +298,22 @@ JSValueRef JSCalendarItemProperties::clone(JSContextRef context,
 
     CalendarItemPropertiesPrivObject *privateObject =
         static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(),
-            CALENDAR_FUNCTION_API_CLONE);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_CLONE);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try
     {
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
+        }
+
         CalendarEventPtr item = privateObject->getObject(); // item to copy
         if (!item) {
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
 
-        JSContextRef globalContext = privateObject->getContext();
-
-        if (argumentCount>0) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
-
         // Call the copy constructor.
         CalendarEventPtr clonedItem( new CalendarEvent(*item));
 
@@ -324,7 +321,13 @@ JSValueRef JSCalendarItemProperties::clone(JSContextRef context,
         clonedItem->resetId();
         clonedItem->setRecurrenceId(0);
 
-        return JSCalendarItem::createJSCalendarItem(globalContext, clonedItem);
+               if (CalendarEvent::TASK_TYPE==clonedItem->getCalendarType()) {
+               return JSCalendarTask::createJSCalendarTask(context, clonedItem);
+               } else if (CalendarEvent::EVENT_TYPE==clonedItem->getCalendarType()) {
+               return JSCalendarEvent::createJSCalendarEvent(context, clonedItem);
+               } else {
+                       ThrowMsg(ConversionException, "Wrong object type.");
+               }
     }
     Catch(UnsupportedException)
     {
@@ -459,11 +462,15 @@ JSValueRef JSCalendarItemProperties::getPropertyStartTime(JSContextRef context,
     {
         CalendarItemPropertiesPrivObject *privateObject =
             static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-        TimeUtilConverter timeConverter(privateObject->getContext());
+        TimeUtilConverter timeConverter(context);
         CalendarEventPtr event = privateObject->getObject();
 
         LogInfo("start time before converted to TZDate: "<<event->getStartTime()<<", time zone: "<<event->getTimeZone());
-        return timeConverter.FromUTCTimeTToTZDate(event->getStartTime(), event->getTimeZone());
+        if (UNDEFINED_TIME==event->getStartTime()) {
+            return JSValueMakeNull(context);
+        } else {
+            return timeConverter.FromUTCTimeTToTZDate(event->getStartTime(), event->getTimeZone());
+        }
     }
     Catch(Exception)
     {
@@ -588,9 +595,8 @@ bool JSCalendarItemProperties::setPropertyCategories(JSContextRef context,
     Try
     {
         CalendarEventPtr event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        event->setCategories(converter->toCategories(value));
+        CalendarConverter converter(context);
+        event->setCategories(converter.toCategories(value));
         return true;
     }
     Catch(Exception)
@@ -610,11 +616,10 @@ JSValueRef JSCalendarItemProperties::getPropertyStatus(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        std::string status = converter->toTizenValue(event->getStatus());
-        return converter->toJSValueRef(status);
+        std::string status = converter.toTizenValue(event->getStatus());
+        return converter.toJSValueRef(status);
     }
     Catch(Exception)
     {
@@ -638,17 +643,15 @@ bool JSCalendarItemProperties::setPropertyStatus(JSContextRef context,
         }
 
         event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEvent::EventStatus status =
-            converter->toEventStatus(converter->toString(value));
+            converter.toEventStatus(converter.toString(value));
         event->setStatus(status);
         return true;
     }
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
-        event->setStatus(CalendarEvent::INVALID_STATUS);
         TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
@@ -663,12 +666,9 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarItemPropertiesPrivObject *priv =
-            static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-
         CalendarEventPtr event = getPrivateObject(object);
 
-        JSObjectRef jsResult = JSCreateArrayObject(priv->getContext(), 0, NULL);
+        JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
         if (NULL == jsResult) {
             ThrowMsg(NullPointerException, "Could not create js array object");
         }
@@ -684,7 +684,7 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
             alarm->setTimeZone(event->getTimeZone());
             alarm->setDescription(event->getAlarmsDescription().at(i));
 
-            if (!JSSetArrayElement(priv->getContext(), jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(priv->getContext(), alarm))) {
+            if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, alarm))) {
                ThrowMsg(UnknownException, "Could not insert value into js array");
             }
         }
@@ -708,10 +708,9 @@ bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context,
     Try
     {
         event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
 
-        EventAlarmListPtr alarms = converter->toVectorOfEventAlarmsFromReference(value);
+        EventAlarmListPtr alarms = converter.toVectorOfEventAlarmsFromReference(value);
         std::vector<CalendarEvent::EventAlarmType> alarmsType;
         std::vector<long> alarmsTick;
         std::vector<std::string> alarmsDescription;
@@ -818,11 +817,10 @@ JSValueRef JSCalendarItemProperties::getPropertyVisibility(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        std::string visibility = converter->toTizenValue(event->getVisibility());
-        return converter->toJSValueRef(visibility);
+        std::string visibility = converter.toTizenValue(event->getVisibility());
+        return converter.toJSValueRef(visibility);
     }
     Catch(Exception)
     {
@@ -846,17 +844,15 @@ bool JSCalendarItemProperties::setPropertyVisibility(JSContextRef context,
         }
 
         event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEvent::EventVisibility visibility =
-            converter->toEventVisibility(converter->toString(value));
+            converter.toEventVisibility(converter.toString(value));
         event->setVisibility(visibility);
         return true;
     }
     Catch(Exception)
     {
         LogError("Error during setting a value");
-        event->setVisibility(CalendarEvent::INVALID_VISIBILITY);
         TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
@@ -871,11 +867,11 @@ JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context
     LogDebug("entered");
     Try
     {
-        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        CalendarItemGeoPtr geoInfo = event->getGeolocation();
+        TizenApis::Api::Tizen::SimpleCoordinatesPtr geoLocation(
+            new TizenApis::Api::Tizen::SimpleCoordinates(event->getLatitude(), event->getLongitude()) );
 
-        return JSCalendarItemGeo::createJSCalendarItemGeo(context, geoInfo);
+        return TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::createJSObject(context, geoLocation);
     }
     Catch(Exception)
     {
@@ -892,12 +888,14 @@ bool JSCalendarItemProperties::setPropertyGeolocation(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    CalendarEventPtr event(NULL);
     Try
     {
-        event = getPrivateObject(object);
-        CalendarConverter converter(context);
-        event->setGeolocation(converter.toGeolocation(value));
+        CalendarEventPtr event = getPrivateObject(object);
+        TizenApis::Api::Tizen::SimpleCoordinatesPtr geoLocation =
+            TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getSimpleCoordinates(context, value);
+
+        event->setLatitude(geoLocation->getLatitude());
+        event->setLongitude(geoLocation->getLongitude());
         return true;
     }
     Catch(Exception)
@@ -918,11 +916,8 @@ JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context,
     Try
     {
         CalendarEventPtr event = getPrivateObject(object);
-        CalendarItemPropertiesPrivObject *priv =
-            static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
 
-        // Use the global context saved in the event struct.
-        TimeUtilConverter converter(priv->getContext());
+        TimeUtilConverter converter(context);
         long length = event->getEndTime() - event->getStartTime(); // in seconds only
         LogDebug("event->getStartTime():"<< event->getStartTime() << ", length:" << length);
         return converter.makeMillisecondDurationObject( length*1000 );
@@ -989,9 +984,17 @@ JSValueRef JSCalendarItemProperties::getPropertyRecurrenceRule(JSContextRef cont
             static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
 
         CalendarEventPtr event = getPrivateObject(object);
-        EventRecurrenceRulePtr rrule = event->getRecurrenceRule();
+        EventRecurrenceRulePtr rrule;
+        if (event->getIsDetached()) {
+            LogDebug("This is a detached event.");
+            return JSValueMakeUndefined(context);
+        } else {
+            rrule = event->getRecurrenceRule();
+        }
 
-        if (rrule) {
+        if (EventRecurrenceRule::NO_RECURRENCE==rrule->getFrequency()) {
+            return JSValueMakeUndefined(context);
+        } else {
             return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(priv->getContext(), rrule);
         }
     }
@@ -1013,6 +1016,10 @@ bool JSCalendarItemProperties::setPropertyRecurrenceRule(JSContextRef context,
     Try
     {
         event = getPrivateObject(object);
+        if (event->getIsDetached()) {
+            LogWarning("Can't set the recurrenceRule of a detached event!");
+            TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::NOT_SUPPORTED_ERROR);
+        }
         event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL)));
         return true;
     }
@@ -1033,10 +1040,9 @@ JSValueRef JSCalendarItemProperties::getPropertyIsAllDay(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        return converter->toJSValueRef(event->getIsAllDay());
+        return converter.toJSValueRef(event->getIsAllDay());
     }
     Catch(Exception)
     {
@@ -1079,11 +1085,10 @@ JSValueRef JSCalendarItemProperties::getPropertyAvailability(JSContextRef contex
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr event = getPrivateObject(object);
-        std::string availability = converter->toTizenValue(event->getAvailability());
-        return converter->toJSValueRef(availability);
+        std::string availability = converter.toTizenValue(event->getAvailability());
+        return converter.toJSValueRef(availability);
     }
     Catch(Exception)
     {
@@ -1107,17 +1112,15 @@ bool JSCalendarItemProperties::setPropertyAvailability(JSContextRef context,
         }
 
         event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEvent::EventAvailability availability =
-            converter->toEventAvailability(converter->toString(value));
+            converter.toEventAvailability(converter.toString(value));
         event->setAvailability(availability);
         return true;
     }
     Catch(Exception)
     {
         LogError("Error during setting a value");
-        event->setAvailability(CalendarEvent::INVALID_AVAILABILITY);
         TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
@@ -1132,18 +1135,15 @@ JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarItemPropertiesPrivObject *priv =
-            static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(object));
-
         CalendarEventPtr event = getPrivateObject(object);
         EventAttendeeListPtr attendees = event->getAttendees();
         if (attendees) {
-            JSObjectRef jsResult = JSCreateArrayObject(priv->getContext(), 0, NULL);
+            JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
             if (NULL == jsResult) {
                 ThrowMsg(NullPointerException, "Could not create js array object");
             }
             for(unsigned int i=0; i<attendees->size(); i++) {
-                if (!JSSetArrayElement(priv->getContext(), jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(priv->getContext(), attendees->at(i)))) {
+                if (!JSSetArrayElement(context, jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) {
                    ThrowMsg(UnknownException, "Could not insert value into js array");
                 }
             }
@@ -1167,9 +1167,8 @@ bool JSCalendarItemProperties::setPropertyAttendees(JSContextRef context,
     Try
     {
         CalendarEventPtr event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        event->setAttendees(converter->toVectorOfAttendeesFromReference(value));
+        CalendarConverter converter(context);
+        event->setAttendees(converter.toVectorOfAttendeesFromReference(value));
         return true;
     }
     Catch(Exception)
@@ -1198,11 +1197,11 @@ JSValueRef JSCalendarItemProperties::getPropertyDueDate(JSContextRef context,
         if (!task) {
             Throw(NullPointerException);
         }
-        if (task->getEndTime() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), task->getEndTime(), task->getTimeZone());
+
+        if (UNDEFINED_TIME==task->getEndTime()) {
+            return JSValueMakeNull(context);
         } else {
-            return JSValueMakeUndefined(context);
+            return JSTZDate::createJSObject(context, task->getEndTime(), task->getTimeZone());
         }
     }
     Catch(Exception)
@@ -1269,11 +1268,11 @@ JSValueRef JSCalendarItemProperties::getPropertyCompletedDate(JSContextRef conte
         if (!task) {
             Throw(NullPointerException);
         }
-        if (task->getEndTime() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), task->getCompletedDate(), task->getTimeZone());
+
+        if (UNDEFINED_TIME==task->getCompletedDate()) {
+            return JSValueMakeNull(context);
         } else {
-            return JSValueMakeUndefined(context);
+            return JSTZDate::createJSObject(context, task->getCompletedDate(), task->getTimeZone());
         }
     }
     Catch(Exception)
@@ -1386,19 +1385,14 @@ JSValueRef JSCalendarItemProperties::getPropertyPriority(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEventPtr item = getPrivateObject(object);
         if (!item) {
             Throw(NullPointerException);
         }
-        if(CalendarEvent::LOW_PRIORITY <= item->getPriority() ||
-            CalendarEvent::HIGH_PRIORITY >= item->getPriority()) {
-            return JSValueMakeUndefined(context);
-        }   
-            
-        std::string priority = converter->toTizenValue(item->getPriority());
-        return converter->toJSValueRef(priority);
+
+        std::string priority = converter.toTizenValue(item->getPriority());
+        return converter.toJSValueRef(priority);
     }
     Catch(Exception)
     {
@@ -1422,19 +1416,15 @@ bool JSCalendarItemProperties::setPropertyPriority(JSContextRef context,
             Throw(InvalidArgumentException);
         }
 
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
+        CalendarConverter converter(context);
         CalendarEvent::TaskPriority priority =
-            converter->toTaskPriority(converter->toString(value));
+            converter.toTaskPriority(converter.toString(value));
         item->setPriority(priority);
         return true;
     }
     Catch(Exception)
     {
         LogWarning("trying to set incorrect value");
-        if (item) {
-            item->setPriority(CalendarEvent::INVALID_PRIORITY);
-        }
         TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
     }
 
@@ -1458,11 +1448,11 @@ JSValueRef JSCalendarItemProperties::getPropertyEndDate(JSContextRef context,
         if (!event) {
             Throw(NullPointerException);
         }
-        if (event->getEndTime() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), event->getEndTime(), event->getTimeZone());
+
+        if (UNDEFINED_TIME==event->getEndTime()) {
+            return JSValueMakeNull(context);
         } else {
-            return JSValueMakeUndefined(context);
+            return JSTZDate::createJSObject(context, event->getEndTime(), event->getTimeZone());
         }
     }
     Catch(Exception)
index daf949a..5ce4f47 100755 (executable)
@@ -27,7 +27,6 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/SecurityExceptions.h>
 
-#include "JSCalendarItem.h"
 #include "JSCalendarManager.h"
 #include "JSCalendar.h"
 #include "CalendarConverter.h"
@@ -84,25 +83,26 @@ JSClassRef JSCalendarManager::m_jsClassRef = JSClassCreate(
 void JSCalendarManager::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("entered");
-    CalendarManagerPrivObject *privateObject =
-        static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(object));
-    if (NULL == privateObject) {
-        ICalendarManagerPtr calendarManager =
-            Api::Calendar::CalendarFactory::getInstance().createCalendarManagerObject();
-        privateObject = new CalendarManagerPrivObject(context, calendarManager);
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar manager private object.");
+        ICalendarManagerPtr calendarManager = CalendarFactory::getInstance().createCalendarManagerObject();
+        CalendarManagerPrivObject *privateObject = new CalendarManagerPrivObject(context, calendarManager);
         if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject))) {
             delete privateObject;
         }
+    } else {
+        LogDebug("Private object alrerady set.");
     }
 }
 
 void JSCalendarManager::finalize(JSObjectRef object)
 {
     LogDebug("entered");
-    CalendarManagerPrivObject *privateObject =
-        static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(object));
-    delete privateObject;
+    CalendarManagerPrivObject *priv = static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
@@ -112,46 +112,49 @@ JSValueRef JSCalendarManager::getCalendars(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
+    LogDebug("entered");
+
     CalendarManagerPrivObject *privateObject =
         static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-    if (NULL == privateObject) {
-        LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
-    }
 
-    JSContextRef globalContext = privateObject->getContext();
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_GET_CALENDARS);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDARS);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    CalendarConverter converter(context);
-
     Try {
-        if (argumentCount<2 || argumentCount>3) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
+        CalendarConverter converter(context);
+
+        JSContextRef globalContext = privateObject->getContext();
+
         JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
-        if (argumentCount > 2) {
-            cbm->setOnError(converter.toFunctionOrNull(arguments[2]));
+        CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE;
+        if (argumentCount>=1) {
+            calendarType = converter.toCalendarType(converter.toString(arguments[0]));
         }
-        cbm->setOnSuccess(converter.toFunction(arguments[1]));
 
-        CalendarEvent::CalendarType calendarType = CalendarEvent::EVENT_TYPE;
-        if (!JSValueIsString(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
-            calendarType = converter.toCalendarType(converter.toString(arguments[0]));
+        if (argumentCount>=2) {
+            cbm->setOnSuccess(converter.toFunction(arguments[1]));
+        }
+
+        if (argumentCount>=3) {
+            cbm->setOnError(converter.toFunctionOrNull(arguments[2]));
         }
 
+               // Protect the super object until the callback operation is finished.
+               JSValueProtect(globalContext, thisObject);
+
         IEventGetCalendarsPtr dplEvent(new IEventGetCalendars());
         dplEvent->setType(calendarType);
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
         privateObject->getObject()->getCalendars(dplEvent);
 
+        return JSValueMakeUndefined(context);
     }
     Catch(UnsupportedException)
     {
@@ -186,28 +189,24 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
 {
     CalendarManagerPrivObject *privateObject =
         static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-    if (NULL == privateObject) {
-        LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
-    }
-
-    JSContextRef globalContext = privateObject->getContext();
 
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try {
-        if (argumentCount!=1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        CalendarConverter converter(globalContext); // Needs global context for subsequent object creation. E.g., TZDate.
-        CalendarEvent::CalendarType calendarType = CalendarEvent::EVENT_TYPE;
-        if (!JSValueIsString(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
+        JSContextRef globalContext = privateObject->getContext();
+
+        CalendarConverter converter(globalContext);
+        CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE;
+        if (argumentCount>=1) {
             calendarType = converter.toCalendarType(converter.toString(arguments[0]));
+        } else {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         IEventGetDefaultCalendarPtr dplEvent(new IEventGetDefaultCalendar());
@@ -218,7 +217,7 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
         if (dplEvent->getResult()) {
             return converter.toJSValueRefCalendar(dplEvent->getCalendar());
         } else {
-            ThrowMsg(UnknownException, "Getting default calendar failed by unkown reason.");
+            ThrowMsg(UnknownException, "Getting default calendar failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -259,35 +258,27 @@ JSValueRef JSCalendarManager::getCalendar(JSContextRef context,
 {
     CalendarManagerPrivObject *privateObject =
         static_cast<CalendarManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-    if (NULL == privateObject) {
-        LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
-    }
 
-    JSContextRef globalContext = privateObject->getContext();
-
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_GET_CALENDAR);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(CALENDAR_FUNCTION_API_GET_CALENDAR);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try {
-        if (argumentCount!=2) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        if (!privateObject) {
+            ThrowMsg(ConversionException, "Object is null.");
         }
 
-        CalendarConverter converter(globalContext); // Needs global context for subsequent object creation. E.g., TZDate.
+        JSContextRef globalContext = privateObject->getContext();
 
-        CalendarEvent::CalendarType calendarType = CalendarEvent::EVENT_TYPE;
-        if (!JSValueIsString(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
+        CalendarConverter converter(globalContext);
+
+        CalendarEvent::CalendarType calendarType = CalendarEvent::UNDEFINED_TYPE;
+        if (argumentCount>=1) {
             calendarType = converter.toCalendarType(converter.toString(arguments[0]));
         }
 
         std::string calendarId;
-        if (!JSValueIsString(context, arguments[1])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else {
+        if (argumentCount>=2) {
             calendarId = converter.toString(arguments[1]);
         }
 
@@ -301,7 +292,7 @@ JSValueRef JSCalendarManager::getCalendar(JSContextRef context,
         if (dplEvent->getResult()) {
             return converter.toJSValueRefCalendar(dplEvent->getCalendar());
         } else {
-            ThrowMsg(UnknownException, "Getting calendar failed by unkown reason.");
+            ThrowMsg(UnknownException, "Getting calendar failed by unknown reason.");
         }
     }
     Catch(UnsupportedException)
index abb1c87..408e997 100755 (executable)
@@ -39,6 +39,10 @@ typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar
 #define TIZEN_CALENDAR_PROPERTY_NEEDS_ACTION_STATUS     "NEEDS_ACTION"
 #define TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS       "IN_PROCESS"
 #define TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS        "COMPLETED"
+#define TIZEN_CALENDAR_PROPERTY_PENDING_STATUS      "PENDING"
+#define TIZEN_CALENDAR_PROPERTY_ACCEPTED_STATUS     "ACCEPTED"
+#define TIZEN_CALENDAR_PROPERTY_DECLINED_STATUS     "DECLINED"
+#define TIZEN_CALENDAR_PROPERTY_DELEGATED_STATUS    "DELEGATED"
 
 #define TIZEN_CALENDAR_PROPERTY_HIGH_PRIORITY           "HIGH"
 #define TIZEN_CALENDAR_PROPERTY_MEDIUM_PRIORITY         "MEDIUM"
@@ -58,14 +62,6 @@ typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar
 #define TIZEN_CALENDAR_PROPERTY_NON_PARTICIPANT_ROLE    "NON_PARTICIPANT"
 #define TIZEN_CALENDAR_PROPERTY_CHAIR_ROLE              "CHAIR"
 
-#define TIZEN_CALENDAR_PROPERTY_PENDING_STATUS      "PENDING"
-#define TIZEN_CALENDAR_PROPERTY_ACCEPTED_STATUS     "ACCEPTED"
-#define TIZEN_CALENDAR_PROPERTY_DECLINED_STATUS     "DECLINED"
-#define TIZEN_CALENDAR_PROPERTY_TENTATIVE_STATUS    "TENTATIVE"
-#define TIZEN_CALENDAR_PROPERTY_DELEGATED_STATUS    "DELEGATED"
-#define TIZEN_CALENDAR_PROPERTY_COMPLETED_STATUS    "COMPLETED"
-#define TIZEN_CALENDAR_PROPERTY_IN_PROCESS_STATUS   "IN_PROCESS"
-
 #define TIZEN_CALENDAR_PROPERTY_INDIVIDUAL_TYPE     "INDIVIDUAL"
 #define TIZEN_CALENDAR_PROPERTY_GROUP_TYPE          "GROUP"
 #define TIZEN_CALENDAR_PROPERTY_RESOURCE_TYPE       "RESOURCE"
index d8f0ab7..f0002ef 100755 (executable)
@@ -92,16 +92,26 @@ JSObjectRef JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(JSContextRe
 
 void JSCalendarRecurrenceRule::initialize(JSContextRef context, JSObjectRef object)
 {
-    LogDebug("enter");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar rrule private object.");
+        EventRecurrenceRulePtr rrule( new EventRecurrenceRule() );
+        RecurrenceRulePrivateObject *priv = new RecurrenceRulePrivateObject(context, rrule);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    } else {
+        LogDebug("Private object alrerady set.");
+    }
 }
 
 void JSCalendarRecurrenceRule::finalize(JSObjectRef object)
 {
     LogDebug("enter");
-    RecurrenceRulePrivateObject* priv =
-        static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
-    delete priv;
-    JSObjectSetPrivate(object, NULL);
+    RecurrenceRulePrivateObject* priv = static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 EventRecurrenceRulePtr JSCalendarRecurrenceRule::getPrivateObject(JSObjectRef object)
@@ -150,38 +160,34 @@ JSObjectRef JSCalendarRecurrenceRule::constructor(JSContextRef context,
 
     Try
     {
-        RecurrenceRulePrivateObject* privateObject = static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(constructor));
-        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
-
-        CalendarConverter converter(globalContext);
+        CalendarConverter converter(context);
         EventRecurrenceRulePtr rrule;
 
-        if (argumentCount==1) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        if (argumentCount==0) {
+            EventRecurrenceRulePtr result( new EventRecurrenceRule());
+            rrule = result;
+        } else if (argumentCount==1) {
             EventRecurrenceRulePtr result( new EventRecurrenceRule());
             rrule = result;
             rrule->setFrequency(converter.toRecurrenceFrequency(converter.toString(arguments[0])));
-            if (!rrule) {
-                ThrowMsg(ConversionException, "Parameter conversion failed.");
-            }
-        } else if (argumentCount==2) {
-            if (!JSValueIsString(context, arguments[0])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
+        } else if (argumentCount>=2) {
+            if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) {
+                EventRecurrenceRulePtr result( new EventRecurrenceRule());
+                rrule = result;
+            } else {
+                if (!JSValueIsObject(context, arguments[1])) {
+                    ThrowMsg(ConversionException, "Wrong second parameter type.");
+                }
 
-            rrule = converter.toEventRecurrenceRule(arguments[1]);
-            if (!rrule) {
-                ThrowMsg(ConversionException, "Parameter conversion failed.");
+                rrule = converter.toEventRecurrenceRule(arguments[1]);
+                if (!rrule) {
+                    ThrowMsg(ConversionException, "Parameter conversion failed.");
+                }
             }
             rrule->setFrequency(converter.toRecurrenceFrequency(converter.toString(arguments[0])));
-        } else {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        return createJSCalendarRecurrenceRule(globalContext, rrule);
+        return createJSCalendarRecurrenceRule(context, rrule);
     }
     Catch(UnsupportedException)
     {
@@ -213,8 +219,7 @@ JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("enter");
-    CalendarConverterFactory::ConverterType converter =
-        CalendarConverterFactory::getConverter(context);
+    CalendarConverter converter(context);
     Try
     {
         RecurrenceRulePrivateObject* priv =
@@ -225,31 +230,35 @@ JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context,
         EventRecurrenceRulePtr rrule = priv->getObject();
 
         if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) {
-            return converter->toJSValueRef(converter->toTizenValue(rrule->getFrequency()));
+            return converter.toJSValueRef(converter.toTizenValue(rrule->getFrequency()));
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) {
-            return converter->toJSValueRef(rrule->getInterval());
+            return converter.toJSValueRef(rrule->getInterval());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
             if (!rrule) {
                 Throw(NullPointerException);
             }
-            if (rrule->getEndDate() != 0) {
-                // Use the global context saved in the event struct.
-                return JSTZDate::createJSObject(priv->getContext(), rrule->getEndDate(), rrule->getTimeZone());
+
+            if (UNDEFINED_TIME==rrule->getEndDate()) {
+                return JSValueMakeNull(context);
             } else {
-                return JSValueMakeUndefined(context);
+                //return JSTZDate::createJSObject(context, rrule->getEndDate(), rrule->getTimeZone());
+                               LogDebug("  endDate in JSrrule" << rrule->getEndDate());
+                               LogDebug("  timezone in JSrrule" << rrule->getTimeZone());
+                TimeUtilConverter timeConverter(context);
+                return timeConverter.FromUTCTimeTToTZDate(rrule->getEndDate(), rrule->getTimeZone());
             }
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT)) {
-            return converter->toJSValueRefLong(rrule->getOccurrenceCount());
-//        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
-//            return converter->toJSValueRef(rrule->getDaysOfTheMonth());
+            return converter.toJSValueRefLong(rrule->getOccurrenceCount());
+        //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
+            //return converter.toJSValueRef(rrule->getDaysOfTheMonth());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) {
-           return converter->toJSValueRef(rrule->getDaysOfTheWeek());
-//        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
-//            return converter->toJSValueRef(rrule->getDaysOfTheYear());
-//        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) {
-//            return converter->toJSValueRef(rrule->getWeeksOfTheYear());
+           return converter.toJSValueRef(rrule->getDaysOfTheWeek());
+        //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
+            //return converter.toJSValueRef(rrule->getDaysOfTheYear());
+        //} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) {
+            //return converter.toJSValueRef(rrule->getWeeksOfTheYear());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITION)) {
-            return converter->toJSValueRef(rrule->getSetPosition());
+            return converter.toJSValueRef(rrule->getSetPosition());
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
             JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
             if (NULL == jsResult) {
@@ -258,7 +267,7 @@ JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context,
             }
 
             for (std::size_t i = 0; i < rrule->getExceptions().size(); ++i) {
-                JSValueRef tmpVal = JSTZDate::createJSObject(priv->getContext(), rrule->getExceptions().at(i), rrule->getTimeZone());
+                JSValueRef tmpVal = JSTZDate::createJSObject(context, rrule->getExceptions().at(i), rrule->getTimeZone());
                 if (!JSSetArrayElement(context, jsResult, i, tmpVal)) {
                     LogError("Could not insert value into js array.");
                     ThrowMsg(UnknownException, "Could not insert value into js array");
@@ -282,8 +291,7 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
         JSValueRef* exception)
 {
     LogDebug("entered");
-    CalendarConverterFactory::ConverterType converter =
-        CalendarConverterFactory::getConverter(context);
+    CalendarConverter converter(context);
     Try
     {
         RecurrenceRulePrivateObject* priv =
@@ -297,14 +305,14 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
             if (!JSValueIsString(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            std::string frequency = converter->toString(value);
-            rrule->setFrequency(converter->toRecurrenceFrequency(frequency));
+            std::string frequency = converter.toString(value);
+            rrule->setFrequency(converter.toRecurrenceFrequency(frequency));
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) {
             if (!JSValueIsNumber(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            int interval = converter->toInt(value);
+            int interval = converter.toInt(value);
             rrule->setInterval(interval);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
@@ -314,44 +322,45 @@ bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
             TimeUtilConverter timeConverter(context);
             std::time_t untilDate = timeConverter.toTZDateTimeT(value);
             rrule->setEndDate(untilDate);
-
+/*
             if( rrule->getTimeZone().empty() ) {
                 std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
                 rrule->setTimeZone(timeZone);
             }
+*/
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT)) {
             if (!JSValueIsNumber(context, value)) {
                 Throw(InvalidArgumentException);
             }
-            long occurrenceCount = converter->toLong(value);
+            long occurrenceCount = converter.toLong(value);
             rrule->setOccurrenceCount(occurrenceCount);
             return true;
         /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
-            std::vector<int> daysOfTheMonth = converter->toVectorOfInts(value);
+            std::vector<int> daysOfTheMonth = converter.toVectorOfInts(value);
             rrule->setDaysOfTheMonth(daysOfTheMonth);
             return true;*/
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK)) {
-            std::vector<std::string> daysOfTheWeek = converter->toVectorOfStrings(value);
+            std::vector<std::string> daysOfTheWeek = converter.toVectorOfStrings(value);
             rrule->setDaysOfTheWeek(daysOfTheWeek);
             return true;
         /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
-            std::vector<int> daysOfTheYear = converter->toVectorOfInts(value);
+            std::vector<int> daysOfTheYear = converter.toVectorOfInts(value);
             rrule->setDaysOfTheYear(daysOfTheYear);
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR)) {
-            std::vector<int> weekOfTheYear = converter->toVectorOfInts(value);
+            std::vector<int> weekOfTheYear = converter.toVectorOfInts(value);
             rrule->setWeeksOfTheYear(weekOfTheYear);
             return true;*/
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITION)) {
             return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR);
             /*
-            bool setPosition = converter->toBool(value);
+            bool setPosition = converter.toBool(value);
             rrule->setSetPosition(setPosition);*/
             return true;
         } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
             // Only save the converted time info.
-            rrule->setExceptions(converter->toVectorOfTimeTFromTZDate(value));
+            rrule->setExceptions(converter.toVectorOfTimeTFromTZDate(value));
             return true;
         }
     }
index 659ab25..a4ca71d 100755 (executable)
@@ -48,7 +48,7 @@ JSClassDefinition JSCalendarTask::m_classInfo = {
     TIZEN_INTERFACE_CALENDAR_TASK,
     JSCalendarItemProperties::getClassRef(),
     m_property,
-    NULL, //    m_function,
+    NULL, //m_function,
     initialize,
     finalize,
     NULL, //hasProperty,
@@ -57,13 +57,13 @@ JSClassDefinition JSCalendarTask::m_classInfo = {
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
+    constructor,
     NULL, //HasInstance,
     NULL  //ConvertToType
 };
 
 JSStaticValue JSCalendarTask::m_property[] = {
-    //EventProperties
+    //Task properties
     { TIZEN_CALENDAR_TASK_ID, getPropertyId,
       NULL, kJSPropertyAttributeReadOnly },
     { TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
@@ -74,25 +74,36 @@ JSStaticValue JSCalendarTask::m_property[] = {
 
 JSClassRef JSCalendarTask::m_jsClassRef = JSClassCreate(JSCalendarTask::getClassInfo());
 
+ICalendarPtr JSCalendarTask::m_calendar = CalendarFactory::getInstance().createCalendarObject();
+
 void JSCalendarTask::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("entered");
-    CalendarTaskPrivObject *priv =
-        static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
-    if (!priv) {
-        CalendarEventPtr privateData(new CalendarEvent());
-        priv = new CalendarTaskPrivObject(context, privateData);
-        JSObjectSetPrivate(object, static_cast<void*>(priv));
-        LogDebug("new event is created");
+    if (!JSObjectGetPrivate(object)) {
+        LogDebug("Create calendar task private object.");
+        CalendarEventPtr task( new CalendarEvent() );
+        CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(context, task);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
     } else {
-        LogDebug("private object already exists");
+        LogDebug("Private object alrerady set.");
+    }
+
+    if (m_calendar) {
+        m_calendar->setType(CalendarEvent::TASK_TYPE);
+        LogDebug("Calendar object type is set to task.");
     }
 }
 
 void JSCalendarTask::finalize(JSObjectRef object)
 {
     LogDebug("entered");
+    CalendarTaskPrivObject* priv = static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) {
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
 }
 
 JSObjectRef JSCalendarTask::constructor(JSContextRef context,
@@ -105,51 +116,53 @@ JSObjectRef JSCalendarTask::constructor(JSContextRef context,
 
     Try
     {
-               CalendarTaskPrivObject* privateObject = static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(constructor));
-               JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
-
-        CalendarConverter converter(globalContext);
+        CalendarConverter converter(context);
         CalendarEventPtr task;
 
         if (argumentCount==0) {
             CalendarEventPtr result(new CalendarEvent());
             task = result;
-        } else if (argumentCount==1) { // eventInitDict case
-            task = converter.toEvent(arguments[0]);
-            if (!task) {
+        } else if (argumentCount==1) {
+            LogInfo("taskInitDict case");
+            if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
+                CalendarEventPtr result(new CalendarEvent());
+                task = result;
+            } else if (JSValueIsObject(context, arguments[0])) {
+                task = converter.toEvent(arguments[0]);
+                if (!task) {
+                    ThrowMsg(ConversionException, "Parameter conversion failed.");
+                }
+            } else {
                 ThrowMsg(ConversionException, "Parameter conversion failed.");
             }
-        } else if (argumentCount==2) { // stringRepresentation case
-            if (!JSValueIsString(context, arguments[0]) || !JSValueIsString(context, arguments[1])) {
-                ThrowMsg(ConversionException, "Wrong parameter type.");
-            }
-
+        } else if (argumentCount>=2) {
+            LogInfo("task stringRepresentation case");
             std::string eventStr;
-            CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
+            CalendarEvent::VObjectFormat format = CalendarEvent::UNDEFINED_FORMAT;
             eventStr = converter.toString(arguments[0]);
             format = converter.toVObjectFormat(converter.toString(arguments[1]));
 
-            ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject();
-            calendar->setType(CalendarEvent::TASK_TYPE);
-
             IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString());
             dplEvent->setEventString(eventStr);
             dplEvent->setFormat(format);
             dplEvent->setForSynchronousCall();
-            calendar->createEventFromString(dplEvent);
+            m_calendar->createEventFromString(dplEvent);
 
             // Process the returned object.
             if (dplEvent->getResult()) {
-                LogInfo("Successfully created an item.");
+                LogInfo("Successfully created a task.");
                 task = dplEvent->getEvent();
             } else {
-                ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
+                if (dplEvent->getExceptionCode()==ExceptionCodes::InvalidArgumentException) {
+                    ThrowMsg(InvalidArgumentException, "Wrong string to convert.");
+                } else {
+                    ThrowMsg(UnknownException, "Converting string failed.");
+                }
             }
-        } else {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        return createJSCalendarTask(globalContext, task);
+        task->setCalendarType(CalendarEvent::TASK_TYPE);
+        return createJSCalendarTask(context, task);
     }
     Catch(UnsupportedException)
     {
@@ -226,7 +239,7 @@ void JSCalendarTask::setPrivateObject(const CalendarEventPtr &event,
     }
     Catch(Exception)
     {
-        LogError("Error during replacing event object");
+        LogError("Error during replacing task object");
     }
 }
 
@@ -242,7 +255,11 @@ JSValueRef JSCalendarTask::getPropertyId(JSContextRef context,
             static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
         CalendarEventPtr task = privateObject->getObject();
 
-        return Converter(context).toJSValueRef(task->getUId());
+        if (task->getUId()==UNDEFINED_ID) {
+            return JSValueMakeUndefined(context);
+        } else {
+            return Converter(context).toJSValueRef(task->getUId());
+        }
     }
     Catch(Exception)
     {
@@ -262,15 +279,14 @@ JSValueRef JSCalendarTask::getPropertyLastModificationDate(JSContextRef context,
         CalendarTaskPrivObject *privateObject =
             static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
         CalendarEventPtr task = privateObject->getObject();
-
         if (!task) {
             Throw(NullPointerException);
         }
-        if (task->getLastModifiedDate() != 0) {
-            // Use the global context saved in the event struct.
-            return JSTZDate::createJSObject(privateObject->getContext(), task->getLastModifiedDate(), task->getTimeZone());
+
+        if (UNDEFINED_TIME==task->getLastModifiedDate()) {
+            return JSValueMakeNull(context);
         } else {
-            return JSValueMakeUndefined(context);
+            return JSTZDate::createJSObject(context, task->getLastModifiedDate(), task->getTimeZone());
         }
     }
     Catch(Exception)
index 385274f..0892f5a 100755 (executable)
@@ -75,6 +75,11 @@ class JSCalendarTask
 
     static JSClassRef m_jsClassRef;
 
+       /**
+        * The calendar object to be used for asynchronous platform function invocation.
+        */
+       static TizenApis::Api::Calendar::ICalendarPtr m_calendar;
+
     /**
      * The callback invoked when an object is first created.
      */
index 1c33631..d8784bd 100755 (executable)
@@ -197,17 +197,6 @@ static FunctionMapping createCalendarFunctions()
                                CALENDAR_FUNCTION_API_REMOVE_BATCH,
                                removeBatchFunc));
 
-    //convertFromString
-    /*AceFunction convertFromStringFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_CONVERT_FROM_STRING,
-            CALENDAR_FUNCTION_API_CONVERT_FROM_STRING,
-            CALENDAR_FEATURES_CALENDAR_READ_WRITE,
-            DEVICE_LIST_CALENDAR_READ);
-
-    calendarMapping.insert(std::make_pair(
-                               CALENDAR_FUNCTION_API_CONVERT_FROM_STRING,
-                               convertFromStringFunc));*/
-
     //convertToString
     AceFunction convertToStringFunc = ACE_CREATE_FUNCTION(
             FUNCTION_CONVERT_TO_STRING,
index af6194b..8354233 100755 (executable)
@@ -38,7 +38,6 @@ namespace Calendar {
 #define CALENDAR_FUNCTION_API_REMOVE "remove"
 #define CALENDAR_FUNCTION_API_REMOVE_BATCH "removeBatch"
 #define CALENDAR_FUNCTION_API_FIND "find"
-#define CALENDAR_FUNCTION_API_CONVERT_FROM_STRING "convertFromString"
 #define CALENDAR_FUNCTION_API_CONVERT_TO_STRING "convertToString"
 #define CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER "addChangeListener"
 #define CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener"
@@ -48,12 +47,10 @@ namespace Calendar {
 
 DECLARE_FUNCTION_GETTER(Calendar);
 
-#define CALENDAR_CHECK_ACCESS(globalContext, functionName)                     \
-    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
-        getCalendarFunctionData,           \
-        functionName)
-
+#define CALENDAR_CHECK_ACCESS(functionName) \
+       aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+       getCalendarFunctionData, \
+       functionName)
 }
 }
 }
index 87360e2..386c9a1 100755 (executable)
@@ -18,7 +18,7 @@
 #include <dpl/log/log.h>
 
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <Commons/Exception.h>
 #include "JSCalendarManager.h"
 #include "JSCalendarEvent.h"
@@ -32,16 +32,29 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
-void on_widget_start_callback(int widgetId,
-        JavaScriptContext context,
-        const engine_interface_t *interface)
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\Calendar] on_widget_start_callback (" << widgetId << ")");
+
+       Try {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+       } Catch (Commons::Exception) {
+               LogError("WrtAccess initialization failed");
+       }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
     LogDebug("[Tizen\\Calendar] on_widget_stop_callback (" << widgetId << ")");
+
+       Try {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+       } Catch (Commons::Exception) {
+               LogError("WrtAccess deinitialization failed");
+       }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
@@ -58,7 +71,7 @@ PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
                NULL)
 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         TIZEN_INTERFACE_CALENDAR_TASK,
-        JSCalendarEvent::getClassRef(),
+        JSCalendarTask::getClassRef(),
         NULL)
 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         TIZEN_INTERFACE_CALENDAR_ATTENDEE,
index 85837c1..5be6629 100755 (executable)
@@ -1,51 +1,38 @@
 set(TARGET_NAME "wrt-plugins-tizen-1.0-call")
+set(DESTINATION_NAME  "tizen-1.0-call")
 
 include_directories(${INCLUDES_PLATFORM_IMPLEMENTATION_CALL})
 
 set(CMAKE_INSTALL_RPATH
   ${CMAKE_INSTALL_RPATH}
   ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
-  #${CMAKE_INSTALL_PREFIX}/tizen-1.0-account
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-contact
 )
 
-set(SRCS 
+set(SRCS
   ${SRCS_PLATFORM_API_CALL}
   ${SRCS_PLATFORM_IMPLEMENTATION_CALL}
+  CallAsyncEventPrivateData.cpp
   CallMultiCallback.cpp
   CallStaticController.cpp
   Converter.cpp
   JSCallHistory.cpp
   JSCallHistoryEntry.cpp
   JSCallManager.cpp
-  JSCallService.cpp
-  JSCellularCallService.cpp
   JSRemoteParty.cpp
   plugin_config.cpp
   plugin_initializer.cpp
   ResponseDispatcher.cpp
-
-  # To be removed after account module activated
-  ${SRCS_PLATFORM_API_ACCOUNT}
-  ${SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT}
-  ../Account/JSAccount.cpp
-  ../Account/JSAccountServices.cpp
-  ../Account/JSAccountServiceType.cpp
-  ../Account/JSAccountServiceProvider.cpp
-  ../Account/JSAccountManager.cpp
-  ../Account/JSFeatureArray.cpp
-  ../Account/AccountConverter.cpp
-  ../Account/plugin_config.cpp
-  ../Account/ResponseDispatcher.cpp
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
 target_link_libraries(${TARGET_NAME}
   wrt-plugins-tizen-1.0-tizen-impl
-  #wrt-plugins-tizen-1.0-account-impl
+  wrt-plugins-tizen-1.0-contact-impl
   ${LIBS_COMMON}
   ${LIBS_PLATFORM_IMPLEMENTATION_CALL}
 )
 
-INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION tizen-1.0-call)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION tizen-1.0-call)
+INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
 
similarity index 61%
rename from src/platform/API/Call/EventSendUSSD.cpp
rename to src/standards/Tizen/Call/CallAsyncEventPrivateData.cpp
index c945eda..f6ab62b 100755 (executable)
  * limitations under the License. 
  */
 
-#include "EventSendUSSD.h"
+#include "CallAsyncEventPrivateData.h"
+
 
 namespace TizenApis {
-namespace Api {
-namespace Call {
-EventSendUSSD::EventSendUSSD()
-{
-}
+namespace Tizen1_0 {
 
-void EventSendUSSD::setCommand(const std::string command)
+CallAsyncEventPrivateData::CallAsyncEventPrivateData(
+                       const JSCallbackManagerPtr& callbackManager, JSObjectRef object) :
+                       m_callbackManager(callbackManager), m_object(object)
 {
-       m_command = command;
 }
 
-void EventSendUSSD::setResult(const std::string result)
+JSCallbackManagerPtr CallAsyncEventPrivateData::getCallbackManager() const
 {
-       m_result = result;
+       return m_callbackManager;
 }
 
-
-std::string EventSendUSSD::getCommand() const
+JSObjectRef CallAsyncEventPrivateData::getObject() const
 {
-       return m_command;
+       return m_object;
 }
 
-std::string EventSendUSSD::getResult() const
-{
-       return m_result;
-}
 }
 }
-}
\ No newline at end of file
+
similarity index 51%
rename from src/platform/API/Call/EventLaunchDialer.h
rename to src/standards/Tizen/Call/CallAsyncEventPrivateData.h
index 877bd68..44f932c 100755 (executable)
  * limitations under the License. 
  */
 
+#ifndef TIZENAPIS_TIZEN_CALL_ASYNC_EVENT_PRIVATE_DATA_H_
+#define TIZENAPIS_TIZEN_CALL_ASYNC_EVENT_PRIVATE_DATA_H_
 
-#ifndef TIZENAPIS_API_CALL_EVENT_LAUNCHDIALER_H_
-#define TIZENAPIS_API_CALL_EVENT_LAUNCHDIALER_H_
-
-#include <string>
-#include <Commons/IEvent.h>
 #include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <JavaScriptCore/JavaScript.h>
+
+using namespace WrtDeviceApis::CommonsJavaScript;
 
 namespace TizenApis {
-namespace Api {
-namespace Call {
-class EventLaunchDialer : public WrtDeviceApis::Commons::IEvent<EventLaunchDialer>
-{
-private:
-       std::string m_remoteParty;
-       std::string m_extension;
-       std::string m_appId;
+namespace Tizen1_0 {
 
+class CallAsyncEventPrivateData : public WrtDeviceApis::Commons::IEventPrivateData
+{
 public:
-       void setRemoteParty(const std::string remoteParty);
-       void setExtension(const std::string extension);
-       void setAppId(const std::string appId);
-       std::string getRemoteParty() const;
-       std::string getExtension() const;
-       std::string getAppId() const;
-
-       EventLaunchDialer();
+       CallAsyncEventPrivateData(const JSCallbackManagerPtr& callbackManager,
+                       JSObjectRef object);
+
+       JSCallbackManagerPtr getCallbackManager() const;
+       JSObjectRef getObject() const;
+
+private:
+       JSCallbackManagerPtr m_callbackManager;
+       JSObjectRef m_object;
 };
 
-typedef DPL::SharedPtr<EventLaunchDialer> EventLaunchDialerPtr;
-}
+typedef DPL::SharedPtr<CallAsyncEventPrivateData> CallAsyncEventPrivateDataPtr;
+
 }
 }
 
-#endif
\ No newline at end of file
+#endif
index f43cfde..e4bfdce 100755 (executable)
@@ -46,9 +46,13 @@ void CallStaticController::onAnswerReceived(const EventCallHistoryListenerPtr& e
        EventCallHistoryListenerPrivateDataPtr multiCallbacks = 
                DPL::DynamicPointerCast<EventCallHistoryListenerPrivateData>(event->getPrivateData());
 
-       assert(multiCallbacks != NULL);
-       assert(multiCallbacks->getOnAdded() != NULL);
-       assert(multiCallbacks->getOnChanged() != NULL);
+       if (multiCallbacks == NULL) {
+               return;
+       }
+
+       if ((multiCallbacks->getOnAdded() == NULL)  || (multiCallbacks->getOnChanged() == NULL)) {
+               return; 
+       }
 
        JSCallbackManagerPtr defaultCbm = multiCallbacks->getOnAdded(); 
        JSContextRef context = defaultCbm->getContext();
@@ -66,7 +70,7 @@ void CallStaticController::onAnswerReceived(const EventCallHistoryListenerPtr& e
                        break;                  
                }
        } catch(ConversionException) {
-               LogError(       "Conversion exception while processing EventCallHistoryListener");
+               LogError("Conversion exception while processing EventCallHistoryListener");
        }
 }
 
index 2a7535c..4ecdd83 100755 (executable)
@@ -26,8 +26,6 @@
 #include <API/Call/CallDefine.h>
 #include "JSCallHistoryEntry.h"
 #include "JSRemoteParty.h"
-#include "JSCallService.h"
-#include "JSCellularCallService.h"
 
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
@@ -36,9 +34,6 @@ using namespace TizenApis::Api::Call;
 
 namespace TizenApis {
 namespace Tizen1_0 {
-std::vector<std::string> Converter::m_allowedCallHistoryEntryProperties;
-std::vector<std::string> Converter::m_allowedRemoteParty;
-std::vector<std::string> Converter::m_allowedCallServiceFilter;
 
 Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context)
 {
@@ -46,24 +41,24 @@ Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::C
        (void) init;
 }
 
-std::vector<unsigned long> Converter::toVectorOfULongs(const JSValueRef& arg)
+std::vector<unsigned long> Converter::toVectorOfULongs(const JSValueRef& jsValue)
 {
-    return toVectorOfT_(arg, &Converter::toULong);
+    return toVectorOfT_(jsValue, &Converter::toULong);
 }
 
-CallHistoryEntryList Converter::toVectorOfCallHistoryEntryProperties(const JSValueRef& arg)
+CallHistoryEntryList Converter::toVectorOfCallHistoryEntryProperties(const JSValueRef& jsValue)
 {
-       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
-               ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
+       if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) {
+               ThrowMsg(Commons::ConversionException, "Undefined history entry");
        }
 
-       if (!JSIsArrayValue(m_context, arg)) {
+       if (!JSIsArrayValue(m_context, jsValue)) {
                ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
        }
 
        try {
                CallHistoryEntryList result;
-               JSObjectRef objArg = toJSObjectRef(arg);
+               JSObjectRef objArg = toJSObjectRef(jsValue);
                for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); ++i) {
                        JSValueRef element = JSGetArrayElement(m_context, objArg, i);
                        result.push_back(toCallHistoryEntryProperties(element));
@@ -91,8 +86,12 @@ StringArrayPtr Converter::toStringArray(const JSValueRef &jsValue)
                                result->push_back(toString(element));
                        }
                }
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::InvalidArgumentException& ex) {
+               ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage());
        } catch (Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
        return result;
 }
@@ -109,254 +108,73 @@ RemotePartyListPtr Converter::toRemotePartyList(const JSValueRef &jsValue)
                                result->push_back(toRemoteParty(element));
                        }
                }
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::InvalidArgumentException& ex) {
+               ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage());
        } catch (Commons::Exception& ex) {
-               LogError("Exception: " << ex.GetMessage());
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
        return result;
 }
 
 RemotePartyPtr Converter::toRemoteParty(const JSValueRef &jsValue)
 {
-       Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedRemoteParty, jsValue)) {
-               ThrowMsg(Commons::InvalidArgumentException, "Wrong attribute of RemoteParty");
-       }
-
-       const ScopedJSStringRef remotePartyStr(JSStringCreateWithUTF8CString(STR_REMOTE_PARTY));
-       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString(STR_DISPLAY_NAME));
-       const ScopedJSStringRef contactIdStr(JSStringCreateWithUTF8CString(STR_CONTACT_ID));
-
-       JSObjectRef jsObject = toJSObjectRef(jsValue);
-
-       JSValueRef jRemoteParty = JSObjectGetProperty(m_context, jsObject, remotePartyStr.get(), NULL);
-       JSValueRef jDisplayName = JSObjectGetProperty(m_context, jsObject, displayNameStr.get(), NULL);
-       JSValueRef jContactId = JSObjectGetProperty(m_context, jsObject, contactIdStr.get(), NULL);
-
-       std::string remoteParty;
-       std::string displayName;
-       std::string contactId;
-
-       RemotePartyPtr result(new RemoteParty());
-
-       if (!result) {
-               Throw(Commons::ConversionException);
-       }
-
-       if (!JSValueIsUndefined(m_context, jRemoteParty)) {
-               remoteParty = toString(jRemoteParty);
-               result->setRemoteParty(remoteParty);
-       }
-
-       if (!JSValueIsUndefined(m_context, jDisplayName)) {
-               displayName = toString(jDisplayName);
-               result->setDisplayName(displayName);
-       }
-
-       if (!JSValueIsUndefined(m_context, jContactId)) {
-               contactId = toString(jContactId);
-               result->setContactId(contactId);
+       try {
+               return JSRemoteParty::getRemoteParty(m_context, jsValue);
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::Exception& ex) {
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
-
-       return result;
 }
 
-CallServiceFilterPtr Converter::toCallServiceFilter(const JSValueRef &jsValue)
+CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSValueRef &jsValue)
 {
-       Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedCallServiceFilter, jsValue)) {
-               ThrowMsg(Commons::InvalidArgumentException, "Wrong attribute of call service filter");
-       }
-
-       const ScopedJSStringRef callTypeStr(JSStringCreateWithUTF8CString(STR_CALL_TYPE));
-       const ScopedJSStringRef tagsStr(JSStringCreateWithUTF8CString(STR_TAGS));
-       const ScopedJSStringRef serviceNameStr(JSStringCreateWithUTF8CString(STR_SERVICE_NAME));
-       const ScopedJSStringRef providerIdStr(JSStringCreateWithUTF8CString(STR_PROVIDER_ID));
-
-       JSObjectRef jsObject = toJSObjectRef(jsValue);
-
-       JSValueRef jCallType = JSObjectGetProperty(m_context, jsObject, callTypeStr.get(), NULL);
-       JSValueRef jTags = JSObjectGetProperty(m_context, jsObject, tagsStr.get(), NULL);
-       JSValueRef jServiceName = JSObjectGetProperty(m_context, jsObject, serviceNameStr.get(), NULL);
-       JSValueRef jProviderId = JSObjectGetProperty(m_context, jsObject, providerIdStr.get(), NULL);
-
-       std::string callType;
-       StringArrayPtr tags(new StringArray());
-       std::string serviceName;
-       std::string providerId;
-
-       CallServiceFilterPtr result(new CallServiceFilter());
-
-       if (!result) {
-               Throw(Commons::ConversionException);
-       }
-
-       if (!JSValueIsUndefined(m_context, jCallType)) {
-               callType = toString(jCallType);
-               result->setCallType(callType);
-       }
-
-       if (!JSValueIsUndefined(m_context, jProviderId)) {
-               providerId = toString(jProviderId);
-               result->setProviderId(providerId);
+       try {
+               return JSCallHistoryEntry::getCallHistoryEntry(m_context, jsValue);
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::Exception& ex) {
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
-
-       return result;
 }
 
-CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSValueRef &jsValue)
+EventCallHistoryListenerPrivateDataPtr 
+       Converter::toEventCallHistoryListenerPrivateData(const JSValueRef &jsValue, JSContextRef context)
 {
-       Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedCallHistoryEntryProperties, jsValue)) {
-               ThrowMsg(Commons::InvalidArgumentException, "Wrong attribute of call history entry");
-       }
-
-       const ScopedJSStringRef entryIdStr(JSStringCreateWithUTF8CString(STR_ENTRY_ID));
-       const ScopedJSStringRef serviceIdStr(JSStringCreateWithUTF8CString(STR_SERVICE_ID));
-       const ScopedJSStringRef callTypeStr(JSStringCreateWithUTF8CString(STR_CALL_TYPE));
-       const ScopedJSStringRef tagsStr(JSStringCreateWithUTF8CString(STR_TAGS));
-       const ScopedJSStringRef remotePartiesStr(JSStringCreateWithUTF8CString(STR_REMOTE_PARTIES));
-       const ScopedJSStringRef forwardedFromStr(JSStringCreateWithUTF8CString(STR_FORWARDEDFROM));
-       const ScopedJSStringRef startTimeStr(JSStringCreateWithUTF8CString(STR_START_TIME));
-       const ScopedJSStringRef durationStr(JSStringCreateWithUTF8CString(STR_DURATION));
-       const ScopedJSStringRef endReasonStr(JSStringCreateWithUTF8CString(STR_END_REASON));
-       const ScopedJSStringRef directionStr(JSStringCreateWithUTF8CString(STR_DIRECTION));
-       const ScopedJSStringRef recordingStr(JSStringCreateWithUTF8CString(STR_RECORDING));
-       const ScopedJSStringRef costStr(JSStringCreateWithUTF8CString(STR_COST));
-       const ScopedJSStringRef currencyStr(JSStringCreateWithUTF8CString(STR_CURRENCY));
-
-       JSObjectRef jsObject = toJSObjectRef(jsValue);
-
-       JSValueRef jEntryId = JSObjectGetProperty(m_context, jsObject, entryIdStr.get(), NULL);
-       JSValueRef jServiceId = JSObjectGetProperty(m_context, jsObject, serviceIdStr.get(), NULL);
-       JSValueRef jCallType = JSObjectGetProperty(m_context, jsObject, callTypeStr.get(), NULL);
-       JSValueRef jTags = JSObjectGetProperty(m_context, jsObject, tagsStr.get(), NULL);
-       JSValueRef jRemoteParties = JSObjectGetProperty(m_context, jsObject, remotePartiesStr.get(), NULL);
-       JSValueRef jForwardedFrom = JSObjectGetProperty(m_context, jsObject, forwardedFromStr.get(), NULL);
-       JSValueRef jStartTime = JSObjectGetProperty(m_context, jsObject, startTimeStr.get(), NULL);
-       JSValueRef jDuration = JSObjectGetProperty(m_context, jsObject, durationStr.get(), NULL);
-       JSValueRef jEndReason = JSObjectGetProperty(m_context, jsObject, endReasonStr.get(), NULL);
-       JSValueRef jDirection = JSObjectGetProperty(m_context, jsObject, directionStr.get(), NULL);
-       JSValueRef jRecording = JSObjectGetProperty(m_context, jsObject, recordingStr.get(), NULL);
-       JSValueRef jCost = JSObjectGetProperty(m_context, jsObject, costStr.get(), NULL);
-       JSValueRef jCurrency = JSObjectGetProperty(m_context, jsObject, currencyStr.get(), NULL);
-
-       unsigned long entryId;
-       std::string serviceId;
-       std::string callType;
-       StringArrayPtr tags;
-       RemotePartyListPtr remoteParties;
-       RemotePartyPtr forwardedFrom;
-       time_t startTime;
-       unsigned long duration;
-       std::string endReason;
-       std::string direction;
-       StringArrayPtr recording;
-       unsigned long cost;
-       std::string currency;
-
-       CallHistoryEntryPropertiesPtr result = CallHistoryEntryPropertiesPtr(new CallHistoryEntryProperties());
-
-       if (!result) {
-               Throw(Commons::ConversionException);
-       }
-
-       if (!JSValueIsUndefined(m_context, jEntryId)) {
-               entryId = toULong(jEntryId);
-               result->setEntryId(entryId);
-       } else {
-               ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
-       }
-
-       if (!JSValueIsUndefined(m_context, jServiceId)) {
-               serviceId = toString(jServiceId);
-               result->setServiceId(serviceId);
-       }
-
-       if (!JSValueIsUndefined(m_context, jCallType)) {
-               callType = toString(jCallType);
-               result->setCallType(callType);
-       }
-
-       if (!JSValueIsUndefined(m_context, jTags)) {
-               tags = toStringArray(jTags);
-               result->setTags(tags);
-       }
-
-       if (!JSValueIsUndefined(m_context, jRemoteParties)) {
-               remoteParties = toRemotePartyList(jRemoteParties);
-               result->setRemoteParties(remoteParties);
-       } else {
-               ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
-       }
-
-       if (!JSValueIsUndefined(m_context, jForwardedFrom)) {
-               forwardedFrom = toRemoteParty(jForwardedFrom);
-               result->setForwardedFrom(forwardedFrom);
-       }
-
-       if (!JSValueIsUndefined(m_context, jStartTime)) {
-               startTime = toDateTimeT(jStartTime);
-               result->setStartTime(startTime);
-       }
-
-       if (!JSValueIsUndefined(m_context, jDuration)) {
-               duration = toULong(jDuration);
-               result->setDuration(duration);
-       }
-
-       if (!JSValueIsUndefined(m_context, jEndReason)) {
-               endReason = toString(jEndReason);
-               result->setEndReason(endReason);
+       if (JSValueIsNull(m_context, jsValue) || JSValueIsUndefined(m_context, jsValue)) {
+               ThrowMsg(Commons::ConversionException, "Type missmatch error : Listener callback is null or undefined");
        }
-
-       if (!JSValueIsUndefined(m_context, jDirection)) {
-               direction = toString(jDirection);
-               result->setDirection(direction);
+       if (!JSValueIsObject(m_context, jsValue) || JSObjectIsFunction(m_context, toJSObjectRef(jsValue))) {
+               ThrowMsg(Commons::ConversionException, "Type missmatch error : Listener callback");
        }
 
-       if (!JSValueIsUndefined(m_context, jRecording)) {
-               recording = toStringArray(jRecording);
-               result->setRecording(recording);
-       }
+       JSObjectRef objectCallbacks = toJSObjectRef(jsValue);
+       CallHistoryChangeCB result;
 
-       if (!JSValueIsUndefined(m_context, jCost)) {
-               cost = toULong(jCost);
-               result->setCost(cost);
-       }
+       result.onAdded = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onadded");
+       result.onChanged = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onchanged");
 
-       if (!JSValueIsUndefined(m_context, jCurrency)) {
-               currency = toString(jCurrency);
-               result->setCurrency(currency);
-       }
+       JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(context);
+       JSCallbackManagerPtr onChangedCbm = JSCallbackManager::createObject(context);
 
-       return result;
-}
-
-EventCallHistoryListenerPrivateDataPtr 
-       Converter::toEventCallHistoryListenerPrivateData(JSValueRef successParam, JSContextRef context)
-{
-       if (JSValueIsNull(m_context, successParam) || JSValueIsUndefined(m_context, successParam)
-                       || !JSValueIsObject(m_context, successParam))
-       {
-               ThrowMsg(Commons::ConversionException, "CB is not a object");
+       if (!JSValueIsNull(m_context, result.onAdded) && !JSValueIsUndefined(m_context, result.onAdded)) {
+               if (JSObjectIsFunction(m_context, toJSObjectRef(result.onAdded))) {
+                       onAddedCbm->setOnSuccess(result.onAdded);
+               } else {
+                       ThrowMsg(Commons::ConversionException, "Type missmatch error : onadded callback");
+               }
        }
 
-       JSObjectRef objectCallbacks = toJSObjectRef(successParam);
-       Validator validator(m_context);
-       CallHistoryChangeCB result;
-
-       result.onAdded = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onAdded");
-       result.onChanged = JSUtils::getJSPropertyOrUndefined(m_context, objectCallbacks, "onChanged");
-                       
-       if ((!validator.isNullOrUndefined(result.onAdded) && !validator.isCallback(result.onAdded)) ||
-               (!validator.isNullOrUndefined(result.onChanged) && !validator.isCallback(result.onChanged)))
-       {
-               ThrowMsg(Commons::InvalidArgumentException, "Invalid values error : CallHistoryChangeCB");
+       if (!JSValueIsNull(m_context, result.onChanged) && !JSValueIsUndefined(m_context, result.onChanged)) {
+               if (JSObjectIsFunction(m_context, toJSObjectRef(result.onChanged))) {
+                       onChangedCbm->setOnSuccess(result.onChanged);
+               } else {                        
+                       ThrowMsg(Commons::ConversionException, "Type missmatch error : onchanged callback");
+               }
        }
 
-       JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(context, result.onAdded, NULL);
-       JSCallbackManagerPtr onChangedCbm = JSCallbackManager::createObject(context, result.onChanged, NULL);
-
        return EventCallHistoryListenerPrivateDataPtr(new EventCallHistoryListenerPrivateData(onAddedCbm, onChangedCbm));
 }
 
@@ -368,16 +186,24 @@ JSValueRef Converter::toJSValueRef(const Api::Call::CallHistoryEntryListPtr& arg
        }
        Api::Call::CallHistoryEntryProperties tmpCallEntry;
 
-       for (size_t i = 0; i < (*arg).size(); i++) {
-               tmpCallEntry = *((*arg)[i]);
-               JSObjectRef jsObject = JSCallHistoryEntry::createJSObject(context, tmpCallEntry);
-               if (!jsObject) {
-                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
-               }
+       try {
+               for (size_t i = 0; i < (*arg).size(); i++) {
+                       tmpCallEntry = *((*arg)[i]);
+                       JSObjectRef jsObject = JSCallHistoryEntry::createJSObject(context, tmpCallEntry);
+                       if (!jsObject) {
+                               ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+                       }
 
-               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
-                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+                       if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                               ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+                       }
                }
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::InvalidArgumentException& ex) {
+               ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage());
+       } catch (Commons::Exception& ex) {
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
        return jsResult;
 }
@@ -407,62 +233,30 @@ JSValueRef Converter::toJSValueRef(const Api::Call::RemotePartyListPtr& arg, JSC
 
        Api::Call::RemoteParty tmpRemoteParty;
 
-       for (size_t i = 0; i < (*arg).size(); i++) {
-               tmpRemoteParty = *((*arg)[i]);
-               JSObjectRef jsObject = JSRemoteParty::createJSObject(context, tmpRemoteParty);
-               if (!jsObject) {
-                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
-               }
+       try {
+               for (size_t i = 0; i < (*arg).size(); i++) {
+                       tmpRemoteParty = *((*arg)[i]);
+                       JSObjectRef jsObject = JSRemoteParty::createJSObject(context, tmpRemoteParty);
+                       if (!jsObject) {
+                               ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+                       }
 
-               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
-                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+                       if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                               ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+                       }
                }
+       } catch (Commons::ConversionException& ex) {
+               ThrowMsg(Commons::ConversionException, ex.GetMessage());
+       } catch (Commons::InvalidArgumentException& ex) {
+               ThrowMsg(Commons::InvalidArgumentException, ex.GetMessage());
+       } catch (Commons::Exception& ex) {
+               ThrowMsg(Commons::Exception, ex.GetMessage());
        }
        return jsResult;
 }
 
-JSValueRef Converter::toJSValueRef(const Api::Account::AccountServicesArrayPtr& arg, JSContextRef context)
-{
-       std::vector<JSValueRef> callServiceList;
-
-       Api::Account::AccountServices tmpService;
-
-       for (size_t i = 0; i < (*arg).size(); i++) {
-               tmpService = *((*arg)[i]);
-
-               if (tmpService.getServiceTypeId().compare(STR_TIZEN_TEL) == 0) {
-                       callServiceList.push_back(JSCellularCallService::createJSObject(context, tmpService));
-               } else {
-                       callServiceList.push_back(JSCallService::createJSObject(context, tmpService));
-               }
-       }
-
-       return toJSValueRef(callServiceList);
-}
-
 bool Converter::initializeAllowedProperties()
 {
-       m_allowedCallHistoryEntryProperties.push_back(STR_ENTRY_ID);
-       m_allowedCallHistoryEntryProperties.push_back(STR_SERVICE_ID);
-       m_allowedCallHistoryEntryProperties.push_back(STR_CALL_TYPE);
-       m_allowedCallHistoryEntryProperties.push_back(STR_TAGS);
-       m_allowedCallHistoryEntryProperties.push_back(STR_REMOTE_PARTIES);
-       m_allowedCallHistoryEntryProperties.push_back(STR_FORWARDEDFROM);
-       m_allowedCallHistoryEntryProperties.push_back(STR_START_TIME);
-       m_allowedCallHistoryEntryProperties.push_back(STR_DURATION);
-       m_allowedCallHistoryEntryProperties.push_back(STR_END_REASON);
-       m_allowedCallHistoryEntryProperties.push_back(STR_DIRECTION);
-       m_allowedCallHistoryEntryProperties.push_back(STR_RECORDING);
-       m_allowedCallHistoryEntryProperties.push_back(STR_COST);
-       m_allowedCallHistoryEntryProperties.push_back(STR_CURRENCY);
-       m_allowedRemoteParty.push_back(STR_REMOTE_PARTY);
-       m_allowedRemoteParty.push_back(STR_DISPLAY_NAME);
-       m_allowedRemoteParty.push_back(STR_CONTACT_ID);
-       m_allowedCallServiceFilter.push_back(STR_CALL_TYPE);
-       m_allowedCallServiceFilter.push_back(STR_TAGS);
-       m_allowedCallServiceFilter.push_back(STR_SERVICE_NAME);
-       m_allowedCallServiceFilter.push_back(STR_PROVIDER_ID);
-
        return true;
 }
 
index d33c461..a099263 100755 (executable)
 #include <map>
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/Converter.h>
-#include <API/Account/AccountServices.h>
 #include <API/Call/CallHistoryEntryProperties.h>
 #include <API/Call/RemoteParty.h>
-#include <API/Call/CallServiceFilter.h>
+#include <Tizen/Contact/ContactConverter.h>
 #include "CallMultiCallback.h"
 
 namespace TizenApis {
@@ -39,9 +38,9 @@ public:
 public:
        explicit Converter(JSContextRef context);
 
-       std::vector<unsigned long> toVectorOfULongs(const JSValueRef& arg);
+       std::vector<unsigned long> toVectorOfULongs(const JSValueRef& jsValue);
 
-       Api::Call::CallHistoryEntryList toVectorOfCallHistoryEntryProperties(const JSValueRef& arg);
+       Api::Call::CallHistoryEntryList toVectorOfCallHistoryEntryProperties(const JSValueRef& jsValue);
 
        Api::Call::StringArrayPtr toStringArray(const JSValueRef &jsValue);
 
@@ -49,11 +48,9 @@ public:
 
        Api::Call::RemotePartyPtr toRemoteParty(const JSValueRef &jsValue);
 
-       Api::Call::CallServiceFilterPtr toCallServiceFilter(const JSValueRef &jsValue);
-
        Api::Call::CallHistoryEntryPropertiesPtr toCallHistoryEntryProperties(const JSValueRef &jsValue);
 
-       EventCallHistoryListenerPrivateDataPtr toEventCallHistoryListenerPrivateData(JSValueRef successParam, JSContextRef context);
+       EventCallHistoryListenerPrivateDataPtr toEventCallHistoryListenerPrivateData(const JSValueRef &jsValue, JSContextRef context);
 
        JSValueRef toJSValueRef(const Api::Call::CallHistoryEntryListPtr &arg, JSContextRef context);
 
@@ -61,13 +58,8 @@ public:
 
        JSValueRef toJSValueRef(const Api::Call::RemotePartyListPtr& arg, JSContextRef context);
 
-       JSValueRef toJSValueRef(const Api::Account::AccountServicesArrayPtr& arg, JSContextRef context);
-
 private:
        bool initializeAllowedProperties();
-       static std::vector<std::string> m_allowedCallHistoryEntryProperties;
-       static std::vector<std::string> m_allowedRemoteParty;
-       static std::vector<std::string> m_allowedCallServiceFilter;
 };
 
 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<Converter> ConverterFactory;
index ff07e37..0f61d23 100755 (executable)
@@ -32,6 +32,7 @@
 
 #include "JSCallHistoryEntry.h"
 #include "JSCallHistory.h"
+#include "CallAsyncEventPrivateData.h"
 #include "CallStaticController.h"
 #include "CallMultiCallback.h"
 #include "ResponseDispatcher.h"
@@ -136,21 +137,36 @@ bool JSCallHistory::hasInstance(JSContextRef context, JSObjectRef constructor,
 JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount < 1 || argumentCount > 6) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_FIND);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argumentCount < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
 
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
+
+       JSContextRef gContext = priv->getContext();
        WrtDeviceApis::CommonsJavaScript::Converter converter(context);
        Validator check(context, exception);
 
-       try {
-               FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+       JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
 
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
+       try {
+               if (argumentCount >= 1) {
+                       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback ");
+                       } else if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback ");
+                       }
+                       cbm->setOnSuccess(arguments[0]);
+               }
 
                if (argumentCount >= 2) {
                        if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
@@ -161,15 +177,6 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
                        }
                }
 
-               if (argumentCount >= 1) {
-                       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : success callback ");
-                       } else if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback ");
-                       }
-                       cbm->setOnSuccess(arguments[0]);
-               }
-
                if (argumentCount >= 3) {
                        if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
                                if (!JSValueIsObject(context, arguments[2])) {
@@ -178,15 +185,13 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
                        }
                }
 
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_FIND);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
                EventFindCallHistoryPtr event(new EventFindCallHistory());
                ICallHistoryPtr callHistory(priv->getObject());
-               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
+               CallAsyncEventPrivateDataPtr privateData(new CallAsyncEventPrivateData(cbm, thisObject));
+
+               event->setPrivateData(StaticPointerCast<IEventPrivateData> (privateData));
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
 
                if (argumentCount >= 3) {
@@ -213,16 +218,16 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
                                event->setOffset(converter.toULong(arguments[5]));
                        }
                }
-
+               JSValueProtect(gContext, thisObject);
                callHistory->find(event);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
        return JSValueMakeUndefined(context);
@@ -231,39 +236,37 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
 JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount < 1 || argumentCount > 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_REMOVE);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argumentCount < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
 
-       assert(priv && "Invalid private pointer.");
-       Converter converter(context);
-       Validator check(context, exception);
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : CallHistoryEntry");
-       } else if (!JSValueIsObject(context, arguments[0])) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
        }
 
-       try {
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_REMOVE);
+       Converter converter(context);
 
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       try {
+               if (!JSValueIsObjectOfClass(context, arguments[0], JSCallHistoryEntry::getClassRef())) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry");
+               }
 
                ICallHistoryPtr callHistory(priv->getObject());
                CallHistoryEntryPropertiesPtr entry = converter.toCallHistoryEntryProperties(arguments[0]);
                callHistory->remove(entry->getEntryId());
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
@@ -274,31 +277,30 @@ JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObj
 JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount < 1 || argumentCount > 3) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_REMOVE_BATCH);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argumentCount < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
-
-       assert(priv && "Invalid private pointer.");
-       Converter converter(context);
-       Validator check(context, exception);
 
-       if (!JSIsArrayValue(context, arguments[0])) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry array");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
        }
 
-       try {
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
+       JSContextRef gContext = priv->getContext();
+       Converter converter(context);
 
-               if (argumentCount >= 3) {
-                       if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
-                               }
-                               cbm->setOnError(arguments[2]);
-                       }
+       JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
+       try {
+               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid values error : CallHistoryEntry array");
+               } else if (!JSIsArrayValue(context, arguments[0])) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallHistoryEntry array");
                }
 
                if (argumentCount >= 2) {
@@ -310,16 +312,20 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
                        }
                }
 
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_REMOVE_BATCH);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               if (argumentCount >= 3) {
+                       if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) {
+                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
+                               }
+                               cbm->setOnError(arguments[2]);
+                       }
+               }
 
                EventRemoveBatchPtr event(new EventRemoveBatch());
                ICallHistoryPtr callHistory(priv->getObject());
+               CallAsyncEventPrivateDataPtr privateData(new CallAsyncEventPrivateData(cbm, thisObject));
 
-               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
+               event->setPrivateData(StaticPointerCast<IEventPrivateData> (privateData));
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
 
                CallHistoryEntryList entryList = converter.toVectorOfCallHistoryEntryProperties(arguments[0]);
@@ -331,18 +337,19 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
                                entryIds.push_back(entryList[i]->getEntryId());
                        }
                        event->setEntryIds(entryIds);
+                       JSValueProtect(gContext, thisObject);
                        callHistory->removeBatch(event);
                } else {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : Entry array is null");
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : Entry array is empty"));
                }
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
        return JSValueMakeUndefined(context);
@@ -351,29 +358,23 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
 JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount > 2) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-       }
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_REMOVE_ALL);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
 
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
+
+       JSContextRef gContext = priv->getContext();
        Converter converter(context);
-       Validator check(context, exception);
 
-       try {
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
-
-               if (argumentCount >= 2) {
-                       if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
-                               }
-                               cbm->setOnError(arguments[1]);
-                       }
-               }
+       JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
 
+       try {
                if (argumentCount >= 1) {
                        if (!JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) {
                                if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[0]))) {
@@ -383,26 +384,31 @@ JSValueRef JSCallHistory::removeAll(JSContextRef context, JSObjectRef object, JS
                        }
                }
 
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_REMOVE_ALL);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               if (argumentCount >= 2) {
+                       if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
+                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
+                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
+                               }
+                               cbm->setOnError(arguments[1]);
+                       }
+               }
 
                EventRemoveAllPtr event(new EventRemoveAll());
                ICallHistoryPtr callHistory(priv->getObject());
-               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+               CallAsyncEventPrivateDataPtr privateData(new CallAsyncEventPrivateData(cbm, thisObject));
 
+               event->setPrivateData(StaticPointerCast<IEventPrivateData> (privateData));
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+               JSValueProtect(gContext, thisObject);
                callHistory->removeAll(event);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
        return JSValueMakeUndefined(context);
@@ -417,40 +423,44 @@ JSValueRef JSCallHistory::deleteRecording(JSContextRef context, JSObjectRef obje
 JSValueRef JSCallHistory::addListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount < 1 || argumentCount > 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_ADDLISTENER);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argumentCount < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
 
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
+
+       JSContextRef gContext = priv->getContext();
        Converter converter(context);
-       Validator check(context, exception);
 
        try {
-               EventCallHistoryListenerPrivateDataPtr privData(converter.toEventCallHistoryListenerPrivateData(arguments[0], gContext));
-
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_ADDLISTENER);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               long id = 0;
+               if (argumentCount >= 1) {
+                       EventCallHistoryListenerPrivateDataPtr privData(converter.toEventCallHistoryListenerPrivateData(arguments[0], gContext));
 
-               Api::Call::EventCallHistoryListenerEmitterPtr emitter(new Api::Call::EventCallHistoryListenerEmitter);
-               emitter->setListener(&CallStaticController::getInstance());
-               emitter->setEventPrivateData(DPL::StaticPointerCast<Api::Call::EventCallHistoryListener::PrivateDataType>(privData));
+                       Api::Call::EventCallHistoryListenerEmitterPtr emitter(new Api::Call::EventCallHistoryListenerEmitter);
+                       emitter->setListener(&CallStaticController::getInstance());
+                       emitter->setEventPrivateData(DPL::StaticPointerCast<Api::Call::EventCallHistoryListener::PrivateDataType>(privData));
 
-               ICallHistoryPtr callHistory(priv->getObject());
-               long id = callHistory->addListener(emitter);
+                       ICallHistoryPtr callHistory(priv->getObject());
+                       id = callHistory->addListener(emitter);
+               }
 
                return converter.toJSValueRefLong(id);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
@@ -461,38 +471,46 @@ JSValueRef JSCallHistory::addListener(JSContextRef context, JSObjectRef object,
 JSValueRef JSCallHistory::removeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
        const JSValueRef arguments[], JSValueRef* exception) {
 
-       if (argumentCount < 1 || argumentCount > 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_HISTORY_FUNCTION_API_REMOVELISTENER);
+
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       if (argumentCount < 1) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
 
-       assert(priv && "Invalid private pointer.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
+
        Converter converter(context);
        Validator check(context, exception);
 
        try {
-               if (check.isNullOrUndefined(arguments[0])) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle");
-               }
-
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_HISTORY_FUNCTION_API_REMOVELISTENER);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               long id = 0;
+               if (argumentCount >= 1) {
+                       if (check.isNullOrUndefined(arguments[0])) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle");
+                       }
 
-               long id = static_cast<long>(converter.toLong(arguments[0]));
+                       id = static_cast<long>(converter.toLong(arguments[0]));
+               }
 
-               if (id >= 0) {
+               if (id != 0) {
                        ICallHistoryPtr callHistory(priv->getObject());
                        callHistory->removeListener(id);
+               } else {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : handle");
                }
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
index 5ce2981..3eca5d7 100755 (executable)
@@ -96,15 +96,30 @@ JSClassRef JSCallHistoryEntry::m_jsClassRef = JSClassCreate(JSCallHistoryEntry::
 JSObjectRef JSCallHistoryEntry::createJSObject(JSContextRef context,
         const CallHistoryEntryProperties &entryInfo)
 {
-       std::auto_ptr<CallHistoryEntryProperties> callHistoryEntryProps(new CallHistoryEntryProperties(entryInfo));
-       JSCallHistoryEntryPriv *priv = new JSCallHistoryEntryPriv(context, callHistoryEntryProps.get());
-       callHistoryEntryProps.release();
+       CallHistoryEntryPropertiesPtr callHistoryEntryProps(new CallHistoryEntryProperties(entryInfo));
+       JSCallHistoryEntryPriv *priv = new JSCallHistoryEntryPriv(context, CallHistoryEntryPropertiesPtr(callHistoryEntryProps));
        if (!priv) {
                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
        }
        return JSObjectMake(context, getClassRef(), priv);
 }
 
+CallHistoryEntryPropertiesPtr JSCallHistoryEntry::getCallHistoryEntry(JSContextRef context, JSValueRef value)
+{
+       if (!JSValueIsObjectOfClass(context, value, getClassRef())) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       JSCallHistoryEntryPriv *priv = static_cast<JSCallHistoryEntryPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       return priv->getObject();
+}
+
 void JSCallHistoryEntry::initialize(JSContextRef context, JSObjectRef object)
 {
 }
@@ -112,8 +127,10 @@ void JSCallHistoryEntry::initialize(JSContextRef context, JSObjectRef object)
 void JSCallHistoryEntry::finalize(JSObjectRef object)
 {
        JSCallHistoryEntryPriv* priv = static_cast<JSCallHistoryEntryPriv*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       delete priv;
+       if (priv != NULL) {
+               JSObjectSetPrivate(object, NULL);
+               delete priv;
+       }
 }
 
 JSValueRef JSCallHistoryEntry::getProperty(JSContextRef context,
@@ -122,11 +139,13 @@ JSValueRef JSCallHistoryEntry::getProperty(JSContextRef context,
        JSValueRef* exception)
 {
        JSCallHistoryEntryPriv *priv = static_cast<JSCallHistoryEntryPriv*>(JSObjectGetPrivate(object));
-       assert(priv && "Private object not set.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
 
        try {
                JSContextRef globalContext = priv->getContext();
-               CallHistoryEntryProperties *entryInfo = priv->getObject();
+               CallHistoryEntryPropertiesPtr entryInfo = priv->getObject();
                Converter convert(context);
 
                if (JSStringIsEqualToUTF8CString(propertyName, STR_ENTRY_ID)) {
@@ -158,8 +177,10 @@ JSValueRef JSCallHistoryEntry::getProperty(JSContextRef context,
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CURRENCY)) {
                        return convert.toJSValueRef(entryInfo->getCurrency());
                }
-       } catch(WrtDeviceApis::Commons::Exception) {
-               LogWarning("trying to get incorrect value");
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
        return JSValueMakeUndefined(context);
 }
@@ -171,12 +192,14 @@ bool JSCallHistoryEntry::setProperty(JSContextRef context,
                JSValueRef* exception)
 {
        JSCallHistoryEntryPriv *priv = static_cast<JSCallHistoryEntryPriv*>(JSObjectGetPrivate(object));
-       assert(priv && "Private object not set.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
 
        Converter converter(context);
        try {
                if (JSStringIsEqualToUTF8CString(propertyName, STR_DIRECTION)) {
-                       CallHistoryEntryProperties *entryInfo = priv->getObject();
+                       CallHistoryEntryPropertiesPtr entryInfo = priv->getObject();
                        if (entryInfo != NULL) {
                                ICallHistoryEntryPtr callHistoryEntry(CallHistoryFactory::getInstance().getCallHistoryEntryObject());
                                std::string direction(converter.toString(value));
index bd239f3..3ca6c87 100755 (executable)
@@ -24,7 +24,7 @@
 
 namespace TizenApis {
 namespace Tizen1_0 {
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::CallHistoryEntryProperties*>::Type JSCallHistoryEntryPriv;
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::CallHistoryEntryPropertiesPtr>::Type JSCallHistoryEntryPriv;
 
 class JSCallHistoryEntry
 {
@@ -36,6 +36,8 @@ public:
        static JSObjectRef createJSObject(JSContextRef context,
                const Api::Call::CallHistoryEntryProperties &entryInfo);
 
+       static Api::Call::CallHistoryEntryPropertiesPtr getCallHistoryEntry(JSContextRef context, JSValueRef value);
+
 private:
        static void initialize(JSContextRef context,
                JSObjectRef object);
index f0c36fd..03772b4 100755 (executable)
@@ -23,7 +23,6 @@
 #include <API/Call/ICallManager.h>
 #include <API/Call/CallFactory.h>
 #include <API/Call/CallDefine.h>
-#include <API/Call/EventGetCallService.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h> 
 #include <Tizen/Common/SecurityExceptions.h>
@@ -38,7 +37,6 @@ using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Api::Call;
-using namespace TizenApis::Api::Account;
 using namespace TizenApis::Commons;
 
 namespace TizenApis {
@@ -75,7 +73,6 @@ JSStaticValue JSCallManager::m_property[] = {
 JSStaticFunction JSCallManager::m_function[] =
 {
        { "isCallInProgress", JSCallManager::isCallInProgress, kJSPropertyAttributeNone },
-       { "getCallServices", JSCallManager::getCallServices, kJSPropertyAttributeNone },
        { 0, 0, 0 }
 };
 
@@ -95,22 +92,24 @@ const JSClassDefinition* JSCallManager::getClassInfo()
 void JSCallManager::initialize(JSContextRef context, JSObjectRef object)
 {
        JSCallManagerPriv* priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(object));
-       assert(!priv && "Invalid object creation.");
-       ICallManagerPtr Call(CallFactory::getInstance().getCallObject() );
-       priv = new JSCallManagerPriv(context, Call);
-       if(!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
-               LogError("Object can't store private data.");
-               delete priv;
+       if (!priv) {
+               ICallManagerPtr Call(CallFactory::getInstance().getCallObject() );
+               priv = new JSCallManagerPriv(context, Call);
+               if(!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+                       LogError("Object can't store private data.");
+                       delete priv;
+               }
+               LogDebug("JSCallManager::initialize ");
        }
-
-       LogDebug("JSCallManager::initialize ");
 }
 
 void JSCallManager::finalize(JSObjectRef object)
 {
        JSCallManagerPriv* priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       delete priv;
+       if (priv != NULL) {
+               JSObjectSetPrivate(object, NULL);
+               delete priv;
+       }
 }
 
 JSValueRef JSCallManager::getProperty(JSContextRef context,
@@ -120,7 +119,7 @@ JSValueRef JSCallManager::getProperty(JSContextRef context,
 {
        JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(object));
        if (!priv) {
-               return JSValueMakeUndefined(context);
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "private object is null");
        }
 
        JSContextRef globalContext = priv->getContext();
@@ -129,6 +128,8 @@ JSValueRef JSCallManager::getProperty(JSContextRef context,
                if(JSStringIsEqualToUTF8CString(propertyName, STR_HISTORY)) {
                        return JSCallHistory::createJSObject(globalContext, object);
                }
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
@@ -145,92 +146,26 @@ JSValueRef JSCallManager::isCallInProgress(JSContextRef context, JSObjectRef obj
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef* exception)
 {
-       JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(thisObject));
+       AceSecurityStatus status = CALL_CHECK_ACCESS(
+                       CALL_FUNCTION_API_ISCALLINPROGRESS);
 
-       JSContextRef gContext = priv->getContext();
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       
+       JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(thisObject));
        Converter converter(context);
 
        if (priv == NULL) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
        try     {
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_FUNCTION_API_ISCALLINPROGRESS);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ICallManagerPtr callManager(priv->getObject());
                bool result = callManager->isCallInProgress();
                return converter.toJSValueRef(result);
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
-       }
-
-       return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSCallManager::getCallServices(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-       const JSValueRef arguments[], JSValueRef* exception)
-{
-       if (argumentCount > 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-       }
-
-       JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*> (JSObjectGetPrivate(thisObject));
-
-       assert(priv && "Invalid private pointer.");
-       JSContextRef gContext = priv->getContext();
-       Converter converter(context);
-
-       try{
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_FUNCTION_API_GETCALLSERVICES);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               CallServiceFilterPtr filter(new CallServiceFilter());
-
-               if (argumentCount == 0) {
-                       StringArrayPtr tags(new StringArray());
-                       tags->push_back(STR_CALL);
-                       filter->setTags(tags);
-               } else {
-                       if (!JSValueIsObject(context, arguments[0])) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : CallServiceFilter");
-                       }
-                       filter = converter.toCallServiceFilter(arguments[0]);
-               }
-
-               EventGetCallServicePtr event(new EventGetCallService());
-
-               event->setForSynchronousCall();
-               event->setFilter(filter);
-
-               ICallManagerPtr callManager(priv->getObject());
-               callManager->getCallService(event);
-
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-                       return converter.toJSValueRef(event->getResult(), gContext);
-               } else {
-                       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::InvalidArgumentException) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error : CallServiceFilter");
-                       } else {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-                       }
-               }
-       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
index 1f89ff4..284a316 100755 (executable)
@@ -65,13 +65,6 @@ private:
                        JSValueRef* exception);
 
        /**
-       * Get call services, with account, call provider, and capabilities.
-       */
-       static JSValueRef getCallServices(JSContextRef context, JSObjectRef object,
-                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-                       JSValueRef* exception);
-       
-       /**
        * This structure contains properties and callbacks that define a type of object.
        */
        static JSClassDefinition m_classInfo;
diff --git a/src/standards/Tizen/Call/JSCallService.cpp b/src/standards/Tizen/Call/JSCallService.cpp
deleted file mode 100755 (executable)
index 675002f..0000000
+++ /dev/null
@@ -1,234 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <API/Call/CallDefine.h>
-#include <API/Call/CallFactory.h>
-#include <API/Call/ICallService.h>
-#include <API/Call/EventLaunchDialer.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h> 
-#include <Tizen/Common/SecurityExceptions.h>
-#include <Tizen/Account/JSAccountServices.h>
-#include "JSCallService.h"
-#include "ResponseDispatcher.h"
-#include "Converter.h"
-#include "plugin_config.h"
-
-using namespace std;
-using namespace DPL;
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Api::Call;
-using namespace TizenApis::Api::Account;
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-JSClassRef JSCallService::m_jsClassRef = NULL;
-
-JSClassDefinition JSCallService::m_classInfo =
-{
-       0,
-       kJSClassAttributeNone,
-       "CallService",
-       JSAccountServices::getClassRef(),
-       m_property,
-       m_function,
-       initialize,
-       finalize,
-       NULL, //hasProperty,
-       NULL, //getProperty,
-       NULL, //setProperty,
-       NULL, //deleteProperty,
-       NULL, //getPropertyNames,
-       NULL,
-       NULL,
-       hasInstance,
-       NULL
-};
-
-JSStaticValue JSCallService::m_property[] = {
-       { STR_VOICEMAIL_NUMBERS, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSCallService::m_function[] =
-{
-       { "launchDialer", JSCallService::launchDialer, kJSPropertyAttributeNone },
-       { 0, 0, 0 }
-};
-
-const JSClassRef JSCallService::getClassRef()
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSCallService::getClassInfo()
-{
-       return &m_classInfo;
-}
-
-JSObjectRef JSCallService::createJSObject(JSContextRef context, const AccountServices &serviceInfo)
-{
-       ICallServicePtr callService(CallFactory::getInstance().getCallServiceObject());
-       CallServiceObjectPtr privateData = CallServiceObjectPtr(new CallServiceObject(serviceInfo, callService));
-
-       JSCallServicePriv *priv = new JSCallServicePriv(context, privateData);
-
-       if (!priv) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
-       }
-
-       JSObjectRef jsObjRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
-       if (NULL == jsObjRef) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
-       }
-       return jsObjRef;
-}
-
-void JSCallService::initialize(JSContextRef context, JSObjectRef object)
-{
-       LogDebug("JSCallService::initialize ");
-}
-
-void JSCallService::finalize(JSObjectRef object)
-{
-       JSCallServicePriv* priv = static_cast<JSCallServicePriv*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       delete priv;
-}
-
-JSValueRef JSCallService::getProperty(JSContextRef context,
-       JSObjectRef object,
-       JSStringRef propertyName,
-       JSValueRef* exception)
-{
-       JSCallServicePriv *priv = static_cast<JSCallServicePriv*>(JSObjectGetPrivate(object));
-       if (!priv) {
-               return JSValueMakeUndefined(context);
-       }
-
-       JSContextRef globalContext = priv->getContext();
-       CallServiceObjectPtr privateData = priv->getObject();
-       ICallServicePtr callService(privateData->getICallService());
-
-       try {
-               Converter convert(context);
-               if(JSStringIsEqualToUTF8CString(propertyName, STR_VOICEMAIL_NUMBERS)) {
-                       return convert.toJSValueRef(callService->getVoicemailNumbers(), globalContext);
-               }
-       } catch(WrtDeviceApis::Commons::Exception) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSCallService::hasInstance(JSContextRef context, JSObjectRef constructor,
-       JSValueRef possibleInstance, JSValueRef* exception)
-{
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSValueRef JSCallService::launchDialer(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception)
-{
-       if (argumentCount < 1 || argumentCount > 4) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-       }
-       
-       JSCallServicePriv *priv = static_cast<JSCallServicePriv*>(JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
-
-       assert(priv && "Invalid private pointer.");
-       Converter converter(context);
-       Validator check(context, exception);
-
-       try     {
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_FUNCTION_API_LAUNCHDIALER);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
-               if (!JSValueIsString(context, arguments[0])) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : remoteparty string");
-               }
-
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
-
-               if (argumentCount >= 3) {
-                       if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
-                               }
-                               cbm->setOnError(arguments[2]);
-                       }
-               }
-
-               if (argumentCount >= 2) {
-                       if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback");
-                               }
-                               cbm->setOnSuccess(arguments[1]);
-                       }
-               }
-
-               if (argumentCount >= 4) {
-                       if (!JSValueIsString(context, arguments[3])) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : extension string");
-                       }
-               }
-
-               CallServiceObjectPtr privateData = priv->getObject();
-               ICallServicePtr callService(privateData->getICallService());
-
-               EventLaunchDialerPtr event(new EventLaunchDialer());
-               event ->setRemoteParty(converter.toString(arguments[0]));
-               if (argumentCount >= 4) {
-                       event ->setExtension(converter.toString(arguments[3]));
-               }
-               event->setAppId(privateData->getApplicationId());
-               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
-
-               callService->launchDialer(event);
-
-       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
-       }
-       return JSValueMakeUndefined(context);
-}
-
-}
-}
-
diff --git a/src/standards/Tizen/Call/JSCallService.h b/src/standards/Tizen/Call/JSCallService.h
deleted file mode 100755 (executable)
index fcc8224..0000000
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_TIZEN_JS_CALLSERVICE_H_
-#define TIZENAPIS_TIZEN_JS_CALLSERVICE_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/AccountServices.h>
-#include <API/Call/CallServiceObject.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::CallServiceObjectPtr>::Type JSCallServicePriv;
-
-class JSCallService
-{
-public:
-       static const JSClassDefinition* getClassInfo();
-
-       static const JSClassRef getClassRef();
-
-       static JSObjectRef createJSObject(JSContextRef context,
-               const Api::Account::AccountServices &serviceInfo);
-
-private:
-       /**
-       * The callback invoked when an object is first created.
-       */
-       static void initialize(JSContextRef context, JSObjectRef object);
-
-       /**
-       * The callback invoked when an object is finalized.
-       */
-       static void finalize(JSObjectRef object);
-
-       /**
-        * The callback invoked when getting a property's value.
-        */
-       static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
-                       JSStringRef propertyName, JSValueRef* exception);
-
-       /**
-       * The callback invoked when an object is used as the target of an 'instanceof' expression.
-       */
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor,
-                       JSValueRef possibleInstance, JSValueRef* exception);
-
-       /**
-       * Tell whether is there is a call going on.
-       */
-       static JSValueRef launchDialer(JSContextRef context, JSObjectRef object,
-                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-                       JSValueRef* exception);
-       
-       /**
-       * This structure contains properties and callbacks that define a type of object.
-       */
-       static JSClassDefinition m_classInfo;
-
-       /**
-        * This structure describes a statically declared value property.
-        */
-       static JSStaticValue m_property[];
-
-       /**
-       * This structure describes a statically declared function property.
-       */
-       static JSStaticFunction m_function[];
-
-       static JSClassRef m_jsClassRef;
-
-};
-
-} 
-} 
-
-#endif
-
diff --git a/src/standards/Tizen/Call/JSCellularCallService.cpp b/src/standards/Tizen/Call/JSCellularCallService.cpp
deleted file mode 100755 (executable)
index c9fc802..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Utils.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include <API/Call/CallDefine.h>
-#include <API/Call/CallFactory.h>
-#include <API/Call/ICallManager.h>
-#include <API/Call/EventSendUSSD.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h> 
-#include <Tizen/Common/SecurityExceptions.h>
-#include "JSCallService.h"
-#include "JSCellularCallService.h"
-#include "ResponseDispatcher.h"
-#include "Converter.h"
-#include "plugin_config.h"
-
-using namespace std;
-using namespace DPL;
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Api::Call;
-using namespace TizenApis::Api::Account;
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-JSClassRef JSCellularCallService::m_jsClassRef = NULL;
-
-JSClassDefinition JSCellularCallService::m_classInfo =
-{
-       0,
-       kJSClassAttributeNone,
-       "CellularCallService",
-       JSCallService::getClassRef(),
-       m_property,
-       m_function,
-       initialize,
-       finalize,
-       NULL, //hasProperty,
-       NULL, //getProperty,
-       NULL, //setProperty,
-       NULL, //deleteProperty,
-       NULL, //getPropertyNames,
-       NULL,
-       NULL,
-       hasInstance,
-       NULL
-};
-
-JSStaticValue JSCellularCallService::m_property[] = {
-       { STR_SUBSCRIBER_NUMBERS, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_EMERGENCY_NUMBERS, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { 0, 0, 0, 0 }
-};
-
-JSStaticFunction JSCellularCallService::m_function[] =
-{
-       { "sendUSSD", JSCellularCallService::sendUSSD, kJSPropertyAttributeNone },
-       { 0, 0, 0 }
-};
-
-const JSClassRef JSCellularCallService::getClassRef()
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSCellularCallService::getClassInfo()
-{
-       return &m_classInfo;
-}
-
-JSObjectRef JSCellularCallService::createJSObject(JSContextRef context, const AccountServices &serviceInfo)
-{
-       ICallServicePtr callService(CallFactory::getInstance().getCallServiceObject());
-       CallServiceObjectPtr privateData = CallServiceObjectPtr(new CallServiceObject(serviceInfo, callService));
-
-       JSCellularCallServicePriv *priv = new JSCellularCallServicePriv(context, privateData);
-
-       if (!priv) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
-       }
-
-       JSObjectRef jsObjRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
-       if (NULL == jsObjRef) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
-       }
-       return jsObjRef;
-}
-
-void JSCellularCallService::initialize(JSContextRef context, JSObjectRef object)
-{
-       LogDebug("JSCellularCallService::initialize ");
-}
-
-void JSCellularCallService::finalize(JSObjectRef object)
-{
-       JSCellularCallServicePriv* priv = static_cast<JSCellularCallServicePriv*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       delete priv;
-}
-
-JSValueRef JSCellularCallService::getProperty(JSContextRef context,
-       JSObjectRef object,
-       JSStringRef propertyName,
-       JSValueRef* exception)
-{
-       JSCellularCallServicePriv *priv = static_cast<JSCellularCallServicePriv*>(JSObjectGetPrivate(object));
-       if (!priv) {
-               return JSValueMakeUndefined(context);
-       }
-
-       JSContextRef globalContext = priv->getContext();
-       CallServiceObjectPtr privateData = priv->getObject();
-       ICallServicePtr callService(privateData->getICallService());
-
-       try {
-               Converter convert(context);
-               if(JSStringIsEqualToUTF8CString(propertyName, STR_SUBSCRIBER_NUMBERS)) {
-                       return convert.toJSValueRef(callService->getSubscriberNumbers(), globalContext);
-               } else if(JSStringIsEqualToUTF8CString(propertyName, STR_EMERGENCY_NUMBERS)) {
-                       return convert.toJSValueRef(callService->getEmergencyNumbers(), globalContext);
-               }
-       } catch(WrtDeviceApis::Commons::Exception) {
-               LogWarning("trying to get incorrect value");
-       }
-       return JSValueMakeUndefined(context);
-}
-
-bool JSCellularCallService::hasInstance(JSContextRef context, JSObjectRef constructor,
-       JSValueRef possibleInstance, JSValueRef* exception)
-{
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSValueRef JSCellularCallService::sendUSSD(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception)
-{
-       if (argumentCount < 1 || argumentCount > 3) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-       }
-
-       JSCellularCallServicePriv *priv = static_cast<JSCellularCallServicePriv*> (JSObjectGetPrivate(thisObject));
-       JSContextRef gContext = priv->getContext();
-
-       assert(priv && "Invalid private pointer.");
-       Converter converter(context);
-       Validator check(context, exception);
-
-       try {
-               AceSecurityStatus status = CALL_CHECK_ACCESS(
-                               gContext,
-                               CALL_FUNCTION_API_LAUNCHDIALER);
-
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (!JSValueIsString(context, arguments[0])) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : ussd string");
-               }
-
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
-
-               if (argumentCount >= 3) {
-                       if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[2]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : error callback");
-                               }
-                               cbm->setOnError(arguments[2]);
-                       }
-               }
-
-               if (argumentCount >= 2) {
-                       if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
-                               if (!JSObjectIsFunction(context, converter.toJSObjectRef(arguments[1]))) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : success callback");
-                               }
-                               cbm->setOnSuccess(arguments[1]);
-                       }
-               }
-
-               EventSendUSSDPtr event(new EventSendUSSD());
-               event->setCommand(converter.toString(arguments[0]));
-               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
-
-               CallServiceObjectPtr privateData = priv->getObject();
-               ICallServicePtr callService(privateData->getICallService());
-
-               callService->sendUSSD(event);
-       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
-       }
-
-       return JSValueMakeUndefined(context);
-}
-
-}// Tizen1_0
-}// TizenApis
-
diff --git a/src/standards/Tizen/Call/JSCellularCallService.h b/src/standards/Tizen/Call/JSCellularCallService.h
deleted file mode 100755 (executable)
index c3c0684..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#ifndef TIZENAPIS_TIZEN_JS_CELLULARCALLSERVICE_H_
-#define TIZENAPIS_TIZEN_JS_CELLULARCALLSERVICE_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Account/AccountServices.h>
-#include <API/Call/CallServiceObject.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::CallServiceObjectPtr>::Type JSCellularCallServicePriv;
-
-class JSCellularCallService
-{
-public:
-       static const JSClassDefinition* getClassInfo();
-
-       static const JSClassRef getClassRef();
-
-       static JSObjectRef createJSObject(JSContextRef context,
-               const Api::Account::AccountServices &serviceInfo);
-private:
-       /**
-       * The callback invoked when an object is first created.
-       */
-       static void initialize(JSContextRef context, JSObjectRef object);
-
-       /**
-       * The callback invoked when an object is finalized.
-       */
-       static void finalize(JSObjectRef object);
-
-       /**
-        * The callback invoked when getting a property's value.
-        */
-       static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
-                       JSStringRef propertyName, JSValueRef* exception);
-
-       /**
-       * The callback invoked when an object is used as the target of an 'instanceof' expression.
-       */
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor,
-                       JSValueRef possibleInstance, JSValueRef* exception);
-
-       /**
-       * Send a USSD string to the network.
-       */
-       static JSValueRef sendUSSD(JSContextRef context, JSObjectRef object,
-                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-                       JSValueRef* exception);
-       
-       /**
-       * This structure contains properties and callbacks that define a type of object.
-       */
-       static JSClassDefinition m_classInfo;
-
-       /**
-        * This structure describes a statically declared value property.
-        */
-       static JSStaticValue m_property[];
-
-       /**
-       * This structure describes a statically declared function property.
-       */
-       static JSStaticFunction m_function[];
-
-       static JSClassRef m_jsClassRef;
-
-};
-
-} 
-} 
-
-#endif
-
index de88a0a..5fb89e1 100755 (executable)
@@ -21,6 +21,8 @@
 #include <dpl/shared_ptr.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h> 
 #include <API/Call/CallDefine.h>
 #include <API/Call/RemoteParty.h>
 #include "JSRemoteParty.h"
@@ -33,6 +35,7 @@ using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::Call;
+using namespace TizenApis::Commons;
 
 JSClassDefinition JSRemoteParty::m_classInfo = {
        0,
@@ -57,7 +60,7 @@ JSClassDefinition JSRemoteParty::m_classInfo = {
 JSStaticValue JSRemoteParty::m_property[] = {
        { STR_REMOTE_PARTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_CONTACT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_CONTACT_REF, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { 0, 0, 0, 0 }
 };
 
@@ -79,15 +82,30 @@ JSClassRef JSRemoteParty::m_jsClassRef = JSClassCreate(JSRemoteParty::getClassIn
 JSObjectRef JSRemoteParty::createJSObject(JSContextRef context,
         const RemoteParty &remoteParty)
 {
-       std::auto_ptr<RemoteParty> RemotePartyProps(new RemoteParty(remoteParty));
-       JSRemotePartyPriv *priv = new JSRemotePartyPriv(context, RemotePartyProps.get());
-       RemotePartyProps.release();
+       RemotePartyPtr RemotePartyProps(new RemoteParty(remoteParty));
+       JSRemotePartyPriv *priv = new JSRemotePartyPriv(context, RemotePartyPtr(RemotePartyProps));
        if (!priv) {
-               ThrowMsg(Commons::NullPointerException, "Can not new an object");
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
        }
        return JSObjectMake(context, getClassRef(), priv);
 }
 
+RemotePartyPtr JSRemoteParty::getRemoteParty(JSContextRef context, JSValueRef value)
+{
+       if (!JSValueIsObjectOfClass(context, value, getClassRef())) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       JSRemotePartyPriv *priv = static_cast<JSRemotePartyPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::ConversionException);
+       }
+       return priv->getObject();
+}
+
 void JSRemoteParty::initialize(JSContextRef context, JSObjectRef object)
 {
 }
@@ -95,8 +113,10 @@ void JSRemoteParty::initialize(JSContextRef context, JSObjectRef object)
 void JSRemoteParty::finalize(JSObjectRef object)
 {
        JSRemotePartyPriv* priv = static_cast<JSRemotePartyPriv*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       delete priv;
+       if (priv != NULL) {
+               JSObjectSetPrivate(object, NULL);
+               delete priv;
+       }
 }
 
 JSValueRef JSRemoteParty::getProperty(JSContextRef context,
@@ -105,21 +125,26 @@ JSValueRef JSRemoteParty::getProperty(JSContextRef context,
        JSValueRef* exception)
 {
        JSRemotePartyPriv *priv = static_cast<JSRemotePartyPriv*>(JSObjectGetPrivate(object));
-       assert(priv && "Private object not set.");
+       if (!priv) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error : Invalid private pointer");
+       }
 
        try {
-               RemoteParty* remoteParty = priv->getObject();
+               RemotePartyPtr remoteParty = priv->getObject();
                Converter convert(context);
+               Tizen1_0::Contact::ContactConverter contactConverter(context);
 
                if (JSStringIsEqualToUTF8CString(propertyName, STR_REMOTE_PARTY)) {
                        return convert.toJSValueRef(remoteParty->getRemoteParty());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DISPLAY_NAME)) {
                        return convert.toJSValueRef(remoteParty->getDisplayName());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CONTACT_ID)) {
-                       return convert.toJSValueRef(remoteParty->getContactId());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CONTACT_REF)) {
+                       return contactConverter.toJSValueRef(remoteParty->getContactRef());
                }
-       } catch(Commons::Exception) {
-               LogWarning("trying to get incorrect value");
+       } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
        return JSValueMakeUndefined(context);
 }
index 6478f1b..09096a4 100755 (executable)
@@ -24,7 +24,7 @@
 
 namespace TizenApis {
 namespace Tizen1_0 {
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::RemoteParty*>::Type JSRemotePartyPriv;
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::RemotePartyPtr>::Type JSRemotePartyPriv;
 
 class JSRemoteParty
 {
@@ -36,6 +36,8 @@ public:
        static JSObjectRef createJSObject(JSContextRef context,
                const Api::Call::RemoteParty &remoteParty);
 
+       static Api::Call::RemotePartyPtr getRemoteParty(JSContextRef context, JSValueRef value);
+
 private:
        static void initialize(JSContextRef context,
                JSObjectRef object);
index bab1be5..4a8bf8e 100755 (executable)
@@ -27,6 +27,7 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h> 
 #include "JSCallHistory.h"
+#include "CallAsyncEventPrivateData.h"
 #include "Converter.h"
 
 using namespace WrtDeviceApis::Commons;
@@ -44,23 +45,31 @@ ResponseDispatcher& ResponseDispatcher::getInstance()
 ResponseDispatcher::ResponseDispatcher() :
        EventAnswerReceiver<Api::Call::EventFindCallHistory>(ThreadEnum::NULL_THREAD),
        EventAnswerReceiver<Api::Call::EventRemoveBatch>(ThreadEnum::NULL_THREAD),
-       EventAnswerReceiver<Api::Call::EventRemoveAll>(ThreadEnum::NULL_THREAD),
-       EventAnswerReceiver<Api::Call::EventLaunchDialer>(ThreadEnum::NULL_THREAD),
-       EventAnswerReceiver<Api::Call::EventSendUSSD>(ThreadEnum::NULL_THREAD)
+       EventAnswerReceiver<Api::Call::EventRemoveAll>(ThreadEnum::NULL_THREAD)
 {
 }
 
 void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventFindCallHistoryPtr& event)
 {
-       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+       CallAsyncEventPrivateDataPtr privateData = DPL::DynamicPointerCast<CallAsyncEventPrivateData>(event->getPrivateData());
+       if (!privateData)
+               return;
 
+       JSCallbackManagerPtr data = privateData->getCallbackManager();
+       if (!data)
+               return;
+
+       JSValueRef thisObject = privateData->getObject();
+       JSValueUnprotect(data->getContext(), thisObject);
+       
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
                Converter converter(data->getContext());
                try {
                        data->callOnSuccess(converter.toJSValueRef(event->getResult(), data->getContext()));
                } catch(WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error"));
+               } catch(WrtDeviceApis::Commons::Exception) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error"));
                }
        } else {
                JSObjectRef jsException = NULL;
@@ -75,37 +84,19 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventFindCallHistoryP
 
 void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveBatchPtr& event)
 {
-       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+       CallAsyncEventPrivateDataPtr privateData = DPL::DynamicPointerCast<CallAsyncEventPrivateData>(event->getPrivateData());
+       if (!privateData)
+               return;
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Try {
-                       data->callOnSuccess();
-               } Catch(WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
-       } else {
-               JSObjectRef jsException = NULL;
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
-               } else {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
-               }
-               data->callOnError(jsException);
-       }
-}
+       JSCallbackManagerPtr data = privateData->getCallbackManager();
+       if (!data)
+               return;
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveAllPtr& event)
-{
-       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+       JSValueRef thisObject = privateData->getObject();
+       JSValueUnprotect(data->getContext(), thisObject);
 
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Try {
-                       data->callOnSuccess();
-               } Catch(WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
+               data->callOnSuccess();
        } else {
                JSObjectRef jsException = NULL;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
@@ -117,43 +108,21 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveAllPtr& ev
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventLaunchDialerPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveAllPtr& event)
 {
-       LogDebug("Enter");
-       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+       CallAsyncEventPrivateDataPtr privateData = DPL::DynamicPointerCast<CallAsyncEventPrivateData>(event->getPrivateData());
+       if (!privateData)
+               return;
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Try {
-                       data->callOnSuccess();
-               } Catch(WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error"));
-               }
-       } else {
-               JSObjectRef jsException = NULL;
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
-               } else {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
-               }
-               data->callOnError(jsException);
-       }
-}
+       JSCallbackManagerPtr data = privateData->getCallbackManager();
+       if (!data)
+               return;
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventSendUSSDPtr& event)
-{
-       LogDebug("Enter");
-
-       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+       JSValueRef thisObject = privateData->getObject();
+       JSValueUnprotect(data->getContext(), thisObject);
 
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Converter converter(data->getContext());
-               try {
-                       data->callOnSuccess(converter.toJSValueRef(event->getResult()));
-               } catch(WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
+               data->callOnSuccess();
        } else {
                JSObjectRef jsException = NULL;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
@@ -164,6 +133,7 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventSendUSSDPtr& eve
                data->callOnError(jsException);
        }
 }
+
 }
 } 
 
index d5b0e85..dfa71d3 100755 (executable)
 #include <API/Call/EventFindCallHistory.h>
 #include <API/Call/EventRemoveBatch.h>
 #include <API/Call/EventRemoveAll.h>
-#include <API/Call/EventLaunchDialer.h>
-#include <API/Call/EventSendUSSD.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
 class ResponseDispatcher : 
        public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventFindCallHistory>,
        public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventRemoveBatch>,
-       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventRemoveAll>,
-       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventLaunchDialer>,
-       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventSendUSSD>
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventRemoveAll>
 {
 public:
        static ResponseDispatcher& getInstance();
@@ -41,8 +37,6 @@ public:
        void OnAnswerReceived(const Api::Call::EventFindCallHistoryPtr& event);
        void OnAnswerReceived(const Api::Call::EventRemoveBatchPtr& event);
        void OnAnswerReceived(const Api::Call::EventRemoveAllPtr& event);
-       void OnAnswerReceived(const Api::Call::EventLaunchDialerPtr& event);
-       void OnAnswerReceived(const Api::Call::EventSendUSSDPtr& event);
 
 protected:
        ResponseDispatcher();
index 90fe78b..c88d577 100755 (executable)
@@ -9,12 +9,14 @@
 
        <api-feature>
                <name>http://tizen.org/api/call</name>
-               <device-capability>call</device-capability>
+               <device-capability>call.state</device-capability>
+               <device-capability>call.history.read</device-capability>
+               <device-capability>call.history.write</device-capability>
        </api-feature>
 
        <api-feature>
-               <name>http://tizen.org/api/call.simple</name>
-               <device-capability>call.simple</device-capability>
+               <name>http://tizen.org/api/call.state</name>
+               <device-capability>call.state</device-capability>
        </api-feature>
 
        <api-feature>
index 98f49fb..64025b8 100755 (executable)
@@ -24,7 +24,7 @@
 #include <Commons/Exception.h>
 
 #define CALL_FEATURE_API "http://tizen.org/api/call"
-#define CALL_SIMPLE_FEATURE_API "http://tizen.org/api/call.simple"
+#define CALL_STATE_FEATURE_API "http://tizen.org/api/call.state"
 #define CALL_HISTORY_FEATURE_API "http://tizen.org/api/call.history"
 #define CALL_HISTORY_FEATURE_API_READ "http://tizen.org/api/call.history.read"
 #define CALL_HISTORY_FEATURE_API_WRITE "http://tizen.org/api/call.history.write"
@@ -32,7 +32,7 @@
 namespace TizenApis {
 namespace Tizen1_0 {
 
-const char* CALL_DEVICE_CAP_SIMPLE = "call.simple";
+const char* CALL_DEVICE_CAP_STATE = "call.state";
 const char* CALL_HISTORY_DEVICE_CAP_READ = "call.history.read";
 const char* CALL_HISTORY_DEVICE_CAP_WRITE = "call.history.write";
 
@@ -44,9 +44,6 @@ const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER = "addListener";
 const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER = "removeListener";
 
 const char* CALL_FUNCTION_API_ISCALLINPROGRESS = "isCallInProgress";
-const char* CALL_FUNCTION_API_GETCALLSERVICES = "getCallServices";
-const char* CALL_FUNCTION_API_SENDUSSD = "sendUSSD";
-const char* CALL_FUNCTION_API_LAUNCHDIALER = "launchDialer";
 
 
 static WrtDeviceApis::Commons::FunctionMapping createCallFunctions();
@@ -59,14 +56,14 @@ static WrtDeviceApis::Commons::FunctionMapping createCallFunctions()
 {
        using namespace WrtDeviceApis::Commons;
 
-       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_SIMPLE, CALL_DEVICE_CAP_SIMPLE);
+       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_STATE, CALL_DEVICE_CAP_STATE);
        ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_HISTORY_READ, CALL_HISTORY_DEVICE_CAP_READ);
        ACE_CREATE_DEVICE_CAP(DEVICE_CAP_CALL_HISTORY_WRITE, CALL_HISTORY_DEVICE_CAP_WRITE);
 
        ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
 
-       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALL_SIMPLE);
-       ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_SIMPLE, DEVICE_CAP_CALL_SIMPLE);
+       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALL_STATE);
+       ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_STATE, DEVICE_CAP_CALL_STATE);
 
        ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_CALL_HISTORY_READ);
        ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_HISTORY_READ, DEVICE_CAP_CALL_HISTORY_READ);
@@ -75,14 +72,14 @@ static WrtDeviceApis::Commons::FunctionMapping createCallFunctions()
        ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_HISTORY_WRITE, DEVICE_CAP_CALL_HISTORY_WRITE);
 
        ACE_CREATE_FEATURE(FEATURE_CALL, CALL_FEATURE_API);
-       ACE_CREATE_FEATURE(FEATURE_CALL_SIMPLE, CALL_SIMPLE_FEATURE_API);
+       ACE_CREATE_FEATURE(FEATURE_CALL_STATE, CALL_STATE_FEATURE_API);
        ACE_CREATE_FEATURE(FEATURE_CALL_HISTORY, CALL_HISTORY_FEATURE_API);
        ACE_CREATE_FEATURE(FEATURE_CALL_HISTORY_READ, CALL_HISTORY_FEATURE_API_READ);
        ACE_CREATE_FEATURE(FEATURE_CALL_HISTORY_WRITE, CALL_HISTORY_FEATURE_API_WRITE);
 
-       ACE_CREATE_FEATURE_LIST(CALL_FEATURES_CALL_SIMPLE);
-       ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_SIMPLE, FEATURE_CALL);
-       ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_SIMPLE, FEATURE_CALL_SIMPLE);
+       ACE_CREATE_FEATURE_LIST(CALL_FEATURES_CALL_STATE);
+       ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_STATE, FEATURE_CALL);
+       ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_STATE, FEATURE_CALL_STATE);
 
        ACE_CREATE_FEATURE_LIST(CALL_FEATURES_CALL_HISTORY_READ_WRITE);
        ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_HISTORY_READ_WRITE, FEATURE_CALL);
@@ -153,35 +150,11 @@ static WrtDeviceApis::Commons::FunctionMapping createCallFunctions()
        AceFunction isCallInProgressFunc = ACE_CREATE_FUNCTION(
                        FUNCTION_IS_CALL_IN_PROGRESS,
                        CALL_FUNCTION_API_ISCALLINPROGRESS,
-                       CALL_FEATURES_CALL_SIMPLE,
+                       CALL_FEATURES_CALL_STATE,
                        EMPTY_DEVICE_LIST);
 
        CallMapping.insert(std::make_pair(CALL_FUNCTION_API_ISCALLINPROGRESS, isCallInProgressFunc));
 
-       AceFunction getCallServicesFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_GET_CALL_SERVICES,
-                       CALL_FUNCTION_API_GETCALLSERVICES,
-                       CALL_FEATURES_CALL_SIMPLE,
-                       EMPTY_DEVICE_LIST);
-
-       CallMapping.insert(std::make_pair(CALL_FUNCTION_API_GETCALLSERVICES, getCallServicesFunc));
-
-       AceFunction sendUSSDFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_SEND_USSD,
-                       CALL_FUNCTION_API_SENDUSSD,
-                       CALL_FEATURES_CALL_SIMPLE,
-                       EMPTY_DEVICE_LIST);
-
-       CallMapping.insert(std::make_pair(CALL_FUNCTION_API_SENDUSSD, sendUSSDFunc));
-
-       AceFunction launchDialerFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_LAUNCH_DIALER,
-                       CALL_FUNCTION_API_LAUNCHDIALER,
-                       CALL_FEATURES_CALL_SIMPLE,
-                       EMPTY_DEVICE_LIST);
-
-       CallMapping.insert(std::make_pair(CALL_FUNCTION_API_LAUNCHDIALER, launchDialerFunc));
-
        return CallMapping;
 }
 
index 6a3b5c6..9f6220d 100755 (executable)
@@ -31,9 +31,6 @@ extern const char* CALL_HISTORY_FUNCTION_API_ADDLISTENER;
 extern const char* CALL_HISTORY_FUNCTION_API_REMOVELISTENER;
 
 extern const char* CALL_FUNCTION_API_ISCALLINPROGRESS;
-extern const char* CALL_FUNCTION_API_GETCALLSERVICES;
-extern const char* CALL_FUNCTION_API_SENDUSSD;
-extern const char* CALL_FUNCTION_API_LAUNCHDIALER;
 
 DECLARE_FUNCTION_GETTER(Call);
 
@@ -43,10 +40,9 @@ DECLARE_FUNCTION_GETTER(Call);
 namespace WrtDeviceApis {
 namespace Commons {
 
-#define CALL_CHECK_ACCESS(globalContext, functionName) \
+#define CALL_CHECK_ACCESS(functionName) \
     WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter, \
     WrtDeviceApis::Commons::DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getCallFunctionData,         \
         functionName)
 }
index 385c30f..dad7585 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include <Commons/Exception.h>
 #include "JSCallManager.h"
 
 #define CALL "call"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+void on_widget_start_callback(int widgetId) {
+       LogDebug("[Tizen\\call] on_widget_start_callback (" << widgetId << ")");
+       try {
+               WrtAccessSingleton::Instance().initialize(widgetId);
+       } catch(WrtDeviceApis::Commons::Exception) {
+               LogError("WrtAccess initialization failed");
+       }
 }
 
 void on_widget_stop_callback(int widgetId) {
+       LogDebug("[Tizen\\call] on_widget_stop_callback (" << widgetId << ")");
+       try {
+               WrtAccessSingleton::Instance().deinitialize(widgetId);
+       } catch(WrtDeviceApis::Commons::Exception) {
+               LogError("WrtAccess deinitialization failed");
+       }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index 849ea56..f1e1038 100755 (executable)
@@ -2,7 +2,7 @@ set(SRCS
   JSTizenException.cpp
   TizenExceptionData.cpp
   JSTizenExceptionFactory.cpp
-  JSGlobalContextFactory.cpp
+  JSWebAPIError.cpp
 )
 
 add_library(${COMMON_TARGET_NAME} SHARED ${SRCS})
diff --git a/src/standards/Tizen/Common/JSGlobalContextFactory.cpp b/src/standards/Tizen/Common/JSGlobalContextFactory.cpp
deleted file mode 100644 (file)
index b896083..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        JSGlobalContextFactory.h
- * @author      Kisub Song (kisubs.song@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#include "JSGlobalContextFactory.h"
-#include <stdio.h>
-
-namespace TizenApis {
-namespace Commons {
-
-JSGlobalContextFactory::JSGlobalContextFactory()
-{
-       m_ref = JSGlobalContextCreate(NULL);
-       printf("JSGlobalContextCreate (0x%08x)\n", (unsigned int)m_ref);
-}
-
-JSGlobalContextFactory::~JSGlobalContextFactory()
-{
-       if (m_ref != NULL) {
-               JSGlobalContextRelease(m_ref);
-               printf("JSGlobalContextRelease (0x%08x)\n", (unsigned int)m_ref);
-       }
-}
-
-JSGlobalContextRef JSGlobalContextFactory::get() const
-{
-       return m_ref;
-}
-
-JSGlobalContextFactoryPtr JSGlobalContextFactory::getInstance()
-{
-       static JSGlobalContextFactoryPtr factory(NULL);
-
-       if(factory == NULL)
-       {
-               factory = JSGlobalContextFactoryPtr(new JSGlobalContextFactory());
-       }
-
-       return factory;
-}
-
-} // Commons
-} // TizenApis
diff --git a/src/standards/Tizen/Common/JSGlobalContextFactory.h b/src/standards/Tizen/Common/JSGlobalContextFactory.h
deleted file mode 100644 (file)
index 631cf40..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * @file        JSGlobalContextFactory.h
- * @author      Kisub Song (kisubs.song@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef _TIZENAPIS_COMMONS_JS_GLOBAL_CONTEXT_FACTORY_H_
-#define _TIZENAPIS_COMMONS_JS_GLOBAL_CONTEXT_FACTORY_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <dpl/noncopyable.h>
-#include <dpl/shared_ptr.h>
-
-namespace TizenApis {
-namespace Commons {
-
-class JSGlobalContextFactory;
-typedef DPL::SharedPtr<JSGlobalContextFactory> JSGlobalContextFactoryPtr;
-
-class JSGlobalContextFactory : private DPL::Noncopyable
-{
-private:
-       JSGlobalContextRef m_ref;
-
-private:
-       JSGlobalContextFactory();
-
-public:
-       ~JSGlobalContextFactory();
-
-       JSGlobalContextRef get() const;
-
-       static JSGlobalContextFactoryPtr getInstance();
-};
-
-} // Commons
-} // TizenApis
-
-#endif // _TIZENAPIS_COMMONS_JS_GLOBAL_CONTEXT_FACTORY_H_
-
index 9016725..96d5401 100644 (file)
 namespace TizenApis {
        namespace Commons {
 
-               const std::string JSTizenException::UNKNOWN_ERROR           = "UNKNOWN_ERROR";
-               const std::string JSTizenException::TYPE_MISMATCH_ERROR     = "TYPE_MISMATCH_ERROR";
-               const std::string JSTizenException::INVALID_VALUES_ERROR    = "INVALID_VALUES_ERROR";
-               const std::string JSTizenException::TIMEOUT_ERROR           = "TIMEOUT_ERROR";
-               const std::string JSTizenException::IO_ERROR                = "IO_ERROR";
-               const std::string JSTizenException::NOT_SUPPORTED_ERROR     = "NOT_SUPPORTED_ERROR";
-               const std::string JSTizenException::PERMISSION_DENIED_ERROR = "PERMISSION_DENIED_ERROR";
-               const std::string JSTizenException::NOT_FOUND_ERROR         = "NOT_FOUND_ERROR";
+               const std::string JSTizenException::UNKNOWN_ERROR           = "UnknownError";
+               const std::string JSTizenException::TYPE_MISMATCH_ERROR     = "TypeMismatchError";
+               const std::string JSTizenException::INVALID_VALUES_ERROR    = "InvalidValuesError";
+               const std::string JSTizenException::TIMEOUT_ERROR           = "TimeoutError";
+               const std::string JSTizenException::IO_ERROR                = "IOError";
+               const std::string JSTizenException::NOT_SUPPORTED_ERROR     = "NotSupportedError";
+               const std::string JSTizenException::PERMISSION_DENIED_ERROR = "SecurityError";
+               const std::string JSTizenException::NOT_FOUND_ERROR         = "NotFoundError";
+               const std::string JSTizenException::SERVICE_NOT_AVAILABLE   = "ServiceNotAvailableError";
+               const std::string JSTizenException::NETWORK_ERROR           = "NetworkError";
 
                namespace{
                        #define PLUGIN_NAME       "TizenException"
@@ -46,6 +48,7 @@ namespace TizenApis {
                                        TizenApis::Commons::JSTizenException::NOT_SUPPORTED_ERROR,
                                        TizenApis::Commons::JSTizenException::PERMISSION_DENIED_ERROR,
                                        TizenApis::Commons::JSTizenException::NOT_FOUND_ERROR,
+                                       TizenApis::Commons::JSTizenException::NETWORK_ERROR,
                        };
                }
 
@@ -116,16 +119,16 @@ namespace TizenApis {
                                return JSValueMakeUndefined(context);
                        }
 
-                       WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-                       try {
-                               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME)) {
-                                       return converter.toJSValueRef(privateObject->getObject()->getName());
-                               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MESSAGE)) {
-                                       return converter.toJSValueRef(privateObject->getObject()->getMessage());
-                               }
-                       } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
-                               LogError("Exception: " << ex.GetMessage());
-                       }
+//                     WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+//                     try {
+//                             if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME)) {
+//                                     return converter.toJSValueRef(privateObject->getObject()->getName());
+//                             } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MESSAGE)) {
+//                                     return converter.toJSValueRef(privateObject->getObject()->getMessage());
+//                             }
+//                     } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
+//                             LogError("Exception: " << ex.GetMessage());
+//                     }
 
                        return JSValueMakeUndefined(context);
                }
index af0e248..d4e7328 100644 (file)
@@ -26,6 +26,10 @@ namespace TizenApis {
 
        namespace Commons {
 
+               /**
+                * @deprecated
+                * TizenException is deprecated. use JSWebAPIError instead.
+               */
                class JSTizenException {
                        public:
                                typedef  WrtDeviceApis::CommonsJavaScript::PrivateObjectT<TizenExceptionDataPtr>::Type PrivateObject;
@@ -39,7 +43,8 @@ namespace TizenApis {
                                static const std::string NOT_SUPPORTED_ERROR;
                                static const std::string PERMISSION_DENIED_ERROR;
                                static const std::string NOT_FOUND_ERROR;
-
+                               static const std::string SERVICE_NOT_AVAILABLE;
+                               static const std::string NETWORK_ERROR;
                          public:
                                static JSClassRef getClassRef();
 
index 6311ae9..2719bae 100644 (file)
 #include <CommonsJavaScript/JSUtils.h>
 
 #include "TizenExceptionData.h"
-#include "JSTizenException.h"
+#include "JSWebAPIError.h"
 
 namespace TizenApis {
 
        namespace Commons {
+
                JSTizenExceptionFactory::JSTizenExceptionFactory() {
                }
 
@@ -34,14 +35,20 @@ namespace TizenApis {
                }
 
                JSObjectRef JSTizenExceptionFactory::makeErrorObject(JSContextRef context, const std::string& name, const std::string& message) {
-                       JSTizenException::PrivateObject::ObjectType data(new TizenExceptionData(name, message));
-                       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(context, JSTizenException::getClassRef(), data);
+
+                       int code = JSWebAPIError::convertToWebAPIErrorCode(name);
+
+                       JSWebAPIError::PrivateObject::ObjectType data(new TizenExceptionData(code, name, message));
+                       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(context, JSWebAPIError::getClassRef(), data);
                }
 
                JSValueRef JSTizenExceptionFactory::postException(JSContextRef context, JSValueRef* exception, const std::string& name, const std::string& message) {
                        Assert(exception && "Exception object can't be NULL.");
-                       JSTizenException::PrivateObject::ObjectType data(new TizenExceptionData(name, message));
-                       *exception = WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(context, JSTizenException::getClassRef(), data);
+
+                       int code = JSWebAPIError::convertToWebAPIErrorCode(name);
+
+                       JSWebAPIError::PrivateObject::ObjectType data(new TizenExceptionData(code, name, message));
+                       *exception = WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(context, JSWebAPIError::getClassRef(), data);
                        return JSValueMakeUndefined(context);
                }
 
diff --git a/src/standards/Tizen/Common/JSWebAPIError.cpp b/src/standards/Tizen/Common/JSWebAPIError.cpp
new file mode 100644 (file)
index 0000000..3b794c2
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#include "JSWebAPIError.h"
+
+#include <dpl/log/log.h>
+
+#include <CommonsJavaScript/Converter.h>
+
+namespace TizenApis {
+       namespace Commons {
+
+               namespace{
+                       #define PLUGIN_NAME       "WebAPIError"
+                       #define PROPERTY_CODE     "code"
+                       #define PROPERTY_NAME     "name"
+                       #define PROPERTY_TYPE     "type"
+                       #define PROPERTY_MESSAGE  "message"
+
+                       #define PROPERTY_UNKNOWN_ERR                              "UNKNOWN_ERR"
+                       #define PROPERTY_INDEX_SIZE_ERR                           "INDEX_SIZE_ERR"
+                       #define PROPERTY_DOMSTRING_SIZE_ERR                       "DOMSTRING_SIZE_ERR"
+                       #define PROPERTY_HIERARCHY_REQUEST_ERR                    "HIERARCHY_REQUEST_ERR"
+                       #define PROPERTY_WRONG_DOCUMENT_ERR                       "WRONG_DOCUMENT_ERR"
+                       #define PROPERTY_INVALID_CHARACTER_ERR                    "INVALID_CHARACTER_ERR"
+                       #define PROPERTY_NO_DATA_ALLOWED_ERR                      "NO_DATA_ALLOWED_ERR"
+                       #define PROPERTY_NO_MODIFICATION_ALLOWED_ERR              "NO_MODIFICATION_ALLOWED_ERR"
+                       #define PROPERTY_NOT_FOUND_ERR                            "NOT_FOUND_ERR"
+                       #define PROPERTY_NOT_SUPPORTED_ERR                        "NOT_SUPPORTED_ERR"
+                       #define PROPERTY_INUSE_ATTRIBUTE_ERR                      "INUSE_ATTRIBUTE_ERR"
+                       #define PROPERTY_INVALID_STATE_ERR                        "INVALID_STATE_ERR"
+                       #define PROPERTY_SYNTAX_ERR                               "SYNTAX_ERR"
+                       #define PROPERTY_INVALID_MODIFICATION_ERR                 "INVALID_MODIFICATION_ERR"
+                       #define PROPERTY_NAMESPACE_ERR                            "NAMESPACE_ERR"
+                       #define PROPERTY_INVALID_ACCESS_ERR                       "INVALID_ACCESS_ERR"
+                       #define PROPERTY_VALIDATION_ERR                           "VALIDATION_ERR"
+                       #define PROPERTY_TYPE_MISMATCH_ERR                        "TYPE_MISMATCH_ERR"
+                       #define PROPERTY_SECURITY_ERR                             "SECURITY_ERR"
+                       #define PROPERTY_NETWORK_ERR                              "NETWORK_ERR"
+                       #define PROPERTY_ABORT_ERR                                "ABORT_ERR"
+                       #define PROPERTY_TIMEOUT_ERR                              "TIMEOUT_ERR"
+                       #define PROPERTY_INVALID_VALUES_ERR                       "INVALID_VALUES_ERR"
+                       #define PROPERTY_IO_ERR                                   "IO_ERR"
+                       #define PROPERTY_OUT_OF_MEMORY_ERR                        "OUT_OF_MEMORY_ERR"
+                       #define PROPERTY_NOT_CONNECTED_SERVICE_ERR                "NOT_CONNECTED_SERVICE_ERR"
+                       #define PROPERTY_FAIL_TO_REQUEST_ERR                      "FAIL_TO_REQUEST_ERR"
+                       #define PROPERTY_INVALID_RESPONSE_ERR                     "INVALID_RESPONSE_ERR"
+                       #define PROPERTY_NO_AVAILABLE_NETWORK_ERR                 "NO_AVAILABLE_NETWORK_ERR"
+                       #define PROPERTY_INVALID_DEVICE_ERR                       "INVALID_DEVICE_ERR"
+                       #define PROPERTY_NOT_SUPPORTED_FUNCTION_ERR               "NOT_SUPPORTED_FUNCTION_ERR"
+                       #define PROPERTY_NO_PERMISSION_ERR                        "NO_PERMISSION_ERR"
+                       #define PROPERTY_INVALID_ITEM_ERR                         "INVALID_ITEM_ERR"
+                       #define PROPERTY_FAIL_TO_PLAY_ERR                         "FAIL_TO_PLAY_ERR"
+                       #define PROPERTY_SERVICE_NOT_AVAILABLE                    "SERVICE_NOT_AVAILABLE"
+                       #define PROPERTY_AVPLAY_NETWORK_DISCONNECTED_ERR          "AVPLAY_NETWORK_DISCONNECTED_ERR"
+                       #define PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_FORMAT_ERR      "AVPLAY_UNSUPPORTED_VIDEO_FORMAT_ERR"
+                       #define PROPERTY_AVPLAY_UNSUPPORTED_AUDIO_FORMAT_ERR      "AVPLAY_UNSUPPORTED_AUDIO_FORMAT_ERR"
+                       #define PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_RESOLUTION_ERR  "AVPLAY_UNSUPPORTED_VIDEO_RESOLUTION_ERR"
+                       #define PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_FRAMERATE_ERR   "AVPLAY_UNSUPPORTED_VIDEO_FRAMERATE_ERR"
+                       #define PROPERTY_AVPLAY_CURRUPTED_STREAM_ERR              "AVPLAY_CURRUPTED_STREAM_ERR"
+               }
+
+               JSClassRef JSWebAPIError::m_classRef = NULL;
+
+               JSClassDefinition JSWebAPIError::m_classInfo = {
+                       0,
+                       kJSClassAttributeNone,
+                       PLUGIN_NAME,
+                       0,
+                       m_properties,
+                       NULL, //__function,
+                       initialize,
+                       finalize,
+                       NULL,
+                       NULL,
+                       NULL, //SetProperty,
+                       NULL, //DeleteProperty,
+                       NULL,
+                       NULL, //CallAsFunction,
+                       NULL, //CallAsConstructor,
+                       hasInstance,
+                       NULL, //ConvertToType,
+               };
+
+               JSStaticValue JSWebAPIError::m_properties[] = {
+                       { PROPERTY_CODE,    getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NAME,    getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_TYPE,    getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_MESSAGE, getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+
+                       { PROPERTY_UNKNOWN_ERR,                             getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INDEX_SIZE_ERR,                          getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_DOMSTRING_SIZE_ERR,                      getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_HIERARCHY_REQUEST_ERR,                   getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_WRONG_DOCUMENT_ERR,                      getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_CHARACTER_ERR,                   getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NO_DATA_ALLOWED_ERR,                     getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NO_MODIFICATION_ALLOWED_ERR,             getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NOT_FOUND_ERR,                           getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NOT_SUPPORTED_ERR,                       getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INUSE_ATTRIBUTE_ERR,                     getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_STATE_ERR,                       getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_SYNTAX_ERR,                              getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_MODIFICATION_ERR,                getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NAMESPACE_ERR,                           getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_ACCESS_ERR,                      getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_VALIDATION_ERR,                          getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_TYPE_MISMATCH_ERR,                       getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_SECURITY_ERR,                            getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NETWORK_ERR,                             getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_ABORT_ERR,                               getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_TIMEOUT_ERR,                             getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_VALUES_ERR,                      getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_IO_ERR,                                  getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_OUT_OF_MEMORY_ERR,                       getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NOT_CONNECTED_SERVICE_ERR,               getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_FAIL_TO_REQUEST_ERR,                     getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_RESPONSE_ERR,                    getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NO_AVAILABLE_NETWORK_ERR,                getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_DEVICE_ERR,                      getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NOT_SUPPORTED_FUNCTION_ERR,              getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_NO_PERMISSION_ERR,                       getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_INVALID_ITEM_ERR,                        getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_FAIL_TO_PLAY_ERR,                        getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_SERVICE_NOT_AVAILABLE,                   getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_NETWORK_DISCONNECTED_ERR,         getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_FORMAT_ERR,     getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_UNSUPPORTED_AUDIO_FORMAT_ERR,     getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_RESOLUTION_ERR, getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_UNSUPPORTED_VIDEO_FRAMERATE_ERR,  getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { PROPERTY_AVPLAY_CURRUPTED_STREAM_ERR,             getStaticProperty, NULL, kJSPropertyAttributeReadOnly },
+                       { 0, 0, 0, 0 }
+               };
+
+               const JSClassDefinition* JSWebAPIError::getClassInfo() {
+                       return &m_classInfo;
+               }
+
+               JSClassRef JSWebAPIError::getClassRef() {
+                       if (!m_classRef) {
+                               m_classRef = JSClassCreate(&m_classInfo);
+                       }
+                       return m_classRef;
+               }
+
+               void JSWebAPIError::initialize(JSContextRef /*context*/, JSObjectRef /*object*/) {
+               }
+
+               void JSWebAPIError::finalize(JSObjectRef object) {
+                       PrivateObject* privateObject = static_cast<PrivateObject*> (JSObjectGetPrivate(object));
+                       if (privateObject) {
+                               JSObjectSetPrivate(object, NULL);
+                               delete privateObject;
+                       }
+               }
+
+               JSValueRef JSWebAPIError::getStaticProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* /*exception*/) {
+                       PrivateObject* privateObject = static_cast<PrivateObject*> (JSObjectGetPrivate(object));
+                       if (!privateObject) {
+                               LogError("Private object is not set.");
+                               return JSValueMakeUndefined(context);
+                       }
+
+                       WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+                       try {
+                               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_CODE)) {
+                                       LogDebug("propertyName PROPERTY_CODE");
+                                       return converter.toJSValueRef(privateObject->getObject()->getCode());
+                               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME)) {
+                                       return converter.toJSValueRef(privateObject->getObject()->getName());
+                               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_TYPE)) {
+                                       return converter.toJSValueRef(privateObject->getObject()->getName());
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MESSAGE)) {
+                                       return converter.toJSValueRef(privateObject->getObject()->getMessage());
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_UNKNOWN_ERR)) {
+                                       return converter.toJSValueRef(UNKNOWN_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INDEX_SIZE_ERR)) {
+                                       return converter.toJSValueRef(INDEX_SIZE_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_DOMSTRING_SIZE_ERR)) {
+                                       return converter.toJSValueRef(DOMSTRING_SIZE_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_HIERARCHY_REQUEST_ERR)) {
+                                       return converter.toJSValueRef(HIERARCHY_REQUEST_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_WRONG_DOCUMENT_ERR)) {
+                                       return converter.toJSValueRef(WRONG_DOCUMENT_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INVALID_CHARACTER_ERR)) {
+                                       return converter.toJSValueRef(INVALID_CHARACTER_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NO_DATA_ALLOWED_ERR)) {
+                                       return converter.toJSValueRef(NO_DATA_ALLOWED_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NO_MODIFICATION_ALLOWED_ERR)) {
+                                       return converter.toJSValueRef(NO_MODIFICATION_ALLOWED_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NOT_FOUND_ERR)) {
+                                       return converter.toJSValueRef(NOT_FOUND_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NOT_SUPPORTED_ERR)) {
+                                       return converter.toJSValueRef(NOT_SUPPORTED_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INUSE_ATTRIBUTE_ERR)) {
+                                       return converter.toJSValueRef(INUSE_ATTRIBUTE_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INVALID_STATE_ERR)) {
+                                       return converter.toJSValueRef(INVALID_STATE_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_SYNTAX_ERR)) {
+                                       return converter.toJSValueRef(SYNTAX_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INVALID_MODIFICATION_ERR)) {
+                                       return converter.toJSValueRef(INVALID_MODIFICATION_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMESPACE_ERR)) {
+                                       return converter.toJSValueRef(NAMESPACE_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_INVALID_ACCESS_ERR)) {
+                                       return converter.toJSValueRef(INVALID_ACCESS_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_VALIDATION_ERR)) {
+                                       return converter.toJSValueRef(VALIDATION_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_TYPE_MISMATCH_ERR)) {
+                                       return converter.toJSValueRef(TYPE_MISMATCH_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_SECURITY_ERR)) {
+                                       return converter.toJSValueRef(SECURITY_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NETWORK_ERR)) {
+                                       return converter.toJSValueRef(NETWORK_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_ABORT_ERR)) {
+                                       return converter.toJSValueRef(ABORT_ERR);
+                               }else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_TIMEOUT_ERR)) {
+                                       return converter.toJSValueRef(TIMEOUT_ERR);
+                               }else{
+                                       LogDebug("propertyName not supported");
+                                       return converter.toJSValueRef(UNKNOWN_ERR);
+                               }
+                       } catch (const WrtDeviceApis::Commons::ConversionException& ex) {
+                               LogError("Exception: " << ex.GetMessage());
+                       }
+
+                       return JSValueMakeUndefined(context);
+               }
+
+               bool JSWebAPIError::hasInstance(JSContextRef context, JSObjectRef /*constructor*/, JSValueRef possibleInstance, JSValueRef* /*exception*/) {
+                       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+               }
+
+               int JSWebAPIError::convertToWebAPIErrorCode(const std::string& errorName){
+                       LogDebug("<<< errorName:[" << errorName << "]");
+
+                       int retErrorCode = -1;
+
+                       if(errorName.compare(JSTizenException::UNKNOWN_ERROR) == 0){
+                               retErrorCode = UNKNOWN_ERR;
+                       }else if(errorName.compare(JSTizenException::NOT_FOUND_ERROR) == 0){
+                               retErrorCode = NOT_FOUND_ERR;
+                       }else if(errorName.compare(JSTizenException::NOT_SUPPORTED_ERROR) == 0){
+                               retErrorCode = NOT_SUPPORTED_ERR;
+                       }else if(errorName.compare(JSTizenException::TYPE_MISMATCH_ERROR) == 0){
+                               retErrorCode = TYPE_MISMATCH_ERR;
+                       }else if(errorName.compare(JSTizenException::PERMISSION_DENIED_ERROR) == 0){
+                               retErrorCode = SECURITY_ERR;
+                       }else if(errorName.compare(JSTizenException::TIMEOUT_ERROR) == 0){
+                               retErrorCode = TIMEOUT_ERR;
+                       }else if(errorName.compare(JSTizenException::INVALID_VALUES_ERROR) == 0){
+                               retErrorCode = 0;
+                       }else if(errorName.compare(JSTizenException::IO_ERROR) == 0){
+                               retErrorCode = 0;
+                       }else if(errorName.compare(JSTizenException::SERVICE_NOT_AVAILABLE) == 0){
+                               retErrorCode = 0;
+                       }else if(errorName.compare(JSTizenException::NETWORK_ERROR) == 0){
+                               retErrorCode = NETWORK_ERR;
+                       }else{
+                               retErrorCode = UNKNOWN_ERR;
+                       }
+
+                       LogDebug(">>> retERrorCode:" << retErrorCode );
+                       return retErrorCode;
+               }
+
+       } /* namespace Commons */
+} /* namespace TizenApis */
diff --git a/src/standards/Tizen/Common/JSWebAPIError.h b/src/standards/Tizen/Common/JSWebAPIError.h
new file mode 100644 (file)
index 0000000..276494a
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ *    Licensed under the Apache License, Version 2.0 (the "License");
+ *    you may not use this file except in compliance with the License.
+ *    You may obtain a copy of the License at
+ *
+ *        http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *    Unless required by applicable law or agreed to in writing, software
+ *    distributed under the License is distributed on an "AS IS" BASIS,
+ *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *    See the License for the specific language governing permissions and
+ *    limitations under the License.
+ */
+
+#ifndef JSWEBAPIERROR_H_
+#define JSWEBAPIERROR_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+
+#include "JSTizenException.h"
+
+namespace TizenApis {
+       namespace Commons {
+
+               class JSWebAPIError {
+                       public:
+                               typedef  WrtDeviceApis::CommonsJavaScript::PrivateObjectT<TizenExceptionDataPtr>::Type PrivateObject;
+
+                               static JSClassRef getClassRef();
+                               static const JSClassDefinition* getClassInfo();
+
+                               static int convertToWebAPIErrorCode(const std::string& errorName);
+
+                       private:
+                               /**
+                                * The callback invoked when an object is first created.
+                                */
+                               static void initialize(JSContextRef context, JSObjectRef object);
+
+                               /**
+                                * The callback invoked when an object is finalized.
+                                */
+                               static void finalize(JSObjectRef object);
+
+                               /**
+                                * The callback invoked when getting a property's value.
+                                */
+                               static JSValueRef getStaticProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+                               /**
+                                * The callback invoked when an object is used as the target of an 'instanceof' expression.
+                                */
+                               static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+                               /**
+                                * This structure contains properties and callbacks that define a type of object.
+                                */
+                               static JSClassDefinition m_classInfo;
+
+                               /**
+                                * This structure describes a statically declared value property.
+                                */
+                               static JSStaticValue m_properties[];
+
+                               static JSClassRef m_classRef;
+
+                       public:
+                               enum{
+                                       UNKNOWN_ERR                              = 0,
+                                       INDEX_SIZE_ERR                           = 1,
+                                       DOMSTRING_SIZE_ERR                       = 2,
+                                       HIERARCHY_REQUEST_ERR                    = 3,
+                                       WRONG_DOCUMENT_ERR                       = 4,
+                                       INVALID_CHARACTER_ERR                    = 5,
+                                       NO_DATA_ALLOWED_ERR                      = 6,
+                                       NO_MODIFICATION_ALLOWED_ERR              = 7,
+                                       NOT_FOUND_ERR                            = 8,
+                                       NOT_SUPPORTED_ERR                        = 9,
+                                       INUSE_ATTRIBUTE_ERR                      = 10,
+                                       INVALID_STATE_ERR                        = 11,
+                                       SYNTAX_ERR                               = 12,
+                                       INVALID_MODIFICATION_ERR                 = 13,
+                                       NAMESPACE_ERR                            = 14,
+                                       INVALID_ACCESS_ERR                       = 15,
+                                       VALIDATION_ERR                           = 16,
+                                       TYPE_MISMATCH_ERR                        = 17,
+                                       SECURITY_ERR                             = 18,
+                                       NETWORK_ERR                              = 19,
+                                       ABORT_ERR                                = 20,
+
+                                       TIMEOUT_ERR                              = 23,
+
+                               };      //WebAPIError
+               };
+
+       } /* namespace Commons */
+} /* namespace TizenApis */
+#endif /* JSWEBAPIERROR_H_ */
index 12a3076..5eee124 100644 (file)
 namespace TizenApis {
        namespace Commons {
 
-               TizenExceptionData::TizenExceptionData(const std::string& name, const std::string& message) :
-               m_name(name), m_message(message) {
+               TizenExceptionData::TizenExceptionData(int code, const std::string& name, const std::string& message) :
+               m_code(code), m_name(name), m_message(message) {
                }
 
                TizenExceptionData::~TizenExceptionData() {
                }
 
+               int TizenExceptionData::getCode() const {
+                       return m_code;
+               }
+
                std::string TizenExceptionData::getName() const {
                        return m_name;
                }
@@ -31,6 +35,5 @@ namespace TizenApis {
                std::string TizenExceptionData::getMessage() const {
                        return m_message;
                }
-
        } // Commons
 } // TizenApis
old mode 100644 (file)
new mode 100755 (executable)
index 5cd3b33..b7d27fd
@@ -25,13 +25,15 @@ namespace Commons {
 
 class TizenExceptionData {
        public:
-               TizenExceptionData(const std::string& name, const std::string& message = std::string());
+               TizenExceptionData(int code, const std::string& name, const std::string& message = std::string());
                virtual ~TizenExceptionData();
 
+               int getCode() const;
                std::string getName() const;
                std::string getMessage() const;
 
        private :
+               int m_code;
                std::string m_name;
                std::string m_message;
 };
index 78f757f..4e327fc 100755 (executable)
@@ -64,6 +64,11 @@ void AddressBookAsyncAnswerHandler::addBatch(const EventAddressBookAddBatchPtr &
                return;
        }
 
+       if(event->checkCancelled()) {
+               LogDebug("Operation cancelled");
+               return;
+       }
+
        JSContextRef gContext = callbackManager->getContext();
 
        JSValueRef error = NULL;
@@ -119,6 +124,11 @@ void AddressBookAsyncAnswerHandler::updateBatch(const EventAddressBookUpdateBatc
                return;
        }
 
+       if(event->checkCancelled()) {
+               LogDebug("Operation cancelled");
+               return;
+       }
+
        JSContextRef gContext = callbackManager->getContext();
 
        JSValueRef error = NULL;
@@ -160,6 +170,11 @@ void AddressBookAsyncAnswerHandler::removeBatch(const EventAddressBookRemoveBatc
                return;
        }
 
+       if(event->checkCancelled()) {
+               LogDebug("Operation cancelled");
+               return;
+       }
+
        JSContextRef gContext = callbackManager->getContext();
 
        JSValueRef error = NULL;
@@ -201,6 +216,11 @@ void AddressBookAsyncAnswerHandler::find(const EventAddressBookFindPtr &event)
                return;
        }
 
+       if(event->checkCancelled()) {
+               LogDebug("Operation cancelled");
+               return;
+       }
+
        JSContextRef gContext = callbackManager->getContext();
 
        JSValueRef error = NULL;
@@ -387,20 +407,6 @@ void AddressBookAsyncAnswerHandler::changeListenerContactRemoved(const EventAddr
        cbm->callOnContactsAdded(contactIds);
 }
 
-void AddressBookAsyncAnswerHandler::changeListenerAddressBookReset(const EventAddressBookChangeListenerPtr &event)
-{
-       LogDebug("entered");
-       JSAddressBookChangeCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSAddressBookChangeCallbackManager>(event->getPrivateData());
-       if (!cbm)
-       {
-               LogError("no callback manager");
-               return;
-       }
-
-       cbm->callOnAddressBookReset();
-}
-
 void AddressBookController::OnAnswerReceived(const EventAddressBookAddBatchPtr &event)
 {
        AddressBookAsyncAnswerHandler::addBatch(event);
@@ -437,32 +443,10 @@ void AddressBookController::onAnswerReceived(const EventAddressBookChangeListene
                AddressBookAsyncAnswerHandler::changeListenerContactUpdated(event);
        else if(type == EventInfoAddressBookChange::OnContactsRemoved)
                AddressBookAsyncAnswerHandler::changeListenerContactRemoved(event);
-       else if(type == EventInfoAddressBookChange::OnAddressBookReset)
-               AddressBookAsyncAnswerHandler::changeListenerAddressBookReset(event);
        else if(type == EventInfoAddressBookChange::OnError)
                AddressBookAsyncAnswerHandler::changeListenerError(event);
 }
 
-void AddressBookAddBatchPendingOperation::handleCallingCallbacks()
-{
-       AddressBookAsyncAnswerHandler::addBatch(DPL::StaticPointerCast<EventAddressBookAddBatch>(m_event));
-}
-
-void AddressBookUpdateBatchPendingOperation::handleCallingCallbacks()
-{
-       AddressBookAsyncAnswerHandler::updateBatch(DPL::StaticPointerCast<EventAddressBookUpdateBatch>(m_event));
-}
-
-void AddressBookRemoveBatchPendingOperation::handleCallingCallbacks()
-{
-       AddressBookAsyncAnswerHandler::removeBatch(DPL::StaticPointerCast<EventAddressBookRemoveBatch>(m_event));
-}
-
-void AddressBookFindPendingOperation::handleCallingCallbacks()
-{
-       AddressBookAsyncAnswerHandler::find(DPL::StaticPointerCast<EventAddressBookFind>(m_event));
-}
-
 } // Contact
 } // Tizen1_0
 } // TizenApis
index bb08382..ab8a463 100755 (executable)
@@ -68,51 +68,6 @@ protected:
 
 typedef DPL::SharedPtr<AddressBookController> AddressBookControllerPtr;
 
-// Pending operation objects
-class AddressBookAddBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
-{
-public:
-       AddressBookAddBatchPendingOperation(
-                       DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
-               WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
-       {
-       }
-       virtual void handleCallingCallbacks();
-};
-
-class AddressBookUpdateBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
-{
-  public:
-       AddressBookUpdateBatchPendingOperation(
-                       DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
-               WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
-       {
-       }
-       virtual void handleCallingCallbacks();
-};
-
-class AddressBookRemoveBatchPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
-{
-  public:
-       AddressBookRemoveBatchPendingOperation(
-                       DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
-               WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
-       {
-       }
-       virtual void handleCallingCallbacks();
-};
-
-class AddressBookFindPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
-{
-  public:
-       AddressBookFindPendingOperation(
-                       DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
-               WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
-       {
-       }
-       virtual void handleCallingCallbacks();
-};
-
 //common part
 class AddressBookAsyncAnswerHandler
 {
@@ -125,7 +80,6 @@ public:
        static void changeListenerContactAdded(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
        static void changeListenerContactUpdated(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
        static void changeListenerContactRemoved(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
-       static void changeListenerAddressBookReset(const TizenApis::Api::Contact::EventAddressBookChangeListenerPtr &event);
 };
 
 } // Contact
index c736d6d..402a9c4 100755 (executable)
@@ -237,10 +237,10 @@ ContactPtr ContactConverter::toContactFromInit(const JSValueRef &jsValue)
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
        }
 
-       if (!validator.checkArrayKeys(m_allowedContactInit, jsValue)) {
-               LogError("invalid properties in ContactInit object");
-               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
-       }
+//     if (!validator.checkArrayKeys(m_allowedContactInit, jsValue)) {
+//             LogError("invalid properties in ContactInit object");
+//             ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+//     }
 
        const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NAME));
        const ScopedJSStringRef accountStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_ACCOUNT));
@@ -459,10 +459,10 @@ ContactNamePtr ContactConverter::toContactNameFromInit(const JSValueRef &jsValue
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
        }
 
-       if (!validator.checkArrayKeys(m_allowedContactNameInit, jsValue)) {
-               LogError("invalid properties in ContactNameInit object");
-               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
-       }
+//     if (!validator.checkArrayKeys(m_allowedContactNameInit, jsValue)) {
+//             LogError("invalid properties in ContactNameInit object");
+//             ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+//     }
 
        const ScopedJSStringRef prefixStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_PREFIX));
        const ScopedJSStringRef firstNameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_FIRST_NAME));
@@ -575,10 +575,10 @@ ContactOrganizationPtr ContactConverter::toContactOrganizationFromInit(const JSV
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
        }
 
-       if (!validator.checkArrayKeys(m_allowedContactOrganizationInit, jsValue)) {
-               LogError("invalid properties in ContactOrganizationInit object");
-               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
-       }
+//     if (!validator.checkArrayKeys(m_allowedContactOrganizationInit, jsValue)) {
+//             LogError("invalid properties in ContactOrganizationInit object");
+//             ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+//     }
 
        // NOTE: Currently not support office and logoURI fields
        const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_NAME));
@@ -781,10 +781,10 @@ ContactAddressPtr ContactConverter::toContactAddressFromInit(const JSValueRef &j
                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
        }
 
-       if (!validator.checkArrayKeys(m_allowedContactAddressInit, jsValue)) {
-               LogError("invalid properties in ContactAddressInit object");
-               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
-       }
+//     if (!validator.checkArrayKeys(m_allowedContactAddressInit, jsValue)) {
+//             LogError("invalid properties in ContactAddressInit object");
+//             ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+//     }
 
        const ScopedJSStringRef countryStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_COUNTRY));
        const ScopedJSStringRef regionStr(JSStringCreateWithUTF8CString(CONTACT_ATTRIBUTE_REGION));
@@ -1180,7 +1180,11 @@ ContactPhoneNumberTypeArrayPtr ContactConverter::toContactPhoneNumberTypeArray(c
        JSObjectRef jsObject = toJSObjectRef(jsValue);
     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
-        result->push_back(toContactPhoneNumberType(element));
+        Try {
+               result->push_back(toContactPhoneNumberType(element));
+        } Catch (Exception) {
+               // nothing
+        }
     }
     return result;
 }
@@ -1247,7 +1251,11 @@ ContactEmailAddressTypeArrayPtr ContactConverter::toContactEmailAddressTypeArray
        JSObjectRef jsObject = toJSObjectRef(jsValue);
     for (std::size_t i = 0; i < JSGetArrayLength(m_context, jsObject); ++i) {
         JSValueRef element = JSGetArrayElement(m_context, jsObject, i);
-        result->push_back(toContactEmailAddressType(element));
+        Try {
+               result->push_back(toContactEmailAddressType(element));
+        } Catch (Exception) {
+               // nothing
+        }
     }
     return result;
 }
index 835f68f..cd27ae2 100755 (executable)
@@ -56,6 +56,11 @@ void ContactManagerAsyncAnswerHandler::getAddressBooks(const EventContactManager
                return;
        }
 
+       if(event->checkCancelled()) {
+               LogDebug("Operation cancelled");
+               return;
+       }
+
        JSContextRef gContext = callbackManager->getContext();
 
        JSValueRef error = NULL;
@@ -106,11 +111,6 @@ void ContactManagerController::OnAnswerReceived(const EventContactManagerGetAddr
        ContactManagerAsyncAnswerHandler::getAddressBooks(event);
 }
 
-void ContactManagerGetAddressBooksPendingOperation::handleCallingCallbacks()
-{
-       ContactManagerAsyncAnswerHandler::getAddressBooks(DPL::StaticPointerCast<EventContactManagerGetAddressBooks>(m_event));
-}
-
 } // Contact
 } // Tizen1_0
 } // TizenApis
index 68f583e..a3aa314 100755 (executable)
@@ -57,17 +57,6 @@ public:
 
 typedef DPL::SharedPtr<ContactManagerController> ContactManagerControllerPtr;
 
-class ContactManagerGetAddressBooksPendingOperation : public WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject
-{
-public:
-       ContactManagerGetAddressBooksPendingOperation(
-                       DPL::SharedPtr<WrtDeviceApis::Commons::IEventController> &event) :
-               WrtDeviceApis::CommonsJavaScript::IJSPendingOperationPrivateObject(event)
-       {
-       }
-       virtual void handleCallingCallbacks();
-};
-
 //common part
 class ContactManagerAsyncAnswerHandler
 {
index 195ca28..eb379f5 100755 (executable)
  */
 
 #include <dpl/log/log.h>
-#include <dpl/assert.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSPendingOperation.h>
 #include <API/Contact/ContactFactory.h>
 #include <API/Contact/EventAddressBookAddBatch.h>
 #include <API/Contact/EventAddressBookUpdateBatch.h>
@@ -34,7 +34,6 @@
 #include <API/Contact/EventAddressBookFind.h>
 #include <API/Contact/EventAddressBookChangeListener.h>
 #include <API/Contact/EventAddressBookRemoveBatch.h>
-#include <CommonsJavaScript/JSPendingOperation.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/SecurityExceptions.h>
@@ -125,9 +124,8 @@ const JSClassRef JSAddressBook::getClassRef()
 void JSAddressBook::Initialize(JSContextRef context,
                JSObjectRef object)
 {
-       AddressBookController *priv =
-               static_cast<AddressBookController*>(JSObjectGetPrivate(object));
-       Assert(priv && "Private object not set.");
+//     AddressBookController *priv =
+//             static_cast<AddressBookController*>(JSObjectGetPrivate(object));
 }
 
 void JSAddressBook::Finalize(JSObjectRef object)
@@ -248,19 +246,16 @@ JSValueRef JSAddressBook::get(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_CONVERT_TO_STRING);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_CONVERT_TO_STRING);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+       //BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
 
-               if (!JSValueIsString(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       if (argumentCount < 1) {
+               /* 1st Argument must be string. */
+               LogError("1st argument must not be undefined.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No Contact id 'undefined'");
        }
 
        string id;
@@ -273,23 +268,46 @@ JSValueRef JSAddressBook::get(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
        }
 
-       ContactPtr contact;
+       EventAddressBookGetPtr dplEvent(new EventAddressBookGet());
+
+       dplEvent->setId(id);
+    dplEvent->setForSynchronousCall();
+
        Try {
-               contact = addressBook->get(id);
-       } Catch(UnsupportedException) {
-               LogError("Error on platform : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Unsupported format");
+               addressBook->get(dplEvent);
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
+       if (!dplEvent->getResult() || !dplEvent->getContactIsSet())
+       {
+               std::stringstream oss;
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::NotFoundException:
+               case ExceptionCodes::InvalidArgumentException:
+                       LogError("Not Found error : " << id);
+                       oss << "No Contact id '" << id << "'";
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, oss.str());
+                       break;
+               case ExceptionCodes::PlatformException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
+
+       ContactPtr contact = dplEvent->getContact();
+
        JSValueRef result;
        Try {
                result = converter->toJSValueRef(contact);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
        return result;
@@ -319,47 +337,57 @@ JSValueRef JSAddressBook::add(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_ADD);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
 
-               if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not object.");
+               if (!JSContact::isObjectOfClass(context, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
        }
 
-       ContactPtr contact;
+       ContactPtr contact(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        Try     {
                contact = converter->toContact(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
        }
 
+       EventAddressBookAddPtr dplEvent(new EventAddressBookAdd());
+
+       dplEvent->setContact(contact);
+    dplEvent->setForSynchronousCall();
+
        Try {
-               addressBook->add(contact);
+               addressBook->add(dplEvent);
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-//     JSValueRef result;
-//     Try {
-//             result = converter->toJSValueRef(contact);
-//     } Catch(Exception) {
-//             LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-//             return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-//     }
-//     return result;
+       if (!dplEvent->getResult())
+       {
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::PlatformException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
 
        return JSValueMakeUndefined(context);
 }
@@ -376,6 +404,9 @@ JSValueRef JSAddressBook::addBatch(JSContextRef context,
        JSContextRef gContext;
        AddressBookController *controller;
 
+       bool js2ndParamIsFunction = false;
+       bool js3rdParamIsFunction = false;
+
        Try     {
                controller = static_cast<AddressBookController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -388,64 +419,72 @@ JSValueRef JSAddressBook::addBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD_BATCH);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_ADD_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 3)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               // check 1st argument
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
 
                if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not array.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
 
-               if (argumentCount >= 2)
+               // check 2nd argument
+               if(argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]) && !JSValueIsNull(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
                }
 
-               if (argumentCount >= 3)
+               // check 3rd argument
+               if(argumentCount >= 3)
                {
-                       if (!validator->isCallback(arguments[2]) && !JSValueIsNull(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[2]))
+                               js3rdParamIsFunction = true;
+
+                       if (!js3rdParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[2]) &&
+                                       !JSValueIsUndefined(context, arguments[2]))
+                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
 
-       if(argumentCount >= 2)
-       {
-               if(!JSValueIsNull(context, arguments[1]))
-                       callbackManager->setOnSuccess(arguments[1]);
-       }
+       if(js2ndParamIsFunction)
+               callbackManager->setOnSuccess(arguments[1]);
 
-       if(argumentCount >= 3)
-       {
-               if(!JSValueIsNull(context, arguments[2]))
-                       callbackManager->setOnError(arguments[2]);
-       }
+       if(js3rdParamIsFunction)
+               callbackManager->setOnError(arguments[2]);
 
        EventAddressBookAddBatchPtr dplEvent(new EventAddressBookAddBatch());
        Try {
                dplEvent->setContacts(converter->toContactArray(arguments[0]));
        } Catch(ConversionException) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be an array of 'Contact object'");
        }
 
        // set event handler's data
        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        dplEvent->setForAsynchronousCall(controller);
 
-       //DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
-       //AddressBookAddBatchPendingOperation *gcPendingOperation = new AddressBookAddBatchPendingOperation(eventContr);
+//     DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
+//     IJSPendingOperationPrivateObject *gcPendingOperation = new IJSPendingOperationPrivateObject(eventContr);
 
        Try {
                addressBook->addBatch(dplEvent);
@@ -454,7 +493,9 @@ JSValueRef JSAddressBook::addBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       //return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+       JSValueProtect(gContext, thisObject);
+
+//     return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
        return JSValueMakeUndefined(context);
 }
 
@@ -482,41 +523,65 @@ JSValueRef JSAddressBook::update(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_UPDATE);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_UPDATE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument is an 'undefined'.");
 
                if (!JSContact::isObjectOfClass(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is wrong object.");
+                       ThrowMsg(InvalidArgumentException, "1st argument is not a 'Contact object'.");
+
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Contact object'");
        }
 
-       ContactPtr contact;
+       ContactPtr contact(NULL);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        Try     {
                contact = converter->toContact(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument is not a 'Contact object'");
        }
 
+       EventAddressBookUpdatePtr dplEvent(new EventAddressBookUpdate());
+
+       dplEvent->setContact(contact);
+    dplEvent->setForSynchronousCall();
+
        Try {
-               addressBook->update(contact);
+               addressBook->update(dplEvent);
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       JSValueRef result = JSValueMakeUndefined(context);
+       if (!dplEvent->getResult())
+       {
+               std::stringstream oss;
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::NotFoundException:
+               case ExceptionCodes::InvalidArgumentException:
+                       oss << "No Contact id '" << contact->getId() << "'";
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, oss.str());
+                       break;
+               case ExceptionCodes::PlatformException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
 
-       return result;
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSAddressBook::updateBatch(JSContextRef context,
@@ -531,6 +596,9 @@ JSValueRef JSAddressBook::updateBatch(JSContextRef context,
        JSContextRef gContext;
        AddressBookController *controller;
 
+       bool js2ndParamIsFunction = false;
+       bool js3rdParamIsFunction = false;
+
        Try     {
                controller = static_cast<AddressBookController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -543,64 +611,72 @@ JSValueRef JSAddressBook::updateBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_UPDATE_BATCH);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_UPDATE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 3)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               // check 1st argument
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
 
                if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not array.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact object'");
 
-               if (argumentCount >= 2)
+               // check 2nd argument
+               if(argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]) && !JSValueIsNull(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
                }
 
-               if (argumentCount >= 3)
+               // check 3rd argument
+               if(argumentCount >= 3)
                {
-                       if (!validator->isCallback(arguments[2]) && !JSValueIsNull(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[2]))
+                               js3rdParamIsFunction = true;
+
+                       if (!js3rdParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[2]) &&
+                                       !JSValueIsUndefined(context, arguments[2]))
+                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
 
-       if(argumentCount >= 2)
-       {
-               if(!JSValueIsNull(context, arguments[1]))
-                       callbackManager->setOnSuccess(arguments[1]);
-       }
+       if(js2ndParamIsFunction)
+               callbackManager->setOnSuccess(arguments[1]);
 
-       if(argumentCount >= 3)
-       {
-               if(!JSValueIsNull(context, arguments[2]))
-                       callbackManager->setOnError(arguments[2]);
-       }
+       if(js3rdParamIsFunction)
+               callbackManager->setOnError(arguments[2]);
 
        EventAddressBookUpdateBatchPtr dplEvent(new EventAddressBookUpdateBatch());
        Try {
                dplEvent->setContacts(converter->toContactArray(arguments[0]));
        } Catch(ConversionException) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "3rd argument must be an array of 'Contact object'");
        }
 
        // set event handler's data
        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        dplEvent->setForAsynchronousCall(controller);
 
-       //DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
-       //AddressBookUpdateBatchPendingOperation *gcPendingOperation = new AddressBookUpdateBatchPendingOperation(eventContr);
+//     DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
+//     IJSPendingOperationPrivateObject *gcPendingOperation = new IJSPendingOperationPrivateObject(eventContr);
 
        Try {
                addressBook->updateBatch(dplEvent);
@@ -609,7 +685,9 @@ JSValueRef JSAddressBook::updateBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       //return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+       JSValueProtect(gContext, thisObject);
+
+//     return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
        return JSValueMakeUndefined(context);
 }
 
@@ -637,19 +715,15 @@ JSValueRef JSAddressBook::remove(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_REMOVE);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_REMOVE);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsString(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is wrong object.");
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       if (argumentCount < 1) {
+               /* 1st Argument must be string. */
+               LogError("1st argument must not be undefined.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No Contact id 'undefined'");
        }
 
        string contactId;
@@ -657,24 +731,45 @@ JSValueRef JSAddressBook::remove(JSContextRef context,
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        Try     {
                contactId = converter->toString(arguments[0]);
-       } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
        }
+       Catch(Exception) {
+               LogError("Error on conversion " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments.");
+       }
+
+       EventAddressBookRemovePtr dplEvent(new EventAddressBookRemove());
+
+       dplEvent->setContactId(contactId);
+    dplEvent->setForSynchronousCall();
 
        Try {
-               addressBook->remove(contactId);
-       } Catch(NotFoundException) {
-               LogError("Error on platform : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Contact id not found");
+               addressBook->remove(dplEvent);
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       JSValueRef result = JSValueMakeUndefined(context);
+       if (!dplEvent->getResult())
+       {
+               std::stringstream oss;
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::NotFoundException:
+               case ExceptionCodes::InvalidArgumentException:
+                       LogError("Not Found error : " << contactId);
+                       oss << "No Contact id '" << contactId << "'";
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, oss.str());
+                       break;
+               case ExceptionCodes::PlatformException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
 
-       return result;
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSAddressBook::removeBatch(JSContextRef context,
@@ -689,6 +784,9 @@ JSValueRef JSAddressBook::removeBatch(JSContextRef context,
        JSContextRef gContext;
        AddressBookController *controller;
 
+       bool js2ndParamIsFunction = false;
+       bool js3rdParamIsFunction = false;
+
        Try     {
                controller = static_cast<AddressBookController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -701,64 +799,72 @@ JSValueRef JSAddressBook::removeBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_REMOVE_BATCH);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_REMOVE_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 3)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               // check 1st argument
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
 
                if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not array.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be an array of 'Contact id'");
 
-               if (argumentCount >= 2)
+               // check 2nd argument
+               if(argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]) && !JSValueIsNull(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
                }
 
-               if (argumentCount >= 3)
+               // check 3rd argument
+               if(argumentCount >= 3)
                {
-                       if (!validator->isCallback(arguments[2]) && !JSValueIsNull(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[2]))
+                               js3rdParamIsFunction = true;
+
+                       if (!js3rdParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[2]) &&
+                                       !JSValueIsUndefined(context, arguments[2]))
+                               ThrowMsg(InvalidArgumentException, "3rd argument must be a 'function' or a 'null'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
 
-       if(argumentCount >= 2)
-       {
-               if(!JSValueIsNull(context, arguments[1]))
-                       callbackManager->setOnSuccess(arguments[1]);
-       }
+       if(js2ndParamIsFunction)
+               callbackManager->setOnSuccess(arguments[1]);
 
-       if(argumentCount >= 3)
-       {
-               if(!JSValueIsNull(context, arguments[2]))
-                       callbackManager->setOnError(arguments[2]);
-       }
+       if(js3rdParamIsFunction)
+               callbackManager->setOnError(arguments[2]);
 
        EventAddressBookRemoveBatchPtr dplEvent(new EventAddressBookRemoveBatch());
        Try {
                dplEvent->setContactIds(converter->toStringArray(arguments[0]));
        } Catch(ConversionException) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "3rd argument must be an array of 'Contact id'");
        }
 
        // set event handler's data
        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        dplEvent->setForAsynchronousCall(controller);
 
-       //DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
-       //AddressBookRemoveBatchPendingOperation *gcPendingOperation = new AddressBookRemoveBatchPendingOperation(eventContr);
+//     DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
+//     IJSPendingOperationPrivateObject *gcPendingOperation = new IJSPendingOperationPrivateObject(eventContr);
 
        Try {
                addressBook->removeBatch(dplEvent);
@@ -767,7 +873,9 @@ JSValueRef JSAddressBook::removeBatch(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       //return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+       JSValueProtect(gContext, thisObject);
+
+//     return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
        return JSValueMakeUndefined(context);
 }
 
@@ -783,6 +891,10 @@ JSValueRef JSAddressBook::find(JSContextRef context,
        JSContextRef gContext;
        AddressBookController *controller;
 
+       bool js2ndParamIsFunction = false;
+       bool js3rdParamIsObject = false;
+       bool js4thParamIsObject = false;
+
        Try     {
                controller = static_cast<AddressBookController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -795,77 +907,88 @@ JSValueRef JSAddressBook::find(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_FIND);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_FIND);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 4)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
 
                if (!validator->isCallback(arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not function.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
 
                if (argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]) && !JSValueIsNull(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is neither function nor null.");
+                       if(validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "1st argument must be a 'function' or a 'null'");
                }
 
                if (argumentCount >= 3)
                {
-                       if (!JSValueIsObject(context, arguments[2]) && !JSValueIsNull(context, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "3rd argument is neither object nor null.");
+                       if(JSValueIsObject(context, arguments[2]))
+                               js3rdParamIsObject = true;
+
+                       if (!js3rdParamIsObject &&
+                                       !JSValueIsNull(context, arguments[2]) &&
+                                       !JSValueIsUndefined(context, arguments[2]))
+                               ThrowMsg(InvalidArgumentException, "3rd argument must be an 'Filter object' or 'null'");
                }
 
                if (argumentCount >= 4)
                {
-                       if (!JSValueIsObject(context, arguments[3]) && !JSValueIsNull(context, arguments[3]))
-                               ThrowMsg(InvalidArgumentException, "4th argument is neither object nor null.");
+                       if(JSValueIsObject(context, arguments[3]))
+                               js4thParamIsObject = true;
+
+                       if (!js4thParamIsObject &&
+                                       !JSValueIsNull(context, arguments[3]) &&
+                                       !JSValueIsUndefined(context, arguments[3]))
+                               ThrowMsg(InvalidArgumentException, "4th argument must be an 'SortMode object' or 'null'");
                }
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
 
        callbackManager->setOnSuccess(arguments[0]);
 
-       if (argumentCount >= 2)
-       {
-               if(!JSValueIsNull(context, arguments[1]))
-                       callbackManager->setOnError(arguments[1]);
-       }
+       if (js2ndParamIsFunction)
+               callbackManager->setOnError(arguments[1]);
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
        FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
        EventAddressBookFindPtr dplEvent(new EventAddressBookFind());
        Try {
-               if (argumentCount >= 3)
-               {
-                       if(!JSValueIsNull(context, arguments[2]))
-                               dplEvent->setFilter(filterConverter->toFilter(arguments[2]));
-               }
-
-               if (argumentCount >= 4)
-               {
-                       if(!JSValueIsNull(context, arguments[3]))
-                               dplEvent->setSortMode(filterConverter->toSortMode(arguments[3]));
-               }
+               if (js3rdParamIsObject)
+                       dplEvent->setFilter(filterConverter->toFilter(arguments[2]));
+       } Catch(Exception) {
+               LogError("Error on 3rd parameter conversion : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "3rd argument must be an 'Filter object' or 'null'");
+       }
 
+       Try {
+               if (js4thParamIsObject)
+                       dplEvent->setSortMode(filterConverter->toSortMode(arguments[3]));
        } Catch(Exception) {
-               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               LogError("Error on 4th parameter conversion : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "4th argument must be an 'SortMode object' or 'null'");
        }
 
        // set event handler's data
        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        dplEvent->setForAsynchronousCall(controller);
 
-       //DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
-       //AddressBookFindPendingOperation *gcPendingOperation = new AddressBookFindPendingOperation(eventContr);
+//     DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
+//     IJSPendingOperationPrivateObject *gcPendingOperation = new IJSPendingOperationPrivateObject(eventContr);
 
        Try {
                addressBook->find(dplEvent);
@@ -874,7 +997,9 @@ JSValueRef JSAddressBook::find(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       //return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+       JSValueProtect(gContext, thisObject);
+
+//     return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
        return JSValueMakeUndefined(context);
 }
 
@@ -890,6 +1015,8 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context,
        JSContextRef gContext;
        AddressBookController *controller;
 
+       bool js2ndParamIsFunction = false;
+
        Try     {
                controller = static_cast<AddressBookController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -899,29 +1026,35 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context,
                gContext = controller->getContext();
        } Catch(Exception) {
                LogError("No private object");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong object");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD_CHANGE_LISTENER);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_ADD_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'AddressBookChangeCallback object'");
 
                if (!JSValueIsObject(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not object.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'AddressBookChangeCallback object'");
 
                if (argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]) && !JSValueIsNull(context, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is neither function or null.");
+                       if(validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be a 'function' or a 'null'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
@@ -929,40 +1062,36 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context,
        JSValueRef oncontactsadded;
        JSValueRef oncontactsupdated;
        JSValueRef oncontactsdeleted;
-       JSValueRef onaddressbookreset;
        Try {
                JSObjectRef callbackObject = converter->toJSObjectRef(arguments[0]);
 
-               oncontactsadded = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "onContactsAdded");
+               oncontactsadded = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "oncontactsadded");
                if (validator->isNullOrUndefined(oncontactsadded))
                        oncontactsadded = NULL;
                else if (!validator->isCallback(oncontactsadded)) {
-                       ThrowMsg(ConversionException, "Not a valid callback (onContactsAdded)");
+                       ThrowMsg(ConversionException, "2nd argument's oncontactsadded attribute is not a 'function'");
                }
 
-               oncontactsupdated = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "onContactsUpdated");
+               oncontactsupdated = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "oncontactsupdated");
                if (validator->isNullOrUndefined(oncontactsupdated))
                        oncontactsupdated = NULL;
                else if (!validator->isCallback(oncontactsupdated)) {
-                       ThrowMsg(ConversionException, "Not a valid callback (onContactsUpdated)");
+                       ThrowMsg(ConversionException, "2nd argument's oncontactsupdated attribute is not a 'function'");
                }
 
-               oncontactsdeleted = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "onContactsRemoved");
+               oncontactsdeleted = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "oncontactsremoved");
                if (validator->isNullOrUndefined(oncontactsdeleted))
                        oncontactsdeleted = NULL;
                else if (!validator->isCallback(oncontactsdeleted)) {
-                       ThrowMsg(ConversionException, "Not a valid callback (onContactsRemoved)");
+                       ThrowMsg(ConversionException, "2nd argument's oncontactsremoved attribute is not a 'function'");
                }
 
-               onaddressbookreset = JSUtils::getJSPropertyOrUndefined(context, callbackObject, "onAddressBookReset");
-               if (validator->isNullOrUndefined(onaddressbookreset))
-                       onaddressbookreset = NULL;
-               else if (!validator->isCallback(onaddressbookreset)) {
-                       ThrowMsg(ConversionException, "Not a valid callback (onAddressBookReset)");
-               }
+               if (oncontactsadded == NULL && oncontactsupdated == NULL && oncontactsdeleted == NULL)
+                       ThrowMsg(ConversionException, "2nd argument must have at least one function");
+
        } Catch(ConversionException) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        JSAddressBookChangeCallbackManagerPtr callbackManager = JSAddressBookChangeCallbackManager::createObject(gContext);
@@ -970,27 +1099,53 @@ JSValueRef JSAddressBook::addChangeListener(JSContextRef context,
        callbackManager->setOnContactsAdded(oncontactsadded);
        callbackManager->setOnContactsUpdated(oncontactsupdated);
        callbackManager->setOnContactsDeleted(oncontactsdeleted);
-       callbackManager->setOnAddressBookReset(onaddressbookreset);
-       if(argumentCount >= 2)
-       {
-               if(!JSValueIsNull(context, arguments[1]))
-                       callbackManager->setOnError(arguments[1]);
-       }
+       if(js2ndParamIsFunction)
+               callbackManager->setOnError(arguments[1]);
 
        EventAddressBookChangeListenerEmitterPtr emitter(new EventAddressBookChangeListenerEmitter());
 
        emitter->setEventPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        emitter->setListener(controller);
 
-       long watchId;
+       EventAddressBookAddChangeListenerPtr dplEvent(new EventAddressBookAddChangeListener());
+
+       dplEvent->setEmitter(emitter);
+    dplEvent->setForSynchronousCall();
+
        Try {
-               watchId = addressBook->addChangeListener(emitter);
+               addressBook->addChangeListener(dplEvent);
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       return converter->toJSValueRefLong(watchId);
+       if (!dplEvent->getResult() || !dplEvent->getIdIsSet())
+       {
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::InvalidArgumentException:
+               case ExceptionCodes::PlatformException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
+
+       long watchId = dplEvent->getId();
+
+       JSValueRef result;
+       Try {
+               result = converter->toJSValueRefLong(watchId);
+       } Catch(Exception) {
+               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       }
+
+       JSValueProtect(gContext, thisObject);
+
+       return result;
 }
 
 JSValueRef JSAddressBook::removeChangeListener(JSContextRef context,
@@ -1014,39 +1169,59 @@ JSValueRef JSAddressBook::removeChangeListener(JSContextRef context,
                gContext = controller->getContext();
        } Catch(Exception) {
                LogError("No private object");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong object");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_REMOVE_CHANGE_LISTENER);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_REMOVE_CHANGE_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsNumber(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not object.");
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       if (argumentCount < 1)
+       {
+               LogError("1st argument must not be undefined.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No watch id 'undefined'");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
 
-       long watchId;
+       long watchId = 0;
        Try {
                watchId = static_cast<long>(converter->toLong(arguments[0]));
 
                if (watchId < 0)
                        ThrowMsg(PlatformException, "watchId is wrong (" << watchId << ")");
-
-               addressBook->removeChangeListener(watchId);
        } Catch(Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
+       EventAddressBookRemoveChangeListenerPtr dplEvent(new EventAddressBookRemoveChangeListener());
+
+       dplEvent->setId(watchId);
+    dplEvent->setForSynchronousCall();
+
+       Try {
+               addressBook->removeChangeListener(dplEvent);
+       } Catch(Exception) {
+               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       }
+
+       if (!dplEvent->getResult())
+       {
+               switch (dplEvent->getExceptionCode())
+               {
+               case ExceptionCodes::InvalidArgumentException:
+               case ExceptionCodes::NotFoundException:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Contact not found");
+                       break;
+               default:
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       break;
+               }
+       }
+
        return JSValueMakeUndefined(context);
 }
 
index ca2fbf4..f64aa7c 100755 (executable)
@@ -37,12 +37,10 @@ JSAddressBookChangeCallbackManager::JSAddressBookChangeCallbackManager(JSContext
                JSObjectRef onContactsAdded,
                JSObjectRef onContactsUpdated,
                JSObjectRef onContactsDeleted,
-               JSObjectRef onAddressBookReset,
                JSObjectRef onError ) :
                m_onContactsAdded(NULL),
                m_onContactsUpdated(NULL),
                m_onContactsDeleted(NULL),
-               m_onAddressBookReset(NULL),
                m_onError(NULL),
                m_context(context),
                m_object(NULL)
@@ -50,7 +48,6 @@ JSAddressBookChangeCallbackManager::JSAddressBookChangeCallbackManager(JSContext
        setOnContactsAdded(onContactsAdded);
        setOnContactsUpdated(onContactsUpdated);
        setOnContactsDeleted(onContactsDeleted);
-       setOnAddressBookReset(onAddressBookReset);
     setOnError(onError);
 }
 
@@ -71,11 +68,6 @@ JSAddressBookChangeCallbackManager::~JSAddressBookChangeCallbackManager()
                JSValueUnprotect(m_context, m_onContactsDeleted);
        }
 
-       if(m_onAddressBookReset)
-       {
-               JSValueUnprotect(m_context, m_onAddressBookReset);
-       }
-
     if(m_onError)
     {
         JSValueUnprotect(m_context, m_onError);
@@ -151,29 +143,6 @@ JSValueRef JSAddressBookChangeCallbackManager::getOnContactsDeleted() const
        return m_onContactsDeleted;
 }
 
-void JSAddressBookChangeCallbackManager::setOnAddressBookReset( JSValueRef onAddressBookReset )
-{
-       if (onAddressBookReset)
-       {
-               if (m_onAddressBookReset != NULL)
-               {
-                       JSValueUnprotect(m_context, m_onAddressBookReset);
-               }
-
-               m_onAddressBookReset = JSValueToObject( m_context, onAddressBookReset, NULL );
-
-               if (m_onAddressBookReset != NULL)
-               {
-                       JSValueProtect(m_context, m_onAddressBookReset);
-               }
-       }
-}
-
-JSValueRef JSAddressBookChangeCallbackManager::getOnAddressBookReset() const
-{
-       return m_onAddressBookReset;
-}
-
 void JSAddressBookChangeCallbackManager::setOnError( JSValueRef onError )
 {
     if (onError)
@@ -245,16 +214,6 @@ void JSAddressBookChangeCallbackManager::callOnContactsDeleted( JSValueRef conta
     makeCallback( m_context, NULL, m_onContactsDeleted, "oncontactsdeleted", objParam, 1 );
 }
 
-void JSAddressBookChangeCallbackManager::callOnAddressBookReset()
-{
-    if ( m_onAddressBookReset == NULL )
-    {
-        //LogDebug("onaddressbookreset callback is not set");
-        return;
-    }
-    makeCallback( m_context, NULL, m_onAddressBookReset, "onaddressbookreset", NULL, 0 );
-}
-
 void JSAddressBookChangeCallbackManager::callOnError( JSValueRef error )
 {
     if ( m_onError == NULL )
index 3b5cbe2..f6159f3 100755 (executable)
@@ -43,7 +43,6 @@ private:
                        JSObjectRef onContactsAdded = NULL,
                        JSObjectRef onContactsUpdated = NULL,
                        JSObjectRef onContactsDeleted = NULL,
-                       JSObjectRef onAddressBookReset = NULL,
                        JSObjectRef onError = NULL );
 
 public:
@@ -60,8 +59,6 @@ public:
        JSValueRef getOnContactsUpdated() const;
        void    setOnContactsDeleted( JSValueRef onContactsDeleted );
        JSValueRef getOnContactsDeleted() const;
-       void    setOnAddressBookReset( JSValueRef onAddressBookReset );
-       JSValueRef getOnAddressBookReset() const;
        void    setOnError( JSValueRef onError );
        JSValueRef getOnError() const;
        void    setObject( JSObjectRef object );
@@ -70,7 +67,6 @@ public:
        void    callOnContactsAdded( JSValueRef contacts );
        void    callOnContactsUpdated( JSValueRef contacts );
        void    callOnContactsDeleted( JSValueRef contactIds );
-       void    callOnAddressBookReset( );
        void    callOnError( JSValueRef error );
 
 private:
@@ -84,7 +80,6 @@ private:
        JSObjectRef  m_onContactsAdded;
        JSObjectRef  m_onContactsUpdated;
        JSObjectRef  m_onContactsDeleted;
-       JSObjectRef  m_onAddressBookReset;
        JSObjectRef  m_onError;
        JSContextRef m_context;
        JSObjectRef  m_object;
index 6fc935a..ccb9085 100755 (executable)
@@ -28,7 +28,6 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/SecurityExceptions.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "plugin_config.h"
 #include "ContactConverter.h"
 #include "JSContact.h"
@@ -53,6 +52,7 @@
 #define CONTACT_ATTR_RINGTONE_URI      "ringtoneURI"
 #define CONTACT_ATTR_CATEGORIES                "categories"
 #define CONTACT_FUNC_CONVERT_TO_STRING         "convertToString"
+#define CONTACT_FUNC_CLONE                                     "clone"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -107,6 +107,7 @@ JSStaticValue JSContact::m_property[] = {
 JSStaticFunction JSContact::m_functions[] =
 {
        { CONTACT_FUNC_CONVERT_TO_STRING, convertToString, kJSPropertyAttributeNone },
+       { CONTACT_FUNC_CLONE, clone, kJSPropertyAttributeNone },
        { 0, 0, 0 }
 };
 
@@ -192,7 +193,11 @@ JSObjectRef JSContact::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool jsNoParam = false;
+       bool js1stParamIsObject = false;
+       bool js1stParamIsString = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactPriv *priv = static_cast<JSContactPriv*>(JSObjectGetPrivate(constructor));
@@ -201,62 +206,89 @@ JSObjectRef JSContact::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (argumentCount == 1)
-               {
-                       if (!JSValueIsObject(gContext, arguments[0]) && !JSValueIsNull(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "1st argument is not object.");
-               }
-
-               if (argumentCount == 2)
+       if (argumentCount == 0)
+       {
+               jsNoParam = true;
+       }
+       else if (argumentCount == 1)
+       {
+               if (JSValueIsNull(gContext, arguments[0]) || JSValueIsUndefined(gContext, arguments[0]))
+                       jsNoParam = true;
+               else if (JSValueIsObject(gContext, arguments[0]))
+                       js1stParamIsObject = true;
+               else
                {
-                       if (!JSValueIsString(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "1st argument is not object.");
-
-                       if (!JSValueIsString(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not object.");
+                       LogError("Argument type mismatch : 2nd argument must be 'ContactTextFormat'");
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+                       return NULL;
                }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
+       }
+       else //  (argumentCount >= 2)
+       {
+               if (JSValueIsObject(gContext, arguments[0]))
+                       js1stParamIsObject = true;
+               else
+                       js1stParamIsString = true;
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
 
        ContactPtr contact(NULL);
-       Try {
-               if(argumentCount == 1)
-               {
-                       if(JSValueIsObject(gContext, arguments[0]))
-                               contact = converter->toContactFromInit(arguments[0]);
+       if(js1stParamIsObject)
+       {
+               Try {
+                       contact = converter->toContactFromInit(arguments[0]);
+
+               } Catch(ConversionException) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactInit object'");
+                       return NULL;
+               } Catch(Exception) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       return NULL;
                }
-
-               if(argumentCount == 2)
-               {
+       }
+       else if(js1stParamIsString)
+       {
+               Try {
                        std::string stringRepresentation;       // vCard string
                        std::string format;
 
                        stringRepresentation = converter->toString(arguments[0]);
                        format = converter->toString(arguments[1]);
 
-                       contact = ContactFactory::getInstance().createContact(stringRepresentation, format);
+                       contact = ContactFactory::getInstance().createContact();
+                       contact->setContactFromString(stringRepresentation, format);
+
+               } Catch(ConversionException) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be 'ContactTextFormat'");
+                       return NULL;
+               } Catch(InvalidArgumentException) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "1st argument must be vCard string");
+                       return NULL;
+               } Catch(UnsupportedException) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
+                       return NULL;
+               } Catch(Exception) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       return NULL;
                }
-
-               if(contact == NULL)
+       }
+       else
+       {
+               Try {
                        contact = ContactFactory::getInstance().createContact();
-
-       } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
+               } Catch(Exception) {
+                       LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
+                       return NULL;
+               }
        }
 
        JSObjectRef jsobject;
@@ -265,7 +297,7 @@ JSObjectRef JSContact::constructor(JSContextRef context,
                jsobject = createJSObject(gContext, contact);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
@@ -967,19 +999,20 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(context, CONTACT_FUNCTION_API_CONVERT_TO_STRING);
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+//     CONTACT_FUNCTION_API_CONVERT_TO_STRING);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount != 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(ConversionException, "1st argument must be 'ContactTextFormat string'");
 
                if (!JSValueIsString(context, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-       } Catch(Exception ) {
+                       ThrowMsg(ConversionException, "1st argument must be 'ContactTextFormat string'");
+       } Catch (Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
        }
 
        std::string format;
@@ -989,15 +1022,18 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                format = converter->toString(arguments[0]);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
        }
 
        std::string vCard;
        Try {
                vCard = contact->convertToString(format);
+       } Catch(ConversionException) {
+               LogError("Error on platform : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'ContactTextFormat string'");
        } Catch(UnsupportedException) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Unsupported format");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Only support vCard 3.0");
        } Catch(Exception) {
                LogError("Error on platform : " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
@@ -1008,7 +1044,50 @@ JSValueRef JSContact::convertToString(JSContextRef context,
                result = converter->toJSValueRef(vCard);
        } Catch(Exception) {
                LogError("Error on conversion : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       }
+
+       return result;
+}
+
+JSValueRef JSContact::clone(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       ContactPtr contact(NULL);
+
+       Try     {
+               contact = getPrivData(thisObject);
+               if (contact == NULL) {
+                       ThrowMsg(InvalidArgumentException, "No private object.");
+               }
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+//     CONTACT_FUNCTION_API_CONVERT_TO_STRING);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       ContactPtr clonedContact(NULL);
+       Try {
+               clonedContact = contact->clone();
+       } Catch(Exception) {
+               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
+       }
+
+       JSValueRef result;
+       Try {
+               result = createJSObject(context, clonedContact);
+       } Catch(Exception) {
+               LogError("Error on conversion : " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
        return result;
index 7b67c4a..db674b5 100755 (executable)
@@ -261,6 +261,13 @@ private:
                        size_t argumentCount,
                        const JSValueRef arguments[],
                        JSValueRef* exception);
+
+       static JSValueRef clone(JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
 };
 
 } // Contact
index a89e181..41e6dbd 100755 (executable)
@@ -25,7 +25,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactAccount.h"
 
@@ -157,7 +156,9 @@ JSObjectRef JSContactAccount::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsString = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactAccountPriv *priv = static_cast<JSContactAccountPriv*>(JSObjectGetPrivate(constructor));
@@ -166,26 +167,11 @@ JSObjectRef JSContactAccount::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsString(gContext, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-
-               if (argumentCount >= 2)
-               {
-                       if (!JSValueIsString(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
-               }
-
-       } Catch(Exception ) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
+       if (argumentCount >= 2)
+       {
+               if (!JSValueIsNull(gContext, arguments[1]) && !JSValueIsUndefined(gContext, arguments[1]))
+                       js2ndParamIsString = true;
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
@@ -194,22 +180,24 @@ JSObjectRef JSContactAccount::constructor(JSContextRef context,
        std::string contactURI;
 
        Try {
-               accountServiceId = converter->toString(arguments[0]);
+               if (argumentCount >= 1)
+                       accountServiceId = converter->toString(arguments[0]);
+               else
+                       accountServiceId = converter->toString(JSValueMakeUndefined(context));
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(JSValueIsString(gContext, arguments[1]))
-                               contactURI = converter->toString(arguments[1]);
-               }
+               if(js2ndParamIsString)
+                       contactURI = converter->toString(arguments[1]);
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
@@ -223,7 +211,7 @@ JSObjectRef JSContactAccount::constructor(JSContextRef context,
                jsobject = createJSObject(gContext, contactAccount);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
index 7108335..24870c1 100755 (executable)
@@ -25,7 +25,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactAddress.h"
 #include "JSContactAddressTypeArray.h"
@@ -168,7 +167,9 @@ JSObjectRef JSContactAddress::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js1stParamIsObject = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactAddressPriv *priv = static_cast<JSContactAddressPriv*>(JSObjectGetPrivate(constructor));
@@ -177,35 +178,38 @@ JSObjectRef JSContactAddress::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount > 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (argumentCount == 1)
+               if (argumentCount >= 1)
                {
-                       if (!JSValueIsObject(gContext, arguments[0]) && !JSValueIsNull(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "1st argument is not object.");
+                       if (JSValueIsObject(gContext, arguments[0]))
+                               js1stParamIsObject = true;
+
+                       if (!js1stParamIsObject &&
+                                       !JSValueIsNull(gContext, arguments[0]) &&
+                                       !JSValueIsUndefined(gContext, arguments[0]))
+                               ThrowMsg(InvalidArgumentException, "1st argument must be a 'ContactAddressInit object'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
                return NULL;
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
 
-       ContactAddressPtr contactEmailAddress(new ContactAddress());
+       ContactAddressPtr contactEmailAddress(NULL);
 
        Try {
-               if(argumentCount == 1 && !JSValueIsNull(gContext, arguments[0]))
+               if(js1stParamIsObject)
                        contactEmailAddress = converter->toContactAddressFromInit(arguments[0]);
+               else
+                       contactEmailAddress = ContactAddressPtr(new ContactAddress());
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'ContactAddressInit object'");
                return NULL;
        }
 
@@ -215,7 +219,7 @@ JSObjectRef JSContactAddress::constructor(JSContextRef context,
                jsobject = createJSObject(gContext, contactEmailAddress);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
index 653aa63..a7c328f 100755 (executable)
@@ -25,7 +25,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactAnniversary.h"
 
@@ -156,7 +155,9 @@ JSObjectRef JSContactAnniversary::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsString = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactAnniversaryPriv *priv = static_cast<JSContactAnniversaryPriv*>(JSObjectGetPrivate(constructor));
@@ -165,25 +166,23 @@ JSObjectRef JSContactAnniversary::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'Date object'");
 
                if (!JSValueIsObject(gContext, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not object.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'Date object'");
 
                if (argumentCount >= 2)
                {
-                       if (!JSValueIsString(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
+                       if (!JSValueIsUndefined(context, arguments[1]) && !JSValueIsNull(context, arguments[1]))
+                               js2ndParamIsString = true;
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Date object'");
                return NULL;
        }
 
@@ -191,25 +190,19 @@ JSObjectRef JSContactAnniversary::constructor(JSContextRef context,
 
        std::tm date;
        std::string label;
-       bool labelIsSet = false;
 
        Try {
                date = converter->toDateTm(arguments[0]);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Date object'");
                return NULL;
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(!JSValueIsNull(gContext, arguments[1]))
-                       {
-                               label = converter->toString(arguments[1]);
-                               labelIsSet = true;
-                       }
-               }
+               if (js2ndParamIsString)
+                       label = converter->toString(arguments[1]);
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -220,7 +213,7 @@ JSObjectRef JSContactAnniversary::constructor(JSContextRef context,
        contactAnniversary->setDate(date);
 
        // NOTE: Currently not support label field
-       //if(labelIsSet)
+       //if(js2ndParamIsString)
        //      contactAnniversary->setLabel(label);
 
        JSObjectRef jsobject;
index dadcd51..8a482e1 100755 (executable)
@@ -25,7 +25,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactEmailAddressTypeArray.h"
 #include "JSContactEmailAddress.h"
@@ -159,7 +158,9 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsArray = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactEmailAddressPriv *priv = static_cast<JSContactEmailAddressPriv*>(JSObjectGetPrivate(constructor));
@@ -168,25 +169,22 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsString(gContext, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-
                if (argumentCount >= 2)
                {
-                       if (!JSIsArrayValue(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+                       if (JSIsArrayValue(gContext, arguments[1]))
+                               js2ndParamIsArray = true;
+
+                       if (!js2ndParamIsArray &&
+                                       !JSValueIsNull(gContext, arguments[1]) &&
+                                       !JSValueIsUndefined(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be array of ContactEmailAddress types");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be array of ContactEmailAddress types");
                return NULL;
        }
 
@@ -196,7 +194,11 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context,
        ContactEmailAddressTypeArrayPtr types(NULL);
 
        Try {
-               email = converter->toString(arguments[0]);
+               if(argumentCount >= 1)
+                       email = converter->toString(arguments[0]);
+               else
+                       email = converter->toString(JSValueMakeUndefined(context));
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -204,13 +206,11 @@ JSObjectRef JSContactEmailAddress::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(JSIsArrayValue(gContext, arguments[1]))
-                               types = converter->toContactEmailAddressTypeArray(arguments[1]);
-               }
-               if(types == NULL)
+               if(js2ndParamIsArray)
+                       types = converter->toContactEmailAddressTypeArray(arguments[1]);
+               else
                        types = ContactEmailAddressTypeArrayPtr(new ContactEmailAddressTypeArray());
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
index 1a4aa98..800f54f 100755 (executable)
@@ -150,6 +150,8 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context,
        JSContextRef gContext;
        ContactManagerController *controller;
 
+       bool js2ndParamIsFunction = false;
+
        Try     {
                controller = static_cast<ContactManagerController*>(JSObjectGetPrivate(thisObject));
                if (!controller) {
@@ -162,33 +164,39 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_GET_ADDRESS_BOOKS);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_GET_ADDRESS_BOOKS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 1)
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
 
                if (!validator->isCallback(arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not function.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be a 'function'");
 
                if (argumentCount >= 2)
                {
-                       if (!validator->isCallback(arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not function.");
+                       if (validator->isCallback(arguments[1]))
+                               js2ndParamIsFunction = true;
+
+                       if (!js2ndParamIsFunction &&
+                                       !JSValueIsNull(context, arguments[1]) &&
+                                       !JSValueIsUndefined(context, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2st argument must be a 'function' or a 'null");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
        }
 
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);
 
        callbackManager->setOnSuccess(arguments[0]);
 
-       if(argumentCount >= 2)
+       if(js2ndParamIsFunction)
                callbackManager->setOnError(arguments[1]);
 
        EventContactManagerGetAddressBooksPtr dplEvent(new EventContactManagerGetAddressBooks());
@@ -197,8 +205,8 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context,
        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(callbackManager));
        dplEvent->setForAsynchronousCall(controller);
 
-       //DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
-       //ContactManagerGetAddressBooksPendingOperation *gcPendingOperation = new ContactManagerGetAddressBooksPendingOperation(eventContr);
+//     DPL::SharedPtr<IEventController> eventContr = DPL::StaticPointerCast< IEventController>(dplEvent);
+//     IJSPendingOperationPrivateObject *gcPendingOperation = new IJSPendingOperationPrivateObject(eventContr);
 
        Try {
                contactManager->getAddressBooks(dplEvent);
@@ -207,7 +215,7 @@ JSValueRef JSContactManager::getAddressBooks(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
        }
 
-       //return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+//     return JSObjectMake(gContext, JSPendingOperation::getClassRef(), gcPendingOperation);
        return JSValueMakeUndefined(context);
 }
 
@@ -226,7 +234,8 @@ JSValueRef JSContactManager::getDefaultAddressBook(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(priv->getContext(), CONTACT_FUNCTION_API_GET_DEFAULT_ADDRESS_BOOK);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_GET_DEFAULT_ADDRESS_BOOK);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        IContactManagerPtr contactManager;
@@ -239,13 +248,6 @@ JSValueRef JSContactManager::getDefaultAddressBook(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       if (argumentCount > 0) {
-               /* Argument count must be 0. */
-               LogError("TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-       }
-
        AddressBookPtr defaultAddressBook;
        Try {
                defaultAddressBook = contactManager->getDefaultAddressBook();
@@ -281,7 +283,8 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       AceSecurityStatus status = CONTACT_CHECK_ACCESS(priv->getContext(), CONTACT_FUNCTION_API_GET_ADDRESS_BOOK);
+       AceSecurityStatus status = CONTACT_CHECK_ACCESS(
+                       CONTACT_FUNCTION_API_GET_ADDRESS_BOOK);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        IContactManagerPtr contactManager;
@@ -294,38 +297,35 @@ JSValueRef JSContactManager::getAddressBook(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
        }
 
-       BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
-       if (argumentCount != 1) {
-               /* Argument count must be 1. */
-               LogError("TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-       }
-       if (!JSValueIsString(context, arguments[0])) {
-               /* Argument count must be string. */
-               LogError("TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+       if (argumentCount < 1) {
+               /* 1st Argument must be string. */
+               LogError("1st argument must not be undefined.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "No AddressBook name 'undefined'");
        }
 
        ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(gContext);
 
        std::string addressBookId;
-       Try
-       {
+       Try {
                addressBookId = converter->toString(arguments[0]);
-               if(addressBookId == "")
-                       ThrowMsg(InvalidArgumentException, "Address book ID is empty string.");
        }
        Catch(Exception) {
                LogError("Error on conversion " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong argument");
        }
 
        AddressBookPtr addressBook;
        Try {
+               if(addressBookId == "")
+                       ThrowMsg(InvalidArgumentException, "Address book ID is empty string.");
+
                addressBook = contactManager->getAddressBook(addressBookId);
+
        } Catch(NotFoundException) {
                LogError("No AddressBook id(" << addressBookId << ")");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, "Internal error");
+               std::stringstream oss;
+               oss << "No AddressBook name '" << addressBookId << "'";
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, oss.str());
        } Catch(Exception){
                LogError("Internal error.");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Internal error");
index 19e0879..8ec0162 100755 (executable)
@@ -26,7 +26,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactName.h"
 
@@ -174,31 +173,33 @@ JSObjectRef JSContactName::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
+       bool js1stParamIsObject = false;
+
        JSContactNamePriv *priv = static_cast<JSContactNamePriv*>(JSObjectGetPrivate(constructor));
        if (!priv) {
                ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount > 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (argumentCount == 1)
+               if (argumentCount >= 1)
                {
-                       if (!JSValueIsObject(gContext, arguments[0]) && !JSValueIsNull(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "1st argument is not object.");
+                       if (JSValueIsObject(gContext, arguments[0]))
+                               js1stParamIsObject = true;
+
+                       if (!js1stParamIsObject &&
+                                       !JSValueIsNull(gContext, arguments[0]) &&
+                                       !JSValueIsUndefined(gContext, arguments[0]))
+                               ThrowMsg(InvalidArgumentException, "1st argument must be 'object'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be 'object'");
                return NULL;
        }
 
@@ -206,18 +207,14 @@ JSObjectRef JSContactName::constructor(JSContextRef context,
 
        ContactNamePtr contactName(NULL);
        Try {
-               if(argumentCount == 1)
-               {
-                       if(JSValueIsObject(gContext, arguments[0]))
-                               contactName = converter->toContactNameFromInit(arguments[0]);
-               }
-
-               if(contactName == NULL)
+               if(js1stParamIsObject)
+                       contactName = converter->toContactNameFromInit(arguments[0]);
+               else
                        contactName = ContactNamePtr(new ContactName());
 
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
@@ -227,7 +224,7 @@ JSObjectRef JSContactName::constructor(JSContextRef context,
                jsobject = createJSObject(gContext, contactName);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
index 4e09297..17c3788 100755 (executable)
@@ -26,7 +26,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 
 #define ORGANIZATION_CLASS_NAME "ContactOrganization"
@@ -165,7 +164,9 @@ JSObjectRef JSContactOrganization::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js1stParamIsObject = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactOrganizationPriv *priv = static_cast<JSContactOrganizationPriv*>(JSObjectGetPrivate(constructor));
@@ -174,22 +175,22 @@ JSObjectRef JSContactOrganization::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount > 1)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (argumentCount == 1)
+               if (argumentCount >= 1)
                {
-                       if (!JSValueIsObject(gContext, arguments[0]) && !JSValueIsNull(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not object.");
+                       if (JSValueIsObject(gContext, arguments[0]))
+                               js1stParamIsObject = true;
+
+                       if (!js1stParamIsObject &&
+                                       !JSValueIsNull(gContext, arguments[0]) &&
+                                       !JSValueIsUndefined(gContext, arguments[0]))
+                               ThrowMsg(InvalidArgumentException, "1st argument must be a 'object'");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'object'");
                return NULL;
        }
 
@@ -197,18 +198,14 @@ JSObjectRef JSContactOrganization::constructor(JSContextRef context,
 
        ContactOrganizationPtr contactOrganization(NULL);
        Try {
-               if(argumentCount == 1)
-               {
-                       if(JSValueIsObject(gContext, arguments[0]))
-                               contactOrganization = converter->toContactOrganizationFromInit(arguments[0]);
-               }
-
-               if(contactOrganization == NULL)
+               if(js1stParamIsObject)
+                       contactOrganization = converter->toContactOrganizationFromInit(arguments[0]);
+               else
                        contactOrganization = ContactOrganizationPtr(new ContactOrganization());
 
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
@@ -218,7 +215,7 @@ JSObjectRef JSContactOrganization::constructor(JSContextRef context,
                jsobject = createJSObject(gContext, contactOrganization);
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
index f0c6ca2..b39bfc7 100755 (executable)
@@ -26,7 +26,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactPhoneNumberTypeArray.h"
 #include "JSContactPhoneNumber.h"
@@ -159,7 +158,9 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsArray = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactPhoneNumberPriv *priv = static_cast<JSContactPhoneNumberPriv*>(JSObjectGetPrivate(constructor));
@@ -168,25 +169,22 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsString(gContext, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-
                if (argumentCount >= 2)
                {
-                       if (!JSIsArrayValue(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+                       if (JSIsArrayValue(gContext, arguments[1]))
+                               js2ndParamIsArray = true;
+
+                       if (!js2ndParamIsArray &&
+                                       !JSValueIsNull(gContext, arguments[1]) &&
+                                       !JSValueIsUndefined(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument must be array of ContactPhoneNumber types");
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "2nd argument must be array of ContactPhoneNumber types");
                return NULL;
        }
 
@@ -196,24 +194,26 @@ JSObjectRef JSContactPhoneNumber::constructor(JSContextRef context,
        ContactPhoneNumberTypeArrayPtr types(NULL);
 
        Try {
-               number = converter->toString(arguments[0]);
+               if(argumentCount >= 1)
+                       number = converter->toString(arguments[0]);
+               else
+                       number = converter->toString(JSValueMakeUndefined(context));
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Internal error");
                return NULL;
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(JSIsArrayValue(gContext, arguments[1]))
-                               types = converter->toContactPhoneNumberTypeArray(arguments[1]);
-               }
-               if(types == NULL)
-               {
+               if(js2ndParamIsArray)
+                       types = converter->toContactPhoneNumberTypeArray(arguments[1]);
+               else
                        types = ContactPhoneNumberTypeArrayPtr(new ContactPhoneNumberTypeArray());
+
+               if(types->size() == 0)
                        types->push_back(CONTACT_PHONE_NUMBER_TYPE_VOICE);
-               }
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
index f6cd766..e0aaacb 100755 (executable)
@@ -26,7 +26,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactRef.h"
 
@@ -164,7 +163,7 @@ JSObjectRef JSContactRef::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactRefPriv *priv = static_cast<JSContactRefPriv*>(JSObjectGetPrivate(constructor));
@@ -173,22 +172,20 @@ JSObjectRef JSContactRef::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount != 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+               if (argumentCount < 2)
+                       ThrowMsg(InvalidArgumentException, "2nd argument must be contact id");
 
                if (!JSValueIsString(gContext, arguments[0]))
-                               ThrowMsg(InvalidArgumentException, "1st argument is not string.");
+                       ThrowMsg(InvalidArgumentException, "1st argument must be address book id");
 
                if (!JSValueIsString(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
+                       ThrowMsg(InvalidArgumentException, "2nd argument must be contact id");
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Wrong arguments");
                return NULL;
        }
 
index 45f9917..45061e1 100755 (executable)
@@ -25,7 +25,6 @@
 #include <CommonsJavaScript/Validator.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-//#include <Tizen/Common/JSGlobalContextFactory.h>
 #include "ContactConverter.h"
 #include "JSContactWebSite.h"
 
@@ -157,7 +156,9 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsString = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSContactWebSitePriv *priv = static_cast<JSContactWebSitePriv*>(JSObjectGetPrivate(constructor));
@@ -166,25 +167,17 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
        }
        JSContextRef gContext = priv->getContext();
 
-//     JSContextRef gContext = JSGlobalContextFactory::getInstance()->get();
-
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
-                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
-
-               if (!JSValueIsString(gContext, arguments[0]))
-                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
-
                if (argumentCount >= 2)
                {
-                       if (!JSValueIsString(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
+                       if (!JSValueIsUndefined(context, arguments[1]) && !JSValueIsNull(context, arguments[1]))
+                               js2ndParamIsString = true;
                }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "1st argument must be a 'Date object'");
                return NULL;
        }
 
@@ -192,10 +185,13 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
 
        std::string url;
        ContactWebSiteType type = WEBSITE_TYPE_HOMEPAGE;
-       bool typeIsSet = false;
 
        Try {
-               url = converter->toString(arguments[0]);
+               if (argumentCount >= 1)
+                       url = converter->toString(arguments[0]);
+               else
+                       url = converter->toString(JSValueMakeUndefined(context));
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -203,23 +199,16 @@ JSObjectRef JSContactWebSite::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(JSValueIsString(gContext, arguments[1]))
-                       {
-                               type = converter->toContactWebSiteType(arguments[1]);
-                               typeIsSet = true;
-                       }
-               }
+               if (js2ndParamIsString)
+                       type = converter->toContactWebSiteType(arguments[1]);
+
        } Catch(Exception) {
-               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
-               return NULL;
+               LogError("2nd argument only support 'HOMEPAGE' or 'BLOG'");
        }
 
        ContactWebSitePtr contactWebSite(new ContactWebSite());
        contactWebSite->setUrl(url);
-       if(typeIsSet)
+       if(js2ndParamIsString)
                contactWebSite->setType(type);
 
        JSObjectRef jsobject;
index 11441b4..72500e7 100755 (executable)
@@ -42,9 +42,8 @@ namespace Contact {
 
 DECLARE_FUNCTION_GETTER(Contact);
 
-#define CONTACT_CHECK_ACCESS(globalContext, functionName)                     \
+#define CONTACT_CHECK_ACCESS(functionName)                     \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getContactFunctionData,           \
         functionName)
 
index 0840b76..4e103b6 100755 (executable)
@@ -24,7 +24,7 @@
 #include <dpl/log/log.h>
 
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include "JSContactManager.h"
 #include "JSContact.h"
 #include "JSContactRef.h"
 #include "JSContactPhoneNumber.h"
 #include "JSContactEmailAddress.h"
 
-void on_widget_start_callback(int widgetId,
-        JavaScriptContext context,
-        const engine_interface_t *interface)
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\contact] on_widget_start_callback (" << widgetId << ")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(
-            widgetId,
-            context,
-            interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper registration failed");
+        LogError("WrtAccess initialization failed");
     }
 }
 
@@ -60,11 +58,11 @@ void on_widget_stop_callback(int widgetId)
     LogDebug("[Tizen\\contact] on_widget_stop_callback (" << widgetId << ")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper removal failed");
+        LogError("WrtAccess deinitialization failed");
     }
 }
 
index e46e381..6024feb 100755 (executable)
@@ -54,6 +54,7 @@ const char* ENCODINGS[] = {
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Filesystem;
 
 namespace TizenApis {
 namespace Tizen1_0{
@@ -62,98 +63,42 @@ Converter::Converter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::C
 }
 
 JSValueRef Converter::toJSValueRef(
-        const Api::Filesystem::StoragePropertiesPtr &arg,
-        JSContextRef context)
-{
-       Api::Filesystem::StorageProperties tmpStorage;
-
-       tmpStorage.setLabel(arg->getLabel()); 
-       tmpStorage.setType(arg->getType());
-
-       switch (arg->getState()) {
-       case Api::Filesystem::StorageProperties::STATE_MOUNTED :
-       case Api::Filesystem::StorageProperties::STATE_MOUNTED_READONLY :
-               tmpStorage.setState(JSStorage::STATE_MOUNTED);
-               break;
-       case Api::Filesystem::StorageProperties::STATE_REMOVED:
-               tmpStorage.setState(JSStorage::STATE_REMOVED);
-               break;
-       case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
-               tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
-               break;
-       }
-
-       JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
-       if (!jsObject) {
-               ThrowMsg(Commons::ConversionException, "Could not create JS object.");
-       }
-
-       return toJSValueRef(jsObject);
-}
-
-JSValueRef Converter::toJSValueRef(
-        const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
+        const NodeList& arg,
+        const JSFile::PrivateObjectDef::PermissionList &parentPermissions,
         JSContextRef context)
 {
-       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
-       if (!jsResult) {
-               ThrowMsg(Commons::ConversionException, "Could not create js array object");
-       }
-
-       Api::Filesystem::StorageProperties tmpStorage;
-
-       for (size_t i = 0; i < arg.size(); i++) {
-               tmpStorage.setLabel(arg[i]->getLabel()); 
-               tmpStorage.setType(arg[i]->getType());
-
-               switch (arg[i]->getState()) {
-               case Api::Filesystem::StorageProperties::STATE_MOUNTED :
-               case Api::Filesystem::StorageProperties::STATE_MOUNTED_READONLY :
-                       tmpStorage.setState(JSStorage::STATE_MOUNTED);
-                       break;
-               case Api::Filesystem::StorageProperties::STATE_REMOVED:
-                       tmpStorage.setState(JSStorage::STATE_REMOVED);
-                       break;
-               case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
-                       tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
-                       break;
-               }
-
-               JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
-               if (!jsObject) {
-                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
-               }
-
-               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
-                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
-               }
-       }
-
-       return jsResult;
+    JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+    if (!jsResult) {
+        ThrowMsg(Commons::ConversionException,
+                 "Could not create js array object");
+    }
+
+    for (std::size_t i = 0; i < arg.size(); ++i)
+    {
+        JSFile::PrivateObjectDefPtr privData(
+                new JSFile::PrivateObjectDef(
+                    arg[i],
+                    parentPermissions));
+        JSFile::PrivateObject* privateObject = new JSFile::PrivateObject(
+                context,
+                privData);
+        JSObjectRef jsObject = JSObjectMake(m_context,
+                                            JSFile::getClassRef(),
+                                            privateObject);
+        if (!jsObject) {
+            delete privateObject;
+            ThrowMsg(Commons::ConversionException,
+                     "Could not create JS object.");
+        }
+        if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+            ThrowMsg(Commons::ConversionException,
+                     "Could not insert value into js array");
+        }
+    }
+
+    return jsResult;
 }
 
-JSValueRef Converter::toJSValueRef(const Api::Filesystem::NodeList& arg,
-        JSContextRef context)
-{
-       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
-       if (!jsResult) {
-               ThrowMsg(Commons::ConversionException, "Could not create js array object");
-       }
-
-       for (std::size_t i = 0; i < arg.size(); ++i) {
-               JSFile::PrivateObject* privateObject = new JSFile::PrivateObject(context, arg[i]);
-               JSObjectRef jsObject = JSObjectMake(m_context, JSFile::getClassRef(), privateObject);
-               if (!jsObject) {
-                       delete privateObject;
-                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
-               }
-               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
-                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
-               }
-       }
-
-       return jsResult;
-}
 
 JSValueRef Converter::toJSValueRef(unsigned char* data, std::size_t num)
 {
@@ -180,7 +125,7 @@ Api::Filesystem::IPathPtr Converter::toPath(const JSValueRef& arg)
                        ThrowMsg(Commons::ConversionException, "Invalid path component.");
                }
                return Api::Filesystem::IPath::create(path);
-       } Catch (Commons::InvalidArgumentException) {
+       } Catch (Commons::ConversionException) {
                ReThrowMsg(Commons::ConversionException, "Not a valid path.");
        }
 }
@@ -232,7 +177,7 @@ Api::Filesystem::AccessMode Converter::toAccessMode(const JSValueRef& arg)
                return Api::Filesystem::AM_WRITE;
        }
        
-       ThrowMsg(Commons::InvalidArgumentException, "Invalid mode.");
+       ThrowMsg(Commons::ConversionException, "Invalid mode.");
 }
 
 std::string Converter::toEncoding(const JSValueRef& arg)
@@ -245,7 +190,7 @@ std::string Converter::toEncoding(const JSValueRef& arg)
                }
                ++ptr;
        }
-       ThrowMsg(Commons::InvalidArgumentException, "Invalid encoding");
+       ThrowMsg(Commons::ConversionException, "Invalid encoding");
 }
 JSValueRef Converter::toStorageState(const short type)
 {
@@ -258,7 +203,7 @@ JSValueRef Converter::toStorageState(const short type)
                case JSStorage::STATE_UNMOUNTABLE:
                        return toJSValueRef(STORAGE_TYPE_STATE_UNMOUNTABLE);
        }
-       ThrowMsg(Commons::InvalidArgumentException, "Invalid storage type");
+       ThrowMsg(Commons::ConversionException, "Invalid storage type");
 }
 
 JSValueRef Converter::toStorageType(const short state)
@@ -270,9 +215,78 @@ JSValueRef Converter::toStorageType(const short state)
                case Api::Filesystem::StorageProperties::TYPE_EXTERNAL:
                        return toJSValueRef(STORAGE_TYPE_EXTERNAL);
        }
-       ThrowMsg(Commons::InvalidArgumentException, "Invalid storage state");
+       ThrowMsg(Commons::ConversionException, "Invalid storage state");
+}
+
+JSValueRef Converter::toJSValueRef(
+        const Api::Filesystem::StoragePropertiesPtr &arg,
+        JSContextRef context)
+{
+       Api::Filesystem::StorageProperties tmpStorage;
+
+       tmpStorage.setLabel(arg->getLabel()); 
+       tmpStorage.setType(arg->getType());
+
+       switch (arg->getState()) {
+       case Api::Filesystem::StorageProperties::STATE_MOUNTED :
+       case Api::Filesystem::StorageProperties::STATE_MOUNTED_READONLY :
+               tmpStorage.setState(JSStorage::STATE_MOUNTED);
+               break;
+       case Api::Filesystem::StorageProperties::STATE_REMOVED:
+               tmpStorage.setState(JSStorage::STATE_REMOVED);
+               break;
+       case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
+               tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
+               break;
+       }
+
+       JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
+       if (!jsObject) {
+               ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+       }
+
+       return toJSValueRef(jsObject);
 }
 
+JSValueRef Converter::toJSValueRef(
+        const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
+        JSContextRef context)
+{
+       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+       if (!jsResult) {
+               ThrowMsg(Commons::ConversionException, "Could not create js array object");
+       }
+
+       Api::Filesystem::StorageProperties tmpStorage;
+
+       for (size_t i = 0; i < arg.size(); i++) {
+               tmpStorage.setLabel(arg[i]->getLabel()); 
+               tmpStorage.setType(arg[i]->getType());
+
+               switch (arg[i]->getState()) {
+               case Api::Filesystem::StorageProperties::STATE_MOUNTED :
+               case Api::Filesystem::StorageProperties::STATE_MOUNTED_READONLY :
+                       tmpStorage.setState(JSStorage::STATE_MOUNTED);
+                       break;
+               case Api::Filesystem::StorageProperties::STATE_REMOVED:
+                       tmpStorage.setState(JSStorage::STATE_REMOVED);
+                       break;
+               case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
+                       tmpStorage.setState(JSStorage::STATE_UNMOUNTABLE);
+                       break;
+               }
+
+               JSObjectRef jsObject = JSStorage::createJSObject(context, tmpStorage);
+               if (!jsObject) {
+                       ThrowMsg(Commons::ConversionException, "Could not create JS object.");
+               }
 
+               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+               }
+       }
+
+       return jsResult;
+}
 }
 }
index 6c2bd9e..f450bda 100755 (executable)
@@ -28,6 +28,7 @@
 #include <API/Filesystem/INodeTypes.h>
 #include <API/Filesystem/NodeFilter.h>
 #include <API/Filesystem/StorageProperties.h>
+#include "JSFile.h"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -39,17 +40,12 @@ public:
 public:
        explicit Converter(JSContextRef context);
 
-       JSValueRef toJSValueRef(
-               const Api::Filesystem::StoragePropertiesPtr &arg,
-               JSContextRef context);
-
-       JSValueRef toJSValueRef(
-               const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
-               JSContextRef context);
 
-       JSValueRef toJSValueRef(const Api::Filesystem::NodeList& arg,
-               JSContextRef context);
 
+    JSValueRef toJSValueRef(
+            const Api::Filesystem::NodeList& arg,
+            const JSFile::PrivateObjectDef::PermissionList &parentPermissions,
+            JSContextRef context);     
        JSValueRef toJSValueRef(unsigned char* data,
                std::size_t num);
 
@@ -63,6 +59,13 @@ public:
        
        JSValueRef toStorageType(const short type);
        JSValueRef toStorageState(const short state);
+       JSValueRef toJSValueRef(
+               const Api::Filesystem::StoragePropertiesPtr &arg,
+               JSContextRef context);
+
+       JSValueRef toJSValueRef(
+               const std::vector<Api::Filesystem::StoragePropertiesPtr>& arg,
+               JSContextRef context);
 };
 
 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<Converter> ConverterFactory;
index b3d6386..fc9e888 100755 (executable)
@@ -22,7 +22,7 @@
 #include <Commons/Exception.h>
 #include <API/Filesystem/Enums.h>
 #include <API/Filesystem/IManager.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <WidgetDB/WidgetDBMgr.h>
 #include "FilesystemUtils.h"
 
@@ -78,11 +78,11 @@ const PathToRootMap& getPathToRootMap()
 IPathPtr fromVirtualPath(JSContextRef context,
                          const std::string& arg)
 {
-/*     IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");*/
+       LogDebug("arg:[" << arg << "]");
 
        if (!isPathValid(arg)) {
-               ThrowMsg(Commons::NotFoundException, "Not found path component.");
+               LogDebug("virtual path is invalid:[" << arg << "]");
+               ThrowMsg(Commons::ConversionException, "Not found path component.");
        }
 
        std::string root;
@@ -95,8 +95,9 @@ IPathPtr fromVirtualPath(JSContextRef context,
                root = arg;
        }
 
-/*    WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());*/
+/*    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+      WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(widgetId);*/
 
        RootToPathMap rootToPath = getRootToPathMap();
 /*     rootToPath["wgt-package"] = widgetDB->getWidgetInstallationPath();
@@ -116,11 +117,10 @@ IPathPtr fromVirtualPath(JSContextRef context,
 }
 
 std::string toVirtualPath(JSContextRef context, const std::string& arg) {
-       IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-       Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
 
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
 
        PathToRootMap pathToRoot = getPathToRootMap();
        pathToRoot[widgetDB->getWidgetInstallationPath()] = "wgt-package";
@@ -140,27 +140,21 @@ std::string toVirtualPath(JSContextRef context, const std::string& arg) {
 }
 
 bool isPathValid(const std::string& path) {
-       static const std::string currentDirBegin(
-               PATH_INVALID_COMPONENT_CURRENT_DIR +
-               Api::Filesystem::IPath::getSeparator());
-       static const std::string parentDirBegin(
-               PATH_INVALID_COMPONENT_PARENT_DIR +
-               Api::Filesystem::IPath::getSeparator());
-       static const std::string currentDirMiddle(
-               Api::Filesystem::IPath::getSeparator() +
-               PATH_INVALID_COMPONENT_CURRENT_DIR +
-               Api::Filesystem::IPath::getSeparator());
-       static const std::string parentDirMiddle(
-               Api::Filesystem::IPath::getSeparator() +
-               PATH_INVALID_COMPONENT_PARENT_DIR +
+       static const std::string currentDirBegin(PATH_INVALID_COMPONENT_CURRENT_DIR + Api::Filesystem::IPath::getSeparator());
+       static const std::string parentDirBegin(PATH_INVALID_COMPONENT_PARENT_DIR +
                Api::Filesystem::IPath::getSeparator());
+       static const std::string currentDirMiddle(Api::Filesystem::IPath::getSeparator() +
+               PATH_INVALID_COMPONENT_CURRENT_DIR +Api::Filesystem::IPath::getSeparator());
+       static const std::string parentDirMiddle(Api::Filesystem::IPath::getSeparator() +
+               PATH_INVALID_COMPONENT_PARENT_DIR +Api::Filesystem::IPath::getSeparator());
 
        if (path.find(parentDirBegin) == 0 ||
-               path.find(currentDirBegin) == 0 ||
+                       path.find(currentDirBegin) == 0 ||
                path.find(parentDirMiddle) != std::string::npos ||
                path.find(currentDirMiddle) != std::string::npos) {
                return false;
        }
+
        return true;
 }
 
index 64d7a76..a16c9d6 100755 (executable)
@@ -23,8 +23,7 @@
 
 #include <Commons/FunctionDeclaration.h>
 #include <Commons/Exception.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
-#include <Commons/WrtWrapper/IWrtWrapper.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <API/Filesystem/Enums.h>
 #include <API/Filesystem/IManager.h>
 #include <API/Filesystem/EventCopy.h>
@@ -52,18 +51,19 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Commons;
 
 namespace {
-const char* PLUGIN_NAME = "File";
-const char* PROPERTY_PARENT = "parent";
-const char* PROPERTY_READ_ONLY = "readOnly";
-const char* PROPERTY_IS_FILE = "isFile";
-const char* PROPERTY_IS_DIRECTORY = "isDirectory";
-const char* PROPERTY_CREATED = "created";
-const char* PROPERTY_MODIFIED = "modified";
-const char* PROPERTY_PATH = "path";
-const char* PROPERTY_NAME = "name";
-const char* PROPERTY_FULL_PATH = "fullPath";
-const char* PROPERTY_FILE_SIZE = "fileSize";
-const char* PROPERTY_LENGTH = "length";
+#define PLUGIN_NAME  "File"
+#define PROPERTY_PARENT  "parent"
+#define PROPERTY_READ_ONLY  "readOnly"
+#define PROPERTY_IS_FILE  "isFile"
+#define PROPERTY_IS_DIRECTORY "isDirectory"
+#define PROPERTY_CREATED  "created"
+#define PROPERTY_MODIFIED  "modified"
+#define PROPERTY_PATH  "path"
+#define PROPERTY_NAME  "name"
+#define PROPERTY_FULL_PATH  "fullPath"
+#define PROPERTY_FILE_SIZE  "fileSize"
+#define PROPERTY_LENGTH "length"
+}      //namespace
 
 JSValueRef getFunctionOrNull(JSContextRef ctx, JSValueRef arg)
 {
@@ -76,15 +76,14 @@ JSValueRef getFunctionOrNull(JSContextRef ctx, JSValueRef arg)
 }
 
 
+
 JSValueRef getFunction(JSContextRef ctx, JSValueRef arg)
 {
        if (Validator(ctx).isCallback(arg)) {
                return arg;
-       } else if (JSValueIsNull(ctx, arg) || JSValueIsUndefined(ctx, arg)) {
-               ThrowMsg(InvalidArgumentException, "JS null passed as function.");
+       } else{
+               ThrowMsg(ConversionException, "Not a function nor JS null.");
        }
-       ThrowMsg(ConversionException, "Not a function nor JS null.");
-}
 }
 
 namespace TizenApis {
@@ -174,44 +173,136 @@ JSValueRef JSFile::getProperty(JSContextRef context,
                JSStringRef propertyName,
                JSValueRef* exception)
 {
-       PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
-       if (!privateObject) {
-               return JSValueMakeUndefined(context);
-       }
+    PrivateObject* privateObject =
+        static_cast<PrivateObject*>(JSObjectGetPrivate(object));
+    if (!privateObject) {
+        LogError("Private object is not set.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+    }
 
        JSContextRef globalContext = privateObject->getContext();
        Converter converter(globalContext);
 
-       try {
-               if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PARENT)) {
-                       INodePtr parent(privateObject->getObject()->getParent());
-                       if (parent) {
-                               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), parent);
+    try {
+        if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PARENT))
+        {
+            INodePtr parent(privateObject->getObject()->getNode()->getParent());
+            PrivateObjectDef::PermissionList perms =
+                privateObject->getObject()->getParentPermissions();
+            if (parent && !perms.empty())
+            {
+                parent->setPermissions(perms.back());
+                perms.pop_back();
+                PrivateObjectDefPtr privData(new PrivateObjectDef(
+                    parent,
+                    perms));
+
+                               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), privData);
                        }
                        return JSValueMakeNull(context);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_READ_ONLY)) {
-                       bool readOnly = ((privateObject->getObject()->getMode() & PERM_WRITE) == 0);
+               } 
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_READ_ONLY))
+        {
+            bool readOnly =
+                ((privateObject->getObject()->getNode()->getMode() & PERM_WRITE) == 0);
+            return converter.toJSValueRef(readOnly);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_IS_FILE))
+        {
+            bool isFile = (privateObject->getObject()->getNode()->getType() == NT_FILE);
+            return converter.toJSValueRef(isFile);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName,
+                                              PROPERTY_IS_DIRECTORY))
+        {
+            bool isDirectory =
+                (privateObject->getObject()->getNode()->getType() == NT_DIRECTORY);
+            return converter.toJSValueRef(isDirectory);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_CREATED))
+        {
+            std::time_t created = privateObject->getObject()->getNode()->getCreated();
+            return converter.toJSValueRef(created);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MODIFIED))
+        {
+            std::time_t modified = privateObject->getObject()->getNode()->getModified();
+            return converter.toJSValueRef(modified);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PATH))
+        {
+            std::string fpath =
+                privateObject->getObject()->getNode()->getPath()->getFullPath();
+            std::string vpath = Utils::toVirtualPath(globalContext, fpath);
+            std::string::size_type pos = vpath.rfind(IPath::getSeparator());
+            std::string path =
+                (std::string::npos != pos ? vpath.substr(0, pos + 1) : vpath);
+            return converter.toJSValueRef(path);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME))
+        {
+            std::string fpath =
+                privateObject->getObject()->getNode()->getPath()->getFullPath();
+            std::string vpath = Utils::toVirtualPath(globalContext, fpath);
+            std::string name;
+            std::string::size_type pos = vpath.rfind(IPath::getSeparator());
+            if (std::string::npos != pos) {
+                name = vpath.substr(pos + 1);
+            }
+            return converter.toJSValueRef(name);
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FULL_PATH))
+        {
+            std::string path =
+                privateObject->getObject()->getNode()->getPath()->getFullPath();
+            return converter.toJSValueRef(Utils::toVirtualPath(globalContext,
+                                                               path));
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FILE_SIZE))
+        {
+            if (privateObject->getObject()->getNode()->getType() == NT_DIRECTORY)
+            {
+                return JSValueMakeUndefined(context);
+            }
+            return converter.toJSValueRef(privateObject->getObject()->getNode()->getSize());
+        }
+        else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_LENGTH))
+        {
+            if (privateObject->getObject()->getNode()->getType() == NT_FILE) {
+                return JSValueMakeUndefined(context);
+            }
+            // TODO: think about more efficent solution!
+            NodeList children = privateObject->getObject()->getNode()->getChildNodes();
+            return converter.toJSValueRef(children.size());
+        }
+    }
+    catch (const WrtDeviceApis::Commons::Exception& ex) {
+        LogError("Exception: " << ex.GetMessage());
+    }
+/*
+    else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_READ_ONLY)) {
+                       bool readOnly = ((privateObject->getObject()->getNode() & PERM_WRITE) == 0);
                        return converter.toJSValueRef(readOnly);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_IS_FILE)) {
-                       bool isFile = (privateObject->getObject()->getType() == NT_FILE);
+                       bool isFile = (privateObject->getObject()->getNode()->getType() == NT_FILE);
                        return converter.toJSValueRef(isFile);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_IS_DIRECTORY)) {
-                       bool isDirectory =(privateObject->getObject()->getType() == NT_DIRECTORY);
+                       bool isDirectory =(privateObject->getObject()->getNode()->getType() == NT_DIRECTORY);
                        return converter.toJSValueRef(isDirectory);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_CREATED)) {
-                       std::time_t created = privateObject->getObject()->getCreated();
+                       std::time_t created = privateObject->getObject()->getNode()->getCreated();
                        return converter.toJSValueRef(created);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_MODIFIED)) {
-                       std::time_t modified = privateObject->getObject()->getModified();
+                       std::time_t modified = privateObject->getObject()->getNode()->getModified();
                        return converter.toJSValueRef(modified);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_PATH)) {
-                       std::string fpath = privateObject->getObject()->getPath()->getFullPath();
+                       std::string fpath = privateObject->getObject()->getNode()->getPath()->getFullPath();
                        std::string vpath = Utils::toVirtualPath(globalContext, fpath);
                        std::string::size_type pos = vpath.rfind(IPath::getSeparator());
                        std::string path = (std::string::npos != pos ? vpath.substr(0, pos + 1) : vpath);
                        return converter.toJSValueRef(path);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAME)) {
-                       std::string fpath = privateObject->getObject()->getPath()->getFullPath();
+                       std::string fpath = privateObject->getObject()->getNode()->getPath()->getFullPath();
                        std::string vpath = Utils::toVirtualPath(globalContext, fpath);
                        std::string name;
                        std::string::size_type pos = vpath.rfind(IPath::getSeparator());
@@ -220,23 +311,23 @@ JSValueRef JSFile::getProperty(JSContextRef context,
                        }
                        return converter.toJSValueRef(name);
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FULL_PATH)) {
-                       std::string path = privateObject->getObject()->getPath()->getFullPath();
+                       std::string path = privateObject->getObject()->getNode()->getPath()->getFullPath();
                        return converter.toJSValueRef(Utils::toVirtualPath(globalContext, path));
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_FILE_SIZE)) {
-                       if (privateObject->getObject()->getType() == NT_DIRECTORY) {
+                       if (privateObject->getObject()->getNode()->getType() == NT_DIRECTORY) {
                                return JSValueMakeUndefined(context);
                        }
-                       return converter.toJSValueRef(privateObject->getObject()->getSize());
+                       return converter.toJSValueRef(privateObject->getObject()->getNode()->getSize());
                } else if (JSStringIsEqualToUTF8CString(propertyName, PROPERTY_LENGTH)) {
-                       if (privateObject->getObject()->getType() == NT_FILE) {
+                       if (privateObject->getObject()->getNode()->getType() == NT_FILE) {
                                return JSValueMakeUndefined(context);
                        }
-                       NodeList children = privateObject->getObject()->getChildNodes();
+                       NodeList children = privateObject->getObject()->getNode()->getChildNodes();
                        return converter.toJSValueRef(children.size());
                }
        } catch (const WrtDeviceApis::Commons::Exception& ex) {
                LogWarning("trying to get incorrect value");
-       }
+       }*/
 
        return JSValueMakeUndefined(context);
 }
@@ -264,16 +355,16 @@ JSValueRef JSFile::toUri(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+        LogError("Private object is not set.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        try {
-               IWrtWrapperPtr wrapper = WrtWrappersMgr::getInstance().getWrtWrapper(privateObject->getContext());
-               int widgetId = wrapper->getWidgetId();
-               return converter.toJSValueRef(privateObject->getObject()->toUri(widgetId));
+        int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+               return converter.toJSValueRef(privateObject->getObject()->getNode()->toUri(widgetId));
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -293,25 +384,33 @@ JSValueRef JSFile::listFiles(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        LogDebug("OK");
  
        JSContextRef globalContext = privateObject->getContext();
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
        try {
+
+               for (index = 0; index < 3; index++)
+               {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
                
-               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               }
+               
+               JSValueRef onSuccess = getFunction(globalContext, reserveArguments[0]);
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-                       
+
+
                if (argc > 1) {
-                       onError = getFunctionOrNull(globalContext, argv[1]);
+                       onError = getFunctionOrNull(globalContext, reserveArguments[1]);
                }
 
                cbm->setOnSuccess(onSuccess);
@@ -319,31 +418,39 @@ JSValueRef JSFile::listFiles(JSContextRef context,
 
                Converter converter(globalContext);
 
-               EventListNodesPtr event(new EventListNodes(privateObject->getObject()));
+               EventListNodesPtr event(new EventListNodes(privateObject->getObject()->getNode()));
                if (argc > 2) {
-                       if (!JSValueIsNull(context, argv[2]) && !JSValueIsUndefined(context, argv[2])) {
-                               try {
-                                       event->setFilter(converter.toNodeFilter(argv[2]));
-                               } catch(WrtDeviceApis::Commons::ConversionException) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-                               }
+                       if (JSValueIsNull(context, reserveArguments[2]) == false &&
+                               JSValueIsUndefined(context, reserveArguments[2]) == false) {
+                               event->setFilter(converter.toNodeFilter(reserveArguments[2]));
                        }
                }
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
-               privateObject->getObject()->getChildNodes(event);
+        PrivateObjectDef::PermissionList perms =
+            privateObject->getObject()->getParentPermissions();
+        perms.push_back(privateObject->getObject()->getNode()->getPermissions());
+
+        ListFilesPrivateDataPtr privData(
+            new ListFilesPrivateData(cbm, perms));
+
+        event->setPrivateData(
+            DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));
+        event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+        JSValueProtect(globalContext, thisObject);
+               
+        privateObject->getObject()->getNode()->getChildNodes(event);
+
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFile::openStream(JSContextRef context,
@@ -355,24 +462,29 @@ JSValueRef JSFile::openStream(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argumentCount < 2) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        JSContextRef globalContext = privateObject->getContext();
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
+       size_t index = 0;
+       JSValueRef reserveArguments[4];
 
        try {
 
-               JSValueRef onSuccess = getFunction(globalContext, arguments[1]);
+               for (index = 0; index < 4; index++) {
+                       if (index < argumentCount)
+                               reserveArguments[index] = arguments[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
+               }
+
+               JSValueRef onSuccess = getFunction(globalContext, reserveArguments[1]);
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
                        
-               if (argumentCount > 2) {
-                       onError = getFunctionOrNull(globalContext, arguments[2]);
-               }
+               onError = getFunctionOrNull(globalContext, reserveArguments[2]);
 
                cbm->setOnSuccess(onSuccess);
                cbm->setOnError(onError);
@@ -380,45 +492,48 @@ JSValueRef JSFile::openStream(JSContextRef context,
                
                Converter converter(globalContext);
 
-               AccessMode mode = converter.toAccessMode(arguments[0]);
-
+               AccessMode mode = converter.toAccessMode(reserveArguments[0]);
                std::string encoding = Encodings::UTF8;
                if (argumentCount > 3) {
-                       encoding = converter.toEncoding(arguments[3]);
+                       if(!JSValueIsNull(globalContext, reserveArguments[3]) && !JSValueIsUndefined(globalContext, reserveArguments[3])){
+                               encoding = converter.toEncoding(reserveArguments[3]);
+                       }
                }
 
-               if ((AM_READ != mode) && (PERM_READ == privateObject->getObject()->getPermissions())) {
+               if ((AM_READ != mode) && (PERM_READ == privateObject->getObject()->getNode()->getPermissions())) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                }
 
-               std::string path = privateObject->getObject()->getPath()->getFullPath();
+        std::string path = privateObject->getObject()->getNode()->getPath()->getFullPath();
                std::string vpath = Utils::toVirtualPath(globalContext, path);
 
                AccessModeInfo am = AccessModeInfo(mode, vpath);
                AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
-                               globalContext,
                                FILESYSTEM_FUNCTION_API_OPEN_STREAM,
                                am);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               EventOpenPtr event(new EventOpen(mode));
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
-
-               privateObject->getObject()->open(event);
+        EventOpenPtr event(new EventOpen(mode));
+        event->setPrivateData(
+            DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(
+                cbm));
+        event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+        JSValueProtect(globalContext, thisObject);
+                               
+        privateObject->getObject()->getNode()->open(event);
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFile::readAsText(JSContextRef context,
@@ -430,27 +545,34 @@ JSValueRef JSFile::readAsText(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
-       
+
        JSContextRef globalContext = privateObject->getContext();
        AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
-                       privateObject->getContext(),
                        FILESYSTEM_FUNCTION_API_READ_AS_TEXT);
 
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
        try {
+
+               for (index = 0; index < 3; index++) {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
+               }
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               JSValueRef onSuccess = getFunction(globalContext, reserveArguments[0]);
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
                        
                if (argc > 1) {
-                       onError = getFunctionOrNull(globalContext, argv[1]);
+                       onError = getFunctionOrNull(globalContext, reserveArguments[1]);
                }
 
                cbm->setOnSuccess(onSuccess);
@@ -459,29 +581,34 @@ JSValueRef JSFile::readAsText(JSContextRef context,
                Converter converter(context);
                std::string src = Encodings::UTF8;
                if (argc > 2) {
-                       if (!JSValueIsNull(context, argv[2]) && !JSValueIsUndefined(context, argv[2])) {
-                               src = converter.toEncoding(argv[2]);
+                       if (!JSValueIsNull(context, reserveArguments[2]) && !JSValueIsUndefined(context, reserveArguments[2])) {
+                               src = converter.toEncoding(reserveArguments[2]);
                        }
                }
 
-               if (NT_FILE != privateObject->getObject()->getType()) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               if (NT_FILE != privateObject->getObject()->getNode()->getType()) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                       return JSValueMakeUndefined(context);
                }
 
-               EventReadTextPtr event(new EventReadText());
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData> (cbm));
+        EventReadTextPtr event(new EventReadText());
+        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::
+                                                         IEventPrivateData,
+                                                     JSCallbackManager>(
+                                  cbm));
+        event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+        JSValueProtect(globalContext, thisObject);
 
-               privateObject->getObject()->read(event);
+        privateObject->getObject()->getNode()->read(event);
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
     return JSValueMakeUndefined(context);
@@ -496,69 +623,81 @@ JSValueRef JSFile::copyTo(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+               
        }
 
        JSContextRef globalContext = privateObject->getContext();
-
-       if (argc < 3) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
+       size_t index = 0;
+       JSValueRef reserveArguments[5];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
        try {
-               Converter converter(globalContext);
-               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
-               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(argv[1]));
-               bool overwrite = converter.toBool(argv[2]);;
 
+               for (index = 0; index < 5; index++)
+               {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
+               }
+
+               Converter converter(globalContext);
                JSValueRef onSuccess = NULL;
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
-               if (argc > 3) {
-                       onSuccess = getFunctionOrNull(globalContext, argv[3]);
-               }
-               
-               if (argc > 4) {
-                       onError = getFunctionOrNull(globalContext, argv[4]);
-               }
+               onSuccess = getFunctionOrNull(globalContext, reserveArguments[3]);
+               onError = getFunctionOrNull(globalContext, reserveArguments[4]);
 
                cbm->setOnSuccess(onSuccess);
-               cbm->setOnError(onError);
+               cbm->setOnError(onError);               
+
+
+               //TODO add check validation for src, dest string.
+               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
+               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[1]));
+               bool overwrite = converter.toBool(reserveArguments[2]);;
                
-               if (NT_DIRECTORY != privateObject->getObject()->getType()) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               if (NT_DIRECTORY != privateObject->getObject()->getNode()->getType()) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                       return JSValueMakeUndefined(context);
                }
 
                std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath());
                AccessModeInfo amode = AccessModeInfo(Api::Filesystem::AM_WRITE, virtualDestPath);
                AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
-                               globalContext,
                                FILESYSTEM_FUNCTION_API_COPY_TO,
                                amode);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               EventCopyPtr event(new EventCopy(src, dest));
-               if (overwrite) {
-                       event->setOptions(OPT_OVERWRITE);
-               }
-
-               event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
-               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
-               IManager::getInstance().copy(event);
+        EventCopyPtr event(new EventCopy(src, dest));
+        if (overwrite) {
+            event->setOptions(OPT_OVERWRITE);
+        }
+        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::
+                                                         IEventPrivateData,
+                                                     JSCallbackManager>(
+                                  cbm));
+        event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+        JSValueProtect(globalContext, thisObject);
+               
+        IManager::getInstance().copy(event);
                
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::NotFoundException &ex) {
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFile::moveTo(JSContextRef context,
@@ -570,52 +709,53 @@ JSValueRef JSFile::moveTo(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        JSContextRef globalContext = privateObject->getContext();
 
-       if (argc < 3) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
-
        LogDebug("OK");
        
+       size_t index = 0;
+       JSValueRef reserveArguments[5];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
+
        try {
 
-               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               for (index = 0; index < 5; index++) {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
                }
 
-               if (NT_DIRECTORY != privateObject->getObject()->getType()) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                }
 
                Converter converter(context);
-               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
-               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(argv[1]));
-               bool overwrite = converter.toBool(argv[2]);
-
                JSValueRef onSuccess = NULL;
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-
-               if (argc > 3) {
-                       onSuccess = getFunctionOrNull(globalContext, argv[3]);
-               }
-               
-               if (argc > 4) {
-                       onError = getFunctionOrNull(globalContext, argv[4]);
-               }
 
+               onSuccess = getFunctionOrNull(globalContext, reserveArguments[3]);
+               onError = getFunctionOrNull(globalContext, reserveArguments[4]);
                cbm->setOnSuccess(onSuccess);
                cbm->setOnError(onError);
 
+               if (NT_DIRECTORY != privateObject->getObject()->getNode()->getType()) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "io error"));
+                       return JSValueMakeUndefined(context);
+               }
+
+               IPathPtr src = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
+               IPathPtr dest = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[1]));
+               bool overwrite = converter.toBool(reserveArguments[2]);
+
                std::string virtualDestPath = Utils::toVirtualPath(globalContext, dest->getFullPath());
 
                AccessModeInfo amode = AccessModeInfo(Api::Filesystem::AM_WRITE, virtualDestPath);
                AceSecurityStatus status = FILESYSTEM_ACCESSMODE_CHECK_ACCESS(
-                               globalContext,
                                FILESYSTEM_FUNCTION_API_MOVE_TO,
                                amode);
 
@@ -628,19 +768,23 @@ JSValueRef JSFile::moveTo(JSContextRef context,
 
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               JSValueProtect(globalContext, thisObject);
 
                IManager::getInstance().move(event);
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
-       } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       }       catch(const WrtDeviceApis::Commons::NotFoundException &ex) {
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage()));
+       }
+       catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFile::createDirectory(JSContextRef context,
@@ -652,29 +796,43 @@ JSValueRef JSFile::createDirectory(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
-                       privateObject->getContext(),
                        FILESYSTEM_FUNCTION_API_CREATE_DIR);
 
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
 
        Converter converter(context);
        try {
-               IPathPtr path = converter.toPath(argv[0]);
-               INodePtr node(privateObject->getObject()->createChild(path, NT_DIRECTORY, OPT_RECURSIVE));
-               node->setPermissions(privateObject->getObject()->getPermissions());
-               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+               
+               if (argc < 1) {
+                       ThrowMsg(InvalidArgumentException, "Invalid path name");
+               }
+
+        IPathPtr path = converter.toPath(argv[0]);
+        INodePtr node(privateObject->getObject()->getNode()->createChild(
+                path,
+                NT_DIRECTORY,
+                OPT_RECURSIVE));
+        node->setPermissions(
+            privateObject->getObject()->getNode()->getPermissions());
+
+        PrivateObjectDefPtr privData(new PrivateObjectDef(
+            node,
+            privateObject->getObject()->getParentPermissions()));
+        privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions());
+
+        return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(
+                privateObject->getContext(),
+                getClassRef(), 
+                privData);
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -695,28 +853,44 @@ JSValueRef JSFile::createFile(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
-                       privateObject->getContext(),
                        FILESYSTEM_FUNCTION_API_CREATE_FILE);
 
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
 
        Converter converter(context);
        try {
+               
+               if (argc < 1) {
+                       ThrowMsg(InvalidArgumentException, "Invalid path name");
+               }
+
+        IPathPtr path = converter.toPath(argv[0]);
+        INodePtr node = privateObject->getObject()->getNode()->createChild(
+                path,
+                NT_FILE);
+
+        PrivateObjectDefPtr privData(new PrivateObjectDef(
+            node,
+            privateObject->getObject()->getParentPermissions()));
+        privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions());
+
+        return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(
+                privateObject->getContext(),
+                getClassRef(),
+                privData);
+/*
                IPathPtr path = converter.toPath(argv[0]);
-               INodePtr node = privateObject->getObject()->createChild(path, NT_FILE);
-               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+               INodePtr node = privateObject->getObject()->getNode()->createChild(path, NT_FILE);
+               return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);*/
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -737,35 +911,48 @@ JSValueRef JSFile::resolve(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
-       if (!JSValueIsString(context, argv[0])) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
 
-       if (privateObject->getObject()->getType() != NT_DIRECTORY) {
+       if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
        }
 
        Converter converter(context);
        try {
+               
+               if (argc < 1) {
+                       ThrowMsg(InvalidArgumentException, "Invalid path name");
+               }
+
+        IPathPtr path = converter.toPath(argv[0]);
+        INodePtr node = privateObject->getObject()->getNode()->getChild(path);
+        node->setPermissions(privateObject->getObject()->getNode()->getPermissions());
+        PrivateObjectDefPtr privData(new PrivateObjectDef(
+            node,
+            privateObject->getObject()->getParentPermissions()));
+        privData->pushParentPermissions(privateObject->getObject()->getNode()->getPermissions());
+        return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(
+                privateObject->getContext(),
+                getClassRef(),
+                privData);
+/*
                IPathPtr path = converter.toPath(argv[0]);
-               INodePtr node = privateObject->getObject()->getChild(path);
-               node->setPermissions(privateObject->getObject()->getPermissions());
+               INodePtr node = privateObject->getObject()->getNode()->getChild(path);
+               node->setPermissions(privateObject->getObject()->getNode()->getPermissions());
                return JSUtils::makeObject(privateObject->getContext(), getClassRef(), node);
+*/
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+       } catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
        }
@@ -782,7 +969,8 @@ JSValueRef JSFile::deleteDirectory(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+               
        }
 
        if (argc < 2) {
@@ -792,53 +980,68 @@ JSValueRef JSFile::deleteDirectory(JSContextRef context,
        JSContextRef globalContext = privateObject->getContext();
 
        LogDebug("OK");
-       
+
+       size_t index = 0;
+       JSValueRef reserveArguments[4];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);      
+
        try {
+               for (index = 0; index < 4; index++) {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
+               }
+                               
                AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
-                               globalContext,
                                FILESYSTEM_FUNCTION_API_DELETE_DIR);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
+               JSValueRef onSuccess = NULL;
+               JSValueRef onError = NULL;
+               
+               onSuccess = getFunctionOrNull(globalContext, reserveArguments[2]);
+               onError = getFunctionOrNull(globalContext, reserveArguments[3]);
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
+               
+               if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                }
 
-               if (privateObject->getObject()->getType() != NT_DIRECTORY) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                       return JSValueMakeUndefined(context);
+
+               }
+
+               if (JSValueIsNull(globalContext, reserveArguments[0]) || JSValueIsUndefined(globalContext, reserveArguments[0])) {
+                       ThrowMsg(InvalidArgumentException, "Invalid directory");
                }
 
                Converter converter(context);
-               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
-               bool recursive = converter.toBool(argv[1]);
+               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
+               bool recursive = converter.toBool(reserveArguments[1]);
 
-               if (*privateObject->getObject()->getPath() != path->getPath()) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+               if (*privateObject->getObject()->getNode()->getPath() != path->getPath()) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                       return JSValueMakeUndefined(context);
                }
-               JSValueRef onSuccess = NULL;
-               JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
                        
-               if (argc > 2) {
-                       onSuccess = getFunctionOrNull(globalContext, argv[2]);
-               }
-               
-               if (argc > 3) {
-                       onError = getFunctionOrNull(globalContext, argv[3]);
-               }
-
-               cbm->setOnSuccess(onSuccess);
-               cbm->setOnError(onError);
 
                EventResolvePtr eventResolve(new EventResolve(path));
                if (eventResolve->setForSynchronousCall()) { 
                        IManager::getInstance().getNode(eventResolve);
                        if (!eventResolve->getResult() || (eventResolve->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None)) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+                               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                               return JSValueMakeUndefined(context);
                        }
 
                        if (eventResolve->getResult()->getType() != NT_DIRECTORY) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+                               ThrowMsg(InvalidArgumentException, "Invalid directory");
                        }
 
                        EventRemovePtr eventRemove(new EventRemove(path));
@@ -849,21 +1052,24 @@ JSValueRef JSFile::deleteDirectory(JSContextRef context,
 
                        eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                        eventRemove->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+                       JSValueProtect(globalContext, thisObject);
+
                        IManager::getInstance().remove(eventRemove);
                }
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, ex.GetMessage()));
+
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFile::deleteFile(JSContextRef context,
@@ -873,60 +1079,77 @@ JSValueRef JSFile::deleteFile(JSContextRef context,
                const JSValueRef argv[],
                JSValueRef* exception)
 {
+       LogDebug("<<<");
+
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+               
        }
 
        JSContextRef globalContext = privateObject->getContext();
-
-       LogDebug("OK");
        
+       size_t index = 0;
+       JSValueRef reserveArguments[3];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);      
+
        try {
+               for (index = 0; index < 3; index++) {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);                                                        
+               
+               }
+
                AceSecurityStatus status = FILESYSTEM_CHECK_ACCESS(
-                               globalContext,
                                FILESYSTEM_FUNCTION_API_DELETE_FILE);
 
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if ((privateObject->getObject()->getPermissions() & PERM_WRITE) == 0) {
+               if ((privateObject->getObject()->getNode()->getPermissions() & PERM_WRITE) == 0) {
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                }
 
-               if (privateObject->getObject()->getType() != NT_DIRECTORY) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
-               }
-
-               Converter converter(context);
-               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(argv[0]));
-
                JSValueRef onSuccess = NULL;
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
-               if (argc > 1) {
-                       onSuccess = getFunctionOrNull(globalContext, argv[1]);
-               }
-               
-               if (argc > 2) {
-                       onError = getFunctionOrNull(globalContext, argv[2]);
-               }
+               onSuccess = getFunctionOrNull(globalContext, reserveArguments[1]);
+               onError = getFunctionOrNull(globalContext, reserveArguments[2]);
                
                cbm->setOnSuccess(onSuccess);
                cbm->setOnError(onError);
+               
+
+               if (privateObject->getObject()->getNode()->getType() != NT_DIRECTORY) {
+                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                       return JSValueMakeUndefined(context);
+               }
+
+               if (JSValueIsNull(globalContext, reserveArguments[0]) || JSValueIsUndefined(globalContext, reserveArguments[0])) {
+                       ThrowMsg(InvalidArgumentException, "Invalid directory");
+               }
+
+               Converter converter(context);
+               IPathPtr path = Utils::fromVirtualPath(globalContext, converter.toString(reserveArguments[0]));
 
                EventResolvePtr eventResolve(new EventResolve(path));
                if (eventResolve->setForSynchronousCall()) { 
                        IManager::getInstance().getNode(eventResolve);
+
                        if (!eventResolve->getResult() ||(eventResolve->getExceptionCode() != WrtDeviceApis::Commons::ExceptionCodes::None)) {
-                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, "IO error");
+                               if(eventResolve->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException){
+                                       LogDebug("POST IO NOT_FOUND_ERROR");
+                                       ThrowMsg(NotFoundException, "Not found error");
+                               }
+
+                               LogDebug("POST IO ERROR");
+                               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, "IO error"));
+                               return JSValueMakeUndefined(context);
                        }
 
-                       if (eventResolve->getResult()->getType() != NT_FILE) {
+                       if (eventResolve->getResult()->getType() != NT_FILE) {                          
+                               ThrowMsg(InvalidArgumentException, "Invalid directory");
                                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
                        }
                        
@@ -934,22 +1157,28 @@ JSValueRef JSFile::deleteFile(JSContextRef context,
                        EventRemovePtr eventRemove(new EventRemove(path));
                        eventRemove->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                        eventRemove->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+                       JSValueProtect(globalContext, thisObject);
+
                        IManager::getInstance().remove(eventRemove);
 
                }
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               LogDebug("Platform Exception !!!!!!!! post io error");
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::IO_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
+       } catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-       return JSValueMakeNull(context);
+       LogDebug(">>>");
+       return JSValueMakeUndefined(context);
 }
 }
 }
index e7b5d67..d11c87c 100755 (executable)
@@ -19,7 +19,9 @@
 #define TIZENAPIS_TIZEN_JSFILE_H_
 
 #include <JavaScriptCore/JavaScript.h>
+#include <Commons/IEvent.h>
 #include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Filesystem/INode.h>
 
 namespace TizenApis {
@@ -27,7 +29,82 @@ namespace Tizen1_0 {
 class JSFile
 {
 public:
-       typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Filesystem::INodePtr>::Type PrivateObject;
+
+    class PrivateObjectDef
+    {
+    public:
+
+        typedef std::vector<int> PermissionList;
+
+        PrivateObjectDef(const Api::Filesystem::INodePtr &node,
+                         const PermissionList &parentPermissions) :
+            m_node(node),
+            m_parentPerms(parentPermissions)
+        {
+        }
+
+        virtual ~PrivateObjectDef()
+        {
+        }
+
+        Api::Filesystem::INodePtr getNode() const
+        {
+            return m_node;
+        }
+
+        PermissionList getParentPermissions() const
+        {
+            return m_parentPerms;
+        }
+
+        void setParentPermissions(const PermissionList &permissions)
+        {
+            m_parentPerms = permissions;
+        }
+
+        void pushParentPermissions(int permissions)
+        {
+            m_parentPerms.push_back(permissions);
+        }
+
+    private:
+        Api::Filesystem::INodePtr m_node;
+        PermissionList m_parentPerms;
+    };
+
+    class ListFilesPrivateData : public WrtDeviceApis::Commons::IEventPrivateData
+    {
+    public:
+        ListFilesPrivateData(
+                const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr &callbackManager,
+                const PrivateObjectDef::PermissionList parentPermissions) :
+            m_callbackManager(callbackManager),
+            m_parentPermissions(parentPermissions)
+        {
+        }
+
+        virtual ~ListFilesPrivateData()
+        {
+        }
+
+        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getCallbackManager() const
+        {
+            return m_callbackManager;
+        }
+
+        PrivateObjectDef::PermissionList getParentPermissions() const
+        {
+            return m_parentPermissions;
+        }
+
+    private:
+        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_callbackManager;
+        PrivateObjectDef::PermissionList m_parentPermissions;
+    };
+
+    typedef DPL::SharedPtr<ListFilesPrivateData> ListFilesPrivateDataPtr;
+    typedef DPL::SharedPtr<PrivateObjectDef> PrivateObjectDefPtr;
+    typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<PrivateObjectDefPtr>::Type PrivateObject;
 
 public:
        static const JSClassDefinition* getClassInfo();
index eb44bfc..6c080da 100755 (executable)
@@ -111,7 +111,8 @@ JSValueRef JSFilestream::getProperty(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(object));
        if (!privateObject) {
-               return JSValueMakeUndefined(context);
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+               
        }
 
        PrivateObject::ObjectType stream = privateObject->getObject();
@@ -183,7 +184,8 @@ JSValueRef JSFilestream::close(JSContextRef context,
 {
        PrivateObject* privateObject =  static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
+               
        }
 
        Try {
@@ -204,20 +206,27 @@ JSValueRef JSFilestream::read(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        try {
-               unsigned long count = converter.toULong(argv[0]);
+               JSValueRef undefinedValue = JSValueMakeUndefined(context);
+               unsigned long count = 0;
+
+               if (argc > 0) 
+                       count = converter.toULong(argv[0]);
+               else 
+                       count = converter.toULong(undefinedValue);
+
+               if (count <= 0) {
+                       ThrowMsg(InvalidArgumentException, "Invalid argument");
+               }
+               
                DPL::ScopedArray<char> text(privateObject->getObject()->getChars(count));
                return converter.toJSValueRef(std::string(text.Get()));
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -238,20 +247,28 @@ JSValueRef JSFilestream::readBytes(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        Try {
-               unsigned long count = converter.toULong(argv[0]);
+               JSValueRef undefinedValue = JSValueMakeUndefined(context);
+               unsigned long count = 0;
+
+               if (argc > 0) 
+                       count = converter.toULong(argv[0]);
+               else 
+                       count = converter.toULong(undefinedValue);
+
+               if (count <= 0) {
+                       ThrowMsg(InvalidArgumentException, "Invalid argument");
+               }               
+
+
                DPL::ScopedArray<unsigned char> data(privateObject->getObject()->getBytes(count));
                return converter.toJSValueRef(data.Get(), privateObject->getObject()->getCount());
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -272,21 +289,28 @@ JSValueRef JSFilestream::readBase64(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        try {
-               unsigned long count = converter.toULong(argv[0]);
+               JSValueRef undefinedValue = JSValueMakeUndefined(context);
+               unsigned long count = 0;
+
+               if (argc > 0) 
+                       count = converter.toULong(argv[0]);
+               else 
+                       count = converter.toULong(undefinedValue);
+
+               if (count <= 0) {
+                       ThrowMsg(InvalidArgumentException, "Invalid argument");
+               }
+
                DPL::ScopedArray<unsigned char> data(privateObject->getObject()->getBytes(count));
                std::string base64 = WrtDeviceApis::Commons::Base64::encode(data.Get(), privateObject->getObject()->getCount());
                return converter.toJSValueRef(base64);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -307,18 +331,21 @@ JSValueRef JSFilestream::write(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        try {
-               privateObject->getObject()->write(converter.toString(argv[0]));
+               JSValueRef undefinedValue = JSValueMakeUndefined(context);
+
+               if (argc > 0) 
+                       privateObject->getObject()->write(converter.toString(argv[0]));
+               else 
+                       privateObject->getObject()->write(converter.toString(undefinedValue));
+
+
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -339,15 +366,15 @@ JSValueRef JSFilestream::writeBytes(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
-       }
 
        Converter converter(context);
        Try {
+               if (argc < 1 || !JSIsArrayValue(context, argv[0]))
+                       ThrowMsg(ConversionException,  "Type mismatch error");
+
                PrivateObject::ObjectType stream = privateObject->getObject();
                std::vector<unsigned char> data = converter.toVectorOfUChars(argv[0]);
                std::vector<unsigned char>::const_iterator it = data.begin();
@@ -355,7 +382,7 @@ JSValueRef JSFilestream::writeBytes(JSContextRef context,
                        stream->write(*it);
                }
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
@@ -376,19 +403,23 @@ JSValueRef JSFilestream::writeBase64(JSContextRef context,
 {
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
-       }
-
-       if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch error");
        }
 
        Converter converter(context);
        try {
-               std::string base64 = WrtDeviceApis::Commons::Base64::decode(converter.toString(argv[0]));
+               LogDebug("OK");
+               
+               JSValueRef undefinedValue = JSValueMakeUndefined(context);
+               std::string base64;
+               if (argc > 0) 
+                       base64 = WrtDeviceApis::Commons::Base64::decode(converter.toString(argv[0]));
+               else 
+                       base64 = WrtDeviceApis::Commons::Base64::decode(converter.toString(undefinedValue));
+
                privateObject->getObject()->write(base64);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
index 76231f7..7cb53ee 100755 (executable)
@@ -33,7 +33,7 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h> 
 #include <Tizen/Common/SecurityExceptions.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <WidgetDB/WidgetDBMgr.h>
 #include <WidgetDB/IWidgetDB.h>
 
@@ -71,10 +71,9 @@ JSValueRef getFunction(JSContextRef ctx, JSValueRef arg)
 {
        if (Validator(ctx).isCallback(arg)) {
                return arg;
-       } else if (JSValueIsNull(ctx, arg) || JSValueIsUndefined(ctx, arg)) {
-               ThrowMsg(InvalidArgumentException, "JS null passed as function.");
+       }else{
+               ThrowMsg(ConversionException, "JS null passed as function.");
        }
-       ThrowMsg(ConversionException, "Not a function nor JS null.");
 }
 
 }
@@ -141,10 +140,8 @@ void JSFilesystemManager::initialize(JSContextRef context,
                delete privateObject;
        }
        else {
-               IWrtWrapperPtr wrt = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-               WidgetDB::Api::IWidgetDBPtr widgetDB = WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
-
-               Assert(wrt && "WrtWrapper not found, not a GLOBAL context supplied?");
+        int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+               WidgetDB::Api::IWidgetDBPtr widgetDB = WidgetDB::Api::getWidgetDB(widgetId);
 
                LogDebug(widgetDB->getWidgetInstallationPath());
                std::string wgtpackage = "wgt-package";
@@ -199,43 +196,39 @@ JSValueRef JSFilesystemManager::getStorage(JSContextRef context,
 
        JSContextRef globalContext = privateObject->getContext();
        ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
 
        try {
 
                JSValueRef onSuccess = getFunction(globalContext, argv[1]);
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
                        
-               if (argc > 2) {
+               if (argc>2) {
                        onError = getFunctionOrNull(globalContext, argv[2]);
                }
 
                cbm->setOnSuccess(onSuccess);
                cbm->setOnError(onError);
-               
-               if (JSValueIsNull(context, argv[0]) || JSValueIsUndefined(context, argv[0]) || !JSValueIsString(context, argv[0])) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-               }
 
                Api::Filesystem::EventGetStoragePtr event(new Api::Filesystem::EventGetStorage());
                event->setLabel(converter->toString(argv[0]));
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
-
+               JSValueProtect(globalContext, thisObject);
 
                Api::Filesystem::IManager::getInstance().getStorage(event);
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFilesystemManager::getStorageList(JSContextRef context,
@@ -257,12 +250,12 @@ JSValueRef JSFilesystemManager::getStorageList(JSContextRef context,
 
        JSContextRef globalContext = privateObject->getContext();
        ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
        
        try {
 
                JSValueRef onSuccess = getFunction(globalContext, argv[0]);
                JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
                        
                if (argc > 1) {
                        onError = getFunctionOrNull(globalContext, argv[1]);
@@ -275,19 +268,22 @@ JSValueRef JSFilesystemManager::getStorageList(JSContextRef context,
                Api::Filesystem::EventListStoragesPtr event(new Api::Filesystem::EventListStorages());
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (cbm));
+               JSValueProtect(globalContext, thisObject);
+
+
                Api::Filesystem::IManager::getInstance().listStorages(event);
 
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context, 
@@ -303,7 +299,7 @@ JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context,
        }
 
        if (argc < 1) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "TYPE_MISMATCH_ERROR");
        }
 
        JSContextRef globalContext = privateObject->getContext();
@@ -311,13 +307,14 @@ JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context,
        ConverterPtr converter = ConverterFactory::getConverter(globalContext);
 
        try {
-               if (JSValueIsNull(context, argv[0]) || JSValueIsUndefined(context, argv[0])) {
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
-                       return JSValueMakeNull(context);
-               } else if (!JSObjectIsFunction(context, converter->toJSObjectRef(argv[0]))) {
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+               JSValueRef onSuccess = getFunction(globalContext, argv[0]);
+               JSValueRef onError = NULL;
+               if (argc > 1) {
+                       onError = getFunctionOrNull(globalContext, argv[1]);
                }
-               cbm->setOnSuccess(argv[0]);
+
+               cbm->setOnSuccess(onSuccess);
+               cbm->setOnError(onError);
 
                Api::Filesystem::EventStorageStateChangedEmitterPtr emitter(new Api::Filesystem::EventStorageStateChangedEmitter);
                emitter->setListener(&StorageStaticController::getInstance());
@@ -325,13 +322,13 @@ JSValueRef JSFilesystemManager::addStorageStateListener(JSContextRef context,
                long id = Api::Filesystem::IManager::getInstance().addStorageStateChangeListener(emitter);
                return converter->toJSValueRefLong(id);
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
        return JSValueMakeUndefined(context);
@@ -353,23 +350,22 @@ JSValueRef JSFilesystemManager::removeStorageStateListener(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
        }
 
-       if (!JSValueIsNumber(context, argv[0])) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
-       }
-
        JSContextRef globalContext = privateObject->getContext();
        ConverterPtr converter = ConverterFactory::getConverter(globalContext);
        
        try {
                long id = static_cast<long>(converter->toLong(argv[0]));
+               LogDebug("id:" << id);
 
                if (id >= 0) {
                        Api::Filesystem::IManager::getInstance().removeStorageStateChangeListener(id);
                }
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+       } catch (const WrtDeviceApis::Commons::NotFoundException& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
@@ -386,6 +382,9 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                const JSValueRef argv[],
                JSValueRef* exception)
 {
+
+       LogDebug("<<<");
+
        PrivateObject* privateObject = static_cast<PrivateObject*>(JSObjectGetPrivate(thisObject));
        if (!privateObject) {
                return JSValueMakeUndefined(context);
@@ -397,39 +396,52 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
 
        JSContextRef globalContext = privateObject->getContext();
        ConverterPtr converter = ConverterFactory::getConverter(globalContext);
+
+       size_t index = 0;
+       JSValueRef reserveArguments[4];
+       JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);      
        
-       try {
 
-               JSValueRef onSuccess = getFunction(globalContext, argv[1]);
-               JSValueRef onError = NULL;
-               JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext);
-                       
-               if (argc > 2) {
-                       onError = getFunctionOrNull(globalContext, argv[2]);
+       try {
+               for (index = 0; index < 4; index++) {
+                       if (index < argc)
+                               reserveArguments[index] = argv[index];
+                       else 
+                               reserveArguments[index] = JSValueMakeUndefined(context);
                }
+               JSValueRef onSuccess = getFunction(globalContext, reserveArguments[1]);
+               JSValueRef onError = NULL;
+
+               onError = getFunctionOrNull(globalContext, reserveArguments[2]);
 
                cbm->setOnSuccess(onSuccess);
                cbm->setOnError(onError);
-               
-               Api::Filesystem::IPathPtr path = Utils::fromVirtualPath(globalContext, converter->toString(argv[0]));
-               std::string virtualPath = converter->toString(argv[0]);
 
+               Api::Filesystem::IPathPtr path;
+               std::string virtualPath;
+               path = Utils::fromVirtualPath(globalContext, converter->toString(reserveArguments[0]));
+               virtualPath = converter->toString(reserveArguments[0]);
+               LogDebug("virtualPath:[" << virtualPath << "]");
                int permissions = Api::Filesystem::PERM_READ | Api::Filesystem::PERM_WRITE;
 
+
+               
                if (argc > 3) {
-                       if (!JSValueIsNull(context, argv[3]) && !JSValueIsUndefined(context, argv[3])) {
-                               std::string perms = converter->toString(argv[3]);
-                               if (("r" != perms) && ("rw" != perms) && ("w" != perms) && ("a" != perms)) {
-                                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
-                               } else if ("r" == perms) {
-                                       permissions = Api::Filesystem::PERM_READ;
-                               } 
+                       std::string perms = converter->toString(reserveArguments[3]);
+                       LogDebug("perms:[" << perms << "]");
+                       if (("r" != perms) && ("rw" != perms) && ("w" != perms) && ("a" != perms)) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid permission");
+                       } else if ("r" == perms) {
+                               permissions = Api::Filesystem::PERM_READ;
                        }
                }
 
+               if (permissions & Api::Filesystem::PERM_WRITE && virtualPath == "wgt-package") {
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::PERMISSION_DENIED_ERROR, "permission denied");
+               }
+
                PermissionsAccessInfo perms(permissions, virtualPath);
                AceSecurityStatus status = FILESYSTEM_PERMISSION_CHECK_ACCESS(
-                               privateObject->getContext(),
                                FILESYSTEM_FUNCTION_API_MGR_RESOLVE_ID,
                                perms);
 
@@ -439,21 +451,23 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                Api::Filesystem::EventResolvePtr event(new Api::Filesystem::EventResolve(path));
                event->setForAsynchronousCall(&ResponseDispatcher::getInstance()); 
                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData > (data));
+               JSValueProtect(globalContext, thisObject);
+
                Api::Filesystem::IManager::getInstance().getNode(event);
                
        } catch(const WrtDeviceApis::Commons::ConversionException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::IO_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::NotFoundException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_FOUND_ERROR, ex.GetMessage()));
        } catch (const WrtDeviceApis::Commons::UnsupportedException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, ex.GetMessage());
        } catch(const WrtDeviceApis::Commons::InvalidArgumentException& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, ex.GetMessage()));
        } catch(const WrtDeviceApis::Commons::Exception& ex) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, ex.GetMessage()));
        }
 
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 }
 }
index 0719a5c..27e619e 100755 (executable)
@@ -57,33 +57,52 @@ ResponseDispatcher::ResponseDispatcher() :
 
 void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventResolvePtr& event)
 {
-       EventGetNodeDataPtr data = DPL::DynamicPointerCast<EventGetNodeData>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("ENTER");
+    EventGetNodeDataPtr data =
+        DPL::DynamicPointerCast<EventGetNodeData>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               event->getResult()->setPermissions(data->getPerms());
-               JSObjectRef object = JSUtils::makeObject(data->getCallbackManager()->getContext(), JSFile::getClassRef(), event->getResult());
-               data->getCallbackManager()->callOnSuccess(object);
-       } else {
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        event->getResult()->setPermissions(data->getPerms());
+        JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef(
+            event->getResult(),
+            JSFile::PrivateObjectDef::PermissionList()));
+
+        JSObjectRef object = JSUtils::makeObject(
+                data->getCallbackManager()->getContext(),
+                JSFile::getClassRef(),
+                privData);
+        data->getCallbackManager()->callOnSuccess(object);
+    }  else {
                JSObjectRef jsException =       JSTizenExceptionFactory::makeErrorObject(data->getCallbackManager()->getContext(), JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
                data->getCallbackManager()->callOnError(jsException);
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventGetStoragePtr& event)
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListNodesPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("ENTER");
+    JSFile::ListFilesPrivateDataPtr privData =
+        DPL::DynamicPointerCast<JSFile::ListFilesPrivateData>(event->getPrivateData());
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Converter converter(data->getContext());
-               Try {
-                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
-                       data->callOnSuccess(result);
-               } Catch (WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
-       } else {
+    JSCallbackManagerPtr data = privData->getCallbackManager();
+    Assert(NULL != data);
+
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        Converter converter(data->getContext());
+        Try {
+            JSValueRef result = converter.toJSValueRef(
+                event->getResult(),
+                privData->getParentPermissions(),
+                data->getContext());
+            data->callOnSuccess(result);
+        }
+        Catch(WrtDeviceApis::Commons::ConversionException) {
+            data->callOnError(JSTizenExceptionFactory::makeErrorObject(
+                               data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+        }
+    } else {
                JSObjectRef jsException = NULL;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
@@ -94,44 +113,43 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventGetStorage
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListStoragesPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventOpenPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("ENTER");
+    DPL::SharedPtr<JSCallbackManager> data =
+        DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Converter converter(data->getContext());
-               Try {
-                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
-                       data->callOnSuccess(result);
-               } Catch (WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
-       } else {
-               JSObjectRef jsException = NULL;
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
-               } else {
-                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
-               }
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        JSObjectRef object = JSUtils::makeObject(
+                data->getContext(),
+                JSFilestream::
+                    getClassRef(),
+                event->getResult());
+        data->callOnSuccess(object);
+    } else {
+               JSObjectRef jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
                data->callOnError(jsException);
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListNodesPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventCopyPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("ENTER");
+    DPL::SharedPtr<JSCallbackManager> data =
+        DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Converter converter(data->getContext());
-               Try {
-                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
-                       data->callOnSuccess(result);
-               } Catch (WrtDeviceApis::Commons::ConversionException) {
-                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
-               }
-       } else {
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef(
+                event->getResult(),
+                JSFile::PrivateObjectDef::PermissionList()));
+
+        JSObjectRef object = JSUtils::makeObject(data->getContext(),
+                                                 JSFile::getClassRef(),
+                                                 privData);
+        data->callOnSuccess(object);
+    } else {
                JSObjectRef jsException = NULL;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
@@ -142,31 +160,44 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListNodesP
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventOpenPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventMovePtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("ENTER");
+    DPL::SharedPtr<JSCallbackManager> data =
+        DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFilestream::getClassRef(), event->getResult());
-               data->callOnSuccess(object);
-       } else {
-               JSObjectRef jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        JSFile::PrivateObjectDefPtr privData(new JSFile::PrivateObjectDef(
+                event->getResult(),
+                JSFile::PrivateObjectDef::PermissionList()));
+        JSObjectRef object = JSUtils::makeObject(data->getContext(),
+                                                 JSFile::getClassRef(),
+                                                 privData);
+        data->callOnSuccess(object);
+    } else {
+               JSObjectRef jsException = NULL;
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
+               } else {
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
+               }
                data->callOnError(jsException);
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventCopyPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventRemovePtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("--| ENTER");
+    DPL::SharedPtr<JSCallbackManager> data =
+        DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFile::getClassRef(), event->getResult());
-               data->callOnSuccess(object);
-       } else {
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        data->callOnSuccess();
+    } else {
                JSObjectRef jsException = NULL;
-               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+               if (event->getExceptionCode() ==WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                } else {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
@@ -175,15 +206,24 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventCopyPtr& e
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventMovePtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventReadTextPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       Assert(NULL != data);
+    LogDebug("--| ENTER");
+    DPL::SharedPtr<JSCallbackManager> data =
+        DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+    Assert(NULL != data);
 
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               JSObjectRef object = JSUtils::makeObject(data->getContext(), JSFile::getClassRef(), event->getResult());
-               data->callOnSuccess(object);
-       } else {
+    if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+        Converter converter(data->getContext());
+        Try {
+            JSValueRef result = converter.toJSValueRef(event->getResult());
+            data->callOnSuccess(result);
+        }
+        Catch(WrtDeviceApis::Commons::ConversionException) {
+            data->callOnError(JSTizenExceptionFactory::makeErrorObject(
+                               data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+        }
+    }  else {
                JSObjectRef jsException = NULL;
                if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
@@ -194,16 +234,22 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventMovePtr& e
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventRemovePtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventGetStoragePtr& event)
 {
        DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
        Assert(NULL != data);
 
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               data->callOnSuccess();
+               Converter converter(data->getContext());
+               Try {
+                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
+                       data->callOnSuccess(result);
+               } Catch (WrtDeviceApis::Commons::ConversionException) {
+                       data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
+               }
        } else {
                JSObjectRef jsException = NULL;
-               if (event->getExceptionCode() ==WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::SecurityException) {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::PERMISSION_DENIED_ERROR, "Permission denied error");
                } else {
                        jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error");
@@ -212,7 +258,7 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventRemovePtr&
        }
 }
 
-void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventReadTextPtr& event)
+void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventListStoragesPtr& event)
 {
        DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
        Assert(NULL != data);
@@ -220,7 +266,7 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventReadTextPt
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
                Converter converter(data->getContext());
                Try {
-                       JSValueRef result = converter.toJSValueRef(event->getResult());
+                       JSValueRef result = converter.toJSValueRef(event->getResult(), data->getContext());
                        data->callOnSuccess(result);
                } Catch (WrtDeviceApis::Commons::ConversionException) {
                        data->callOnError(JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::IO_ERROR, "IO error"));
@@ -235,5 +281,6 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Filesystem::EventReadTextPt
                data->callOnError(jsException);
        }
 }
+
 }
 }
index dc3d817..e8f5bc3 100755 (executable)
@@ -120,25 +120,22 @@ class DefaultArgsVerifier <TizenApis::Tizen1_0::AccessModeInfo>
     }
 };
 
-#define FILESYSTEM_CHECK_ACCESS(globalContext, functionName) \
+#define FILESYSTEM_CHECK_ACCESS(functionName) \
     WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter, \
     WrtDeviceApis::Commons::DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getFilesystemFunctionData,         \
         functionName)
 
-#define FILESYSTEM_PERMISSION_CHECK_ACCESS(globalContext, functionName, perm)  \
+#define FILESYSTEM_PERMISSION_CHECK_ACCESS(functionName, perm)  \
     WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter,                  \
     WrtDeviceApis::Commons::DefaultArgsVerifier <TizenApis::Tizen1_0::PermissionsAccessInfo> >(             \
-        globalContext,                     \
         getFilesystemFunctionData,         \
         functionName,                      \
         perm)
 
-#define FILESYSTEM_ACCESSMODE_CHECK_ACCESS(globalContext, functionName, amode) \
+#define FILESYSTEM_ACCESSMODE_CHECK_ACCESS(functionName, amode) \
     WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter,                  \
     WrtDeviceApis::Commons::DefaultArgsVerifier <TizenApis::Tizen1_0::AccessModeInfo> >(                    \
-        globalContext,                     \
         getFilesystemFunctionData,         \
         functionName,                      \
         amode)
index cac5f03..cb86637 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
 #include <dpl/log/log.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSFilesystemManager.h"
 #include "JSFile.h"
 #include "JSFilestream.h"
 
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 
-void on_widget_start_callback(int widgetId,
-        JavaScriptContext context,
-        const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId)
 {
        Try {
-               WrtWrappersMgr::getInstance().registerWrapper(widgetId, context, interface);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Wrt wrapper registration failed");
+        WrtAccessSingleton::Instance().initialize(widgetId);
+       } Catch (Commons::Exception) {
+               LogError("WrtAccess initialization failed");
        }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
        Try {
-               WrtWrappersMgr::getInstance().removeWrapper(widgetId);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Wrt wrapper removal failed");
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+       } Catch (Commons::Exception) {
+               LogError("WrtAccess deinitialization failed");
        }
 }
 
old mode 100755 (executable)
new mode 100644 (file)
index 526f453..5b46612
@@ -1,23 +1,48 @@
 set(TARGET_NAME "wrt-plugins-tizen-1.0-geocoder")
+set(DESTINATION_NAME "tizen-1.0-geocoder")
+set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-geocoder-impl")
+
+pkg_search_module(geocoder REQUIRED capi-location-manager capi-location-geocoder)
+
+include_directories( ${geocoder_INCLUDE_DIRS}
+       /usr/include/location/
+       ../LBS
+       ../Tizen )
+
+set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}
+  ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-lbs )
+
+set(SRCS_IMPL
+  JSGeocoderProvider.cpp
+  JSGeocoderServiceManager.cpp
+  JSGeocodeResult.cpp
+  GeocoderProvider.cpp
+  GeocodeOptions.cpp
+  ReverseGeocodeOptions.cpp
+  GeocoderACE.cpp
+  DefaultGeocoderProvider.cpp
+)
+
+add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+target_link_libraries(${TARGET_IMPL_NAME}
+  capi-location-geocoder
+  wrt-plugins-tizen-1.0-tizen-impl
+  wrt-plugins-tizen-1.0-lbs-impl  
+  ${LIBS_COMMON}
+  ${geocoder_LIBRARIES}  
+)
 
-include_directories(${INCLUDES_PLATFORM_IMPLEMENTATION_GEOCODER})
 
 set(SRCS
-  ${SRCS_PLATFORM_API_GEOCODER}
-  ${SRCS_PLATFORM_IMPLEMENTATION_GEOCODER}
-  JSGeocoder.cpp
-  JSAddress.cpp
-  JSCoordinates.cpp
-  GeocoderController.cpp
   plugin_initializer.cpp
-  plugin_config.cpp
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
 target_link_libraries(${TARGET_NAME}
-  ${LIBS_COMMON}
-  ${LIBS_PLATFORM_IMPLEMENTATION_GEOCODER}
+  ${TARGET_IMPL_NAME}
 )
 
-INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION tizen-1.0-geocoder)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION tizen-1.0-geocoder)
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
diff --git a/src/standards/Tizen/Geocoder/DefaultGeocoderProvider.cpp b/src/standards/Tizen/Geocoder/DefaultGeocoderProvider.cpp
new file mode 100755 (executable)
index 0000000..0f68383
--- /dev/null
@@ -0,0 +1,512 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <dlog.h>
+#include <location_preference.h>
+#include <glib.h>
+#include "GeoAddress.h"
+#include "DefaultGeocoderProvider.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+typedef struct 
+{
+       int ret;
+       void *user_data;
+       setOptionCb callback;
+}callback_data;
+
+typedef struct 
+{
+       void *user_data;
+       GeocodeResultArrayCallback callback;
+       GeocodeOptions option;  
+       std::vector<double> list;
+}geocoder_geocode_cb_data;
+
+typedef struct 
+{
+       void *user_data;
+       ReverseGeocodeResultArrayCallback callback;
+       ReverseGeocodeOptions option;   
+       std::vector<std::string> strAddrList;   
+       std::vector<GeoAddress> geoAddrList;    
+}geocoder_reverse_geocode_cb_data;
+
+bool DefaultGeocoderProvider::preference_init_cb(const char *key, void *user_data)
+{
+       int ret;
+       DefaultGeocoderProvider *obj = (DefaultGeocoderProvider *)user_data;
+       string pref(key);
+       char* value_str = NULL;
+       ret = location_preference_get(obj->nativeHandle, key, &value_str);
+       if( ret == LOCATION_PREFERENCE_ERROR_NONE && value_str != NULL )
+       {
+               string value(value_str);
+               obj->metadata.push_back(make_pair(pref,value));
+       }
+       obj->supportedOptions.push_back(pref);
+       return TRUE;
+}
+
+int DefaultGeocoderProvider::setOption_cb(void* user_data)
+{
+       callback_data *data = (callback_data*)user_data;
+       if( data == NULL)
+               return false;
+
+       data->callback( data->ret , data->user_data);
+       
+       if( data != NULL)
+               delete data;
+       return false;
+}
+
+DefaultGeocoderProvider::DefaultGeocoderProvider():GeocoderProvider("default"), nativeHandle(NULL)
+{
+       int ret = geocoder_create(&nativeHandle);
+       if( ret != GEOCODER_ERROR_NONE )
+       {
+               LOGE("Error create Geocoder");
+               return;
+       }
+
+       char *provider_name = NULL;
+       ret = location_preference_get_provider_name (GET_LOCATION_SERVICE(nativeHandle) , &provider_name);
+       if( ret == LOCATION_PREFERENCE_ERROR_NONE && provider_name != NULL)
+       {
+               string providerName(provider_name);
+               setName(providerName);  
+               free(provider_name);
+       }
+
+       metadata.clear();
+       supportedOptions.clear();
+       location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(nativeHandle) , preference_init_cb,this);
+}
+
+DefaultGeocoderProvider::~DefaultGeocoderProvider()
+{
+       LOGD("%s - Destroy the DefaultGeocoderProvider",__func__);
+       if(!nativeHandle)
+               geocoder_destroy(nativeHandle);
+}
+
+
+vector<string> DefaultGeocoderProvider::getSupportedOptions()
+{
+       return supportedOptions;
+}
+
+
+vector<pair<string, string>> DefaultGeocoderProvider::getMetadata()
+{
+       return metadata;
+}
+
+int DefaultGeocoderProvider::setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)
+{
+       std::vector<std::pair<std::string, std::string>>::iterator pos;
+       for( pos = options.begin() ; pos != options.end() ; ++pos)
+       {
+               vector<string>::iterator check;
+               bool isvalid = false;
+               for ( check = supportedOptions.begin() ; check != supportedOptions.end() ; ++check )
+               {
+                       if( *check == pos->first )
+                               isvalid = true;
+               }
+               if( isvalid == false )
+                       return -1;
+       }
+
+       for( pos = options.begin() ; pos != options.end() ; ++pos)
+       {
+               std::vector<std::pair<std::string, std::string>>::iterator target;
+               int find = false;
+               for( target = metadata.begin() ; target != metadata.end() ; ++target)
+               {
+                       if ( target->first == pos->first )
+                       {
+                               find = true;
+                               target->second = pos->second;
+                       }
+               }
+               if( !find )
+               {
+                       metadata.push_back(*pos);
+               }
+       }
+
+       vector<pair<string, string>>::iterator key;
+       vector<pair<string, string>> newMetadata;
+       for( key = metadata.begin(); key != metadata.end() ; ++key)
+       {
+               if( 0 == location_preference_set(nativeHandle, key->first.c_str() , key->second.c_str()))
+                       newMetadata.push_back(*key);
+       }
+       metadata = newMetadata;
+
+       callback_data *data = new callback_data();
+       data->user_data = user_data;
+       data->callback = callback;
+       data->ret = 0;
+    g_idle_add_full(G_PRIORITY_HIGH_IDLE, setOption_cb, data, NULL);
+       return 0;
+}
+
+
+string DefaultGeocoderProvider::getConnectivity()
+{
+       return string("ONLINE");
+}
+
+bool DefaultGeocoderProvider::isUsedExternalNetwork()
+{
+       return true;
+}
+
+bool DefaultGeocoderProvider::get_position_cb(geocoder_error_e result, double latitude, double longitude, void *user_data)
+{
+       LOGE("%s - start", __func__);
+       geocoder_geocode_cb_data *calldata = (geocoder_geocode_cb_data*)user_data;
+       if( calldata == NULL )
+               return FALSE;
+
+       if( result != GEOCODER_ERROR_NONE )
+       {
+               int ret;
+               switch(result)
+               {
+               case GEOCODER_ERROR_NETWORK_FAILED:
+                       ret = GEOCODER_ERROR::NETWORK_FAILED;
+                       break;
+               case GEOCODER_ERROR_TIMED_OUT:
+                       ret = GEOCODER_ERROR::TIMEOUT;
+                       break;
+               case GEOCODER_ERROR_NOT_FOUND:
+                       ret =GEOCODER_ERROR::NONE;
+                       break;
+               case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE:
+               default:
+                       ret = GEOCODER_ERROR::SERVICE_NOT_AVAILABLE;
+                       break;
+               }
+               calldata->callback( ret, calldata->list,  calldata->user_data );
+               delete calldata;
+               return FALSE;
+       }
+
+       //TODO: option check
+       //calldata->option.maxResult 
+       LOGE("%s - latitude : %lf, longitude : %lf",__func__, latitude, longitude);
+
+       calldata->list.push_back(latitude);
+       calldata->list.push_back(longitude);
+
+       //TODO: Only for last result
+       if(1)
+       {
+               calldata->callback(0 , calldata->list,  calldata->user_data);
+               delete calldata;
+       }
+
+       LOGE("%s - end", __func__);
+       //TODO: Need to consider multiple result
+       return FALSE;
+}
+
+void   DefaultGeocoderProvider::get_address_cb(geocoder_error_e result, const char *building_number, const char *postal_code, const char *street, const char *city, const char *district, const char *state, const char *country_code, void *user_data)
+{
+       LOGE("%s - start", __func__);
+       geocoder_reverse_geocode_cb_data *calldata = (geocoder_reverse_geocode_cb_data*)user_data;
+       if( calldata == NULL )
+               return;
+
+       if( result != GEOCODER_ERROR_NONE )
+       {
+               int ret;
+               switch(result)
+               {
+               case GEOCODER_ERROR_NETWORK_FAILED:
+                       ret = GEOCODER_ERROR::NETWORK_FAILED;
+                       break;
+               case GEOCODER_ERROR_TIMED_OUT:
+                       ret = GEOCODER_ERROR::TIMEOUT;
+                       break;
+               case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE:
+               default:
+                       ret = GEOCODER_ERROR::SERVICE_NOT_AVAILABLE;
+                       break;
+               }
+               calldata->callback( ret, calldata->strAddrList, calldata->geoAddrList,  calldata->user_data);
+               delete calldata;
+               return;
+       }
+
+       if (calldata->option.addressType == ReverseGeocodeOptions::AddressType::FORMATTED)
+       {
+               LOGE("%s - AddressType::FORMATTED");
+               std::string simpleAddr;
+               if(building_number)
+               {
+                       simpleAddr+=building_number;
+                       simpleAddr+=    " ";
+               }
+               if(postal_code)
+               {
+                       simpleAddr+=postal_code;
+                       simpleAddr+=    " ";
+               }
+               if(street)
+               {
+                       simpleAddr+=street;
+                       simpleAddr+=    " ";
+               }
+               if(city)
+               {
+                       simpleAddr+=city;
+                       simpleAddr+=    " ";
+               }
+               if(district)
+               {
+                       simpleAddr+=district;
+                       simpleAddr+=    " ";
+               }
+               if(state)
+               {
+                       simpleAddr+=state;
+                       simpleAddr+=    " ";
+               }
+               if(country_code)
+                       simpleAddr+=country_code;
+
+               LOGE("%s - AddressType::FORMATTED - Address: %s", __func__,simpleAddr.c_str());
+               calldata->strAddrList.push_back(simpleAddr);
+       }
+       else // for ReverseGeocodeOptions::AddressType::STRUCTURED
+       {
+               LOGE("%s - AddressType::STRUCTURED");
+               GeoAddress structedAddress;
+               if(country_code)
+                       structedAddress.country = string(country_code);
+               if(state)
+                       structedAddress.region = string(state);
+               if(district)
+                       structedAddress.county = string(district);
+               if(city)
+                       structedAddress.city = string(city);
+               if(street)
+                       structedAddress.street = string(street);
+               if(building_number)
+                       structedAddress.premises = string(building_number);
+               if(postal_code)
+                       structedAddress.postalCode = string(postal_code);
+
+               LOGE("%s - AddressType::STRUCTURED - contry_code:%s, state:%s, district:%s, city:%s, district:%s, street:%s , premises:%s , postalCode:%s ", __func__,country_code, state, district, city, street, building_number, postal_code);
+               calldata->geoAddrList.push_back(structedAddress);
+       }
+       calldata->callback(0 , calldata->strAddrList, calldata->geoAddrList,  calldata->user_data);
+       LOGE("%s - end", __func__);
+       delete calldata;
+}
+
+int DefaultGeocoderProvider::geocode(GeoAddress address, GeocodeOptions& option, GeocodeResultArrayCallback callback, void *user_data)
+{
+       LOGE("%s - geocode with GeoAddress", __func__);
+
+       geocoder_geocode_cb_data * calldata = NULL;     
+       int retval = GEOCODER_ERROR::NONE;
+       int ret = GEOCODER_ERROR_NONE;
+
+       //TODO: Geocoder Preference 
+       //if( option.maxResult != 0 )
+       //      geocoder_preference_set_max_result(preference, option.maxResult);
+       //if( option.sortAttributeName != "" )
+       //{
+       //      geocoder_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? GEOCODER_SORTORDER_ASC : GEOCODER_SORTORDER_DESC);
+       //}
+
+       calldata = new geocoder_geocode_cb_data();
+       if (calldata ==NULL)
+       {
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+
+       ret = geocoder_foreach_positions_from_address(nativeHandle, address.toSimpleAddress().c_str(), get_position_cb, calldata);
+
+       switch(ret)
+       {
+       case GEOCODER_ERROR_NONE:
+               calldata = NULL;
+               break;
+       case GEOCODER_ERROR_OUT_OF_MEMORY:
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               break;
+       case GEOCODER_ERROR_INVALID_PARAMETER:
+               retval = GEOCODER_ERROR::INVALID_PARAMETER;
+               break;
+       case GEOCODER_ERROR_NETWORK_FAILED :
+               retval = GEOCODER_ERROR::NETWORK_FAILED;
+               break;
+       case GEOCODER_ERROR_TIMED_OUT:
+               retval = GEOCODER_ERROR::TIMEOUT;
+               break;
+       case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE :
+       default:
+               retval = GEOCODER_ERROR::SERVICE_NOT_AVAILABLE;
+               break;
+       }
+       
+destroy:               
+       if( calldata)
+               delete calldata;        
+       return retval;          
+}
+
+int DefaultGeocoderProvider::geocode(std::string& address, GeocodeOptions & option, GeocodeResultArrayCallback callback, void *user_data)
+{
+       LOGE("%s - geocode with Freeformed address", __func__);
+
+       geocoder_geocode_cb_data * calldata = NULL;     
+       int retval = GEOCODER_ERROR::NONE;
+       int ret = GEOCODER_ERROR_NONE;
+
+       //TODO: Geocoder Preference 
+       //if( option.maxResult != 0 )
+       //      geocoder_preference_set_max_result(preference, option.maxResult);
+       //if( option.sortAttributeName != "" )
+       //{
+       //      geocoder_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? GEOCODER_SORTORDER_ASC : GEOCODER_SORTORDER_DESC);
+       //}
+
+       calldata = new geocoder_geocode_cb_data();
+       if (calldata ==NULL)
+       {
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+
+       ret = geocoder_foreach_positions_from_address(nativeHandle, address.c_str(), get_position_cb, calldata);
+
+       switch(ret)
+       {
+       case GEOCODER_ERROR_NONE:
+               calldata = NULL;
+               break;
+       case GEOCODER_ERROR_OUT_OF_MEMORY:
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               break;
+       case GEOCODER_ERROR_INVALID_PARAMETER:
+               retval = GEOCODER_ERROR::INVALID_PARAMETER;
+               break;
+       case GEOCODER_ERROR_NETWORK_FAILED :
+               retval = GEOCODER_ERROR::NETWORK_FAILED;
+               break;
+       case GEOCODER_ERROR_TIMED_OUT:
+               retval = GEOCODER_ERROR::TIMEOUT;
+               break;
+       case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE :
+       default:
+               retval = GEOCODER_ERROR::SERVICE_NOT_AVAILABLE;
+               break;
+       }
+       
+destroy:               
+       if( calldata)
+               delete calldata;        
+       return retval;          
+}
+
+
+int DefaultGeocoderProvider::reverseGeocode(double latitude, double longitude, ReverseGeocodeOptions& option, ReverseGeocodeResultArrayCallback callback, void *user_data)
+{
+       LOGE("%s - reverseGeocode", __func__);
+
+       geocoder_reverse_geocode_cb_data * calldata = NULL;     
+       int retval = 0;
+       int ret = GEOCODER_ERROR_NONE;
+
+       //TODO: Geocoder Preference 
+       //if( option.maxResult != 0 )
+       //      geocoder_preference_set_max_result(preference, option.maxResult);
+       //if( option.sortAttributeName != "" )
+       //{
+       //      geocoder_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? GEOCODER_SORTORDER_ASC : GEOCODER_SORTORDER_DESC);
+       //}
+       
+       calldata = new geocoder_reverse_geocode_cb_data();
+       if( calldata == NULL)
+       {
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+
+       ret = geocoder_get_address_from_position(nativeHandle, latitude, longitude, get_address_cb, calldata);
+
+       switch(ret)
+       {
+       case GEOCODER_ERROR_NONE:
+               calldata = NULL;
+               break;
+       case GEOCODER_ERROR_OUT_OF_MEMORY:
+               retval = GEOCODER_ERROR::OUT_OF_MEMORY;
+               break;
+       case GEOCODER_ERROR_INVALID_PARAMETER:
+               retval = GEOCODER_ERROR::INVALID_PARAMETER;
+               break;
+       case GEOCODER_ERROR_NETWORK_FAILED :
+               retval = GEOCODER_ERROR::NETWORK_FAILED;
+               break;
+       case GEOCODER_ERROR_TIMED_OUT:
+               retval = GEOCODER_ERROR::TIMEOUT;
+               break;
+       case GEOCODER_ERROR_SERVICE_NOT_AVAILABLE :
+       default:
+               retval = GEOCODER_ERROR::SERVICE_NOT_AVAILABLE;
+               break;
+       }
+       
+destroy:               
+       if( calldata)
+               delete calldata;        
+       return retval;          
+}
+       
+} //LBS
+} //Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/Geocoder/DefaultGeocoderProvider.h b/src/standards/Tizen/Geocoder/DefaultGeocoderProvider.h
new file mode 100755 (executable)
index 0000000..561d76f
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef __WRTPLUGINS_TIZEN_DEFAULT_GEOCODER_PROVIDER__
+#define __WRTPLUGINS_TIZEN_DEFAULT_GEOCODER_PROVIDER__
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <geocoder.h>
+#include "GeocoderProvider.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class DefaultGeocoderProvider :public GeocoderProvider
+{      
+private:
+       geocoder_h nativeHandle;
+       std::vector<std::pair<std::string, std::string>> metadata;
+       std::vector<std::string> supportedOptions;
+
+private:
+       static bool preference_init_cb(const char *property, void *user_data);
+       static int setOption_cb(void* user_data);
+       static bool get_position_cb(geocoder_error_e result, double latitude, double longitude, void *user_data);
+       static void get_address_cb(geocoder_error_e result, const char *building_number, const char *postal_code, const char *street, const char *city, const char *district, const char *state, const char *country_code, void *user_data);
+
+public:
+       DefaultGeocoderProvider();      
+       virtual ~DefaultGeocoderProvider();
+       virtual std::vector<std::pair<std::string, std::string>> getMetadata();
+       virtual std::vector<std::string> getSupportedOptions();
+       virtual std::string getConnectivity();
+       virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending);
+       virtual bool isUsedExternalNetwork();
+
+       virtual int geocode(GeoAddress address  , GeocodeOptions& option ,  GeocodeResultArrayCallback callback, void *user_data);
+       virtual int geocode(std::string& address   , GeocodeOptions& option ,  GeocodeResultArrayCallback callback, void *user_data);
+       virtual int reverseGeocode(double latitude, double longitude , ReverseGeocodeOptions& option , ReverseGeocodeResultArrayCallback callback, void *user_data);
+};
+
+}
+}
+}
+
+#endif //__WRTPLUGINS_TIZEN_DEFAULT_GEOCODER_PROVIDER__
+
+
diff --git a/src/standards/Tizen/Geocoder/GeocodeOptions.cpp b/src/standards/Tizen/Geocoder/GeocodeOptions.cpp
new file mode 100755 (executable)
index 0000000..2eb2604
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <limits>
+#include <dlog.h>
+#include "GeocodeOptions.h"
+#include "LBSUtil.h"
+#include "JSSortMode.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+GeocodeOptions::GeocodeOptions()
+{
+       sortOrder = SortOrder::ASC;
+       maxResult = 0;
+}
+
+bool GeocodeOptions::convert(JSContextRef ctx, JSObjectRef object, GeocodeOptions* options, JSValueRef* exception)
+{
+       LOGD("%s - start",__func__);
+       if(options == NULL)
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "GeocodeOptions is NULL");
+               return false;
+       }
+
+       //convert "sortMode"
+       JSValueRef sortModeValue = LBSUtil::getPropertyToValueRef(ctx, object, "sortMode");
+       if( JSValueIsObjectOfClass(ctx, sortModeValue, TizenApis::Tizen1_0::Tizen::JSSortMode::getClassRef()))
+       {
+               JSObjectRef sortModeObject = JSValueToObject(ctx, sortModeValue , NULL);
+               options->sortAttributeName = LBSUtil::getPropertyToString(ctx, sortModeObject, "attributeName");
+               std::string order = LBSUtil::getPropertyToString(ctx, sortModeObject, "order");
+               if( order == "ASC" )
+                       options->sortOrder = SortOrder::ASC;
+               else if( order == "DESC" )
+                       options->sortOrder = SortOrder::DESC;
+       }
+       else if( !JSValueIsNull(ctx, sortModeValue) && !JSValueIsUndefined(ctx, sortModeValue))
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "sortMode is not SortMode object");
+               return false;
+       }
+       //convert "maxResults"
+       JSValueRef maxResultsValue = LBSUtil::getPropertyToValueRef(ctx, object, "maxResults");
+       double maxresult = JSValueToNumber(ctx, maxResultsValue , NULL);
+       if( maxresult != std::numeric_limits<double>::quiet_NaN())
+               options->maxResult = maxresult;
+       else
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "maxResults is not number");
+               return false;
+       }
+       return true;
+}
+
+}//LSB
+}// Tizen1_0
+}// TizenApis
+
similarity index 57%
rename from src/platform/API/Call/EventGetCallService.cpp
rename to src/standards/Tizen/Geocoder/GeocodeOptions.h
index e589f77..c06056b 100755 (executable)
  */
 
  
-#include "EventGetCallService.h"
+#ifndef __WRTPLUGINS_TIZEN_GEOCODE_OPTIONS__
+#define __WRTPLUGINS_TIZEN_GEOCODE_OPTIONS__
 
-namespace TizenApis {
-namespace Api {
-namespace Call {
-EventGetCallService::EventGetCallService()
-{
-}
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
 
-void EventGetCallService::setFilter(const CallServiceFilterPtr &filter)
-{
-       m_filter = filter;
-}
-
-void EventGetCallService::setResult(const Api::Account::AccountServicesArrayPtr &result)
-{
-       m_result = result;
-}
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
 
 
-CallServiceFilterPtr EventGetCallService::getFilter() const
+class GeocodeOptions
 {
-       return m_filter;
-}
+public:
+       enum SortOrder { ASC , DESC };
+       std::string sortAttributeName;
+       SortOrder sortOrder;
+       unsigned int maxResult;
 
-Api::Account::AccountServicesArrayPtr EventGetCallService::getResult() const
-{
-       return m_result;
-}
+       GeocodeOptions();
+       static bool convert(JSContextRef ctx, JSObjectRef object, GeocodeOptions *options, JSValueRef* exception);
+};
 
 }
 }
 }
+
+#endif //__WRTPLUGINS_TIZEN_GEOCODE_OPTIONS__
diff --git a/src/standards/Tizen/Geocoder/GeocoderACE.cpp b/src/standards/Tizen/Geocoder/GeocoderACE.cpp
new file mode 100755 (executable)
index 0000000..75d903b
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <iostream>
+#include <vector>
+#include "GeocoderACE.h"
+
+#define FEATURE_GEOCODER "http://tizen.org/api/geocoder"
+#define DEVICE_CAPABILITY_EXT_NET "externalNetworkAccess"
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+static AceFunction __geocoder_function();
+static AceFunction geocoder_function = __geocoder_function();  
+
+static AceFunction __geocoder_function()
+{
+       AceFeature geocoder_feature(FEATURE_GEOCODER);
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(geocoder_feature);
+
+       AceDeviceCapability ext_network_cap(DEVICE_CAPABILITY_EXT_NET, WrtDeviceApis::Commons::AceDeviceCapParams());
+       AceDeviceCaps required_device_caps;
+       required_device_caps.push_back(ext_network_cap);
+       
+       return {GEOCODER_FUNCTION_CATEGORY_BASIC , executable_feature_list, required_device_caps };
+}
+
+AceFunction getGeocoderFunction(const std::string & functionId)
+{
+               return geocoder_function; 
+}
+       
+} //LBS
+} // Tizen1_0
+} //TizenApis
+
+
similarity index 54%
rename from src/platform/API/Account/AccountFilter.h
rename to src/standards/Tizen/Geocoder/GeocoderACE.h
index a3dff2f..9340f82 100755 (executable)
  */
 
 
-#ifndef _ABSTRACT_LAYER_IACCOUNT_FILTER_H_
-#define _ABSTRACT_LAYER_IACCOUNT_FILTER_H_
+#ifndef _WRTPLUGINS_TIZEN_GEOCODER_ACE_
+#define _WRTPLUGINS_TIZEN_GEOCODER_ACE_
 
-#include <ctime>
 #include <string>
-#include <vector>
-#include <dpl/shared_ptr.h>
-#include <dpl/optional.h>
+#include <Commons/FunctionDeclaration.h>
 
 namespace TizenApis {
-namespace Api {
-namespace Account {
+namespace Tizen1_0 {
+namespace LBS {
 
-class AccountFilter
-{
-  public:
+#define GEOCODER_FUNCTION_CATEGORY_BASIC "GEOCODER_FUNCTION_BASIC"
 
-    AccountFilter();
-    virtual ~AccountFilter();
+WrtDeviceApis::Commons::AceFunction getGeocoderFunction(const std::string & functionId);
 
-    std::string getIdFilter() const;
-    void setIdFilter(const std::string &value);
+#define GEOCODER_CHECK_ACCESS(functionName)    \
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >( \
+        getGeocoderFunction,   \
+        functionName)
 
-    bool getIdIsSet() const;
+} // LBS
+} // Tizen1_0
+} // Tizen
 
-  protected:
-    DPL::Optional<std::string> m_id;
-};
-
-typedef DPL::SharedPtr<AccountFilter> AccountFilterPtr;
-
-}
-}
-}
-
-#endif /* _ABSTRACT_LAYER_IACCOUNT_FILTER_H_ */
+#endif // _WRTPLUGINS_TIZEN_GEOCODER_ACE_
 
diff --git a/src/standards/Tizen/Geocoder/GeocoderController.cpp b/src/standards/Tizen/Geocoder/GeocoderController.cpp
deleted file mode 100644 (file)
index f570a44..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @author      Sangtai Kim(sangtai.kim@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#include "GeocoderController.h"
-#include "JSAddress.h"
-#include "JSCoordinates.h"
-
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/Converter.h>
-
-using namespace std;
-//using namespace TizenApis::Tizen1_0::Platform;
-using namespace WrtDeviceApis::Commons;
-using namespace TizenApis::Tizen1_0::Api::Geocoder;
-
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-GeocoderController::GeocoderController(const JSCallbackManagerPtr &callbackManager) :
-       EventAnswerReceiver<EventGeocoder> (ThreadEnum::NULL_THREAD), m_callbackManager(callbackManager) {
-       LogDebug("<<<");
-}
-
-GeocoderController::~GeocoderController() {
-       LogDebug("<<<");
-       LogDebug(">>>");
-}
-
-void GeocoderController::OnAnswerReceived(const EventGeocoderPtr &event) {
-       LogDebug("<<<");
-
-       JSContextRef context = m_callbackManager->getContext();
-
-       if (event->getExceptionCode() == ExceptionCodes::None) {
-               LogDebug("result success");
-
-               GeocoderProperties geocoderProperties;
-               geocoderProperties.latitude         = event->getLatitude();
-               geocoderProperties.longitude        = event->getLongitude();
-
-               geocoderProperties.strCountry               = event->getCountry();
-               geocoderProperties.strRegion                = event->getRegion();
-               geocoderProperties.strCounty                = event->getCounty();
-               geocoderProperties.strCity                  = event->getCity();
-               geocoderProperties.strStreet                = event->getStreet();
-               geocoderProperties.strStreetNumber          = event->getStreetNumber();
-               geocoderProperties.strPremises              = event->getPremises();
-               geocoderProperties.strAdditionalInformation = event->getAdditionalInformation();
-               geocoderProperties.strPostalCode            = event->getPostalCode();
-
-               JSObjectRef jsObj = NULL;
-               vector<JSValueRef> propertiesVector;
-
-               if(event->getEventType() == EventGeocoder::GEOCODER_EVENT_GET_POSITION){
-                       jsObj   = JSCoordinates::createJSObject(m_callbackManager->getContext(), geocoderProperties);
-               }else if(event->getEventType() == EventGeocoder::GEOCODER_EVENT_GET_ADDRESS){
-                       jsObj   = JSAddress::createJSObject(m_callbackManager->getContext(), geocoderProperties);
-               }else{
-                       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,
-                                                       JSTizenException::INVALID_VALUES_ERROR, "invalid parameter");
-                       m_callbackManager->callOnError(errorObject);
-               }
-
-               propertiesVector.push_back(jsObj);
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-
-               JSValueRef geocoderPropertiesArray[2] =  {converter.toJSValueRef(propertiesVector), converter.toJSValueRef(propertiesVector.size())};
-               m_callbackManager->callOnSuccess(geocoderPropertiesArray, 2);
-
-               LogDebug("after callOnSuccess");
-       } else {
-               LogDebug("Operation failed. Exception code: " << event->getExceptionCode());
-
-               JSValueRef errorObject = NULL;
-
-               ExceptionCodes::Enumeration exception = event->getExceptionCode();
-               switch(exception){
-               case ExceptionCodes::InvalidArgumentException:
-                       errorObject = JSTizenExceptionFactory::makeErrorObject(context,
-                               JSTizenException::INVALID_VALUES_ERROR, "invalid parameter");
-                       break;
-               case ExceptionCodes::PlatformException:
-                       errorObject = JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::IO_ERROR, "network fail");
-                       break;
-               case ExceptionCodes::PlatformWrongStateException:
-                       errorObject = JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::UNKNOWN_ERROR, "service not available");
-                       break;
-               default:
-                       errorObject = JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::UNKNOWN_ERROR, "Unknown error");
-                       break;
-               }
-
-               m_callbackManager->callOnError(errorObject);
-       }
-
-       LogDebug(">>>");
-}
-
-void GeocoderController::setCallback(const JSCallbackManagerPtr &callbackManager) {
-       m_callbackManager = callbackManager;
-}
-
-JSCallbackManagerPtr GeocoderController::getCallback() const {
-       return m_callbackManager;
-}
-
-}
-}
-
diff --git a/src/standards/Tizen/Geocoder/GeocoderController.h b/src/standards/Tizen/Geocoder/GeocoderController.h
deleted file mode 100644 (file)
index 4b0d42a..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-
-
-
-/*
- * @author      sangtai kim(Sangtai.kim@samsung.com)
- * @version     0.1
- * @brief
- */
-
-#ifndef WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
-#define WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
-
-#include <dpl/event/controller.h>
-#include <dpl/log/log.h>
-
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <API/Geocoder/EventGeocoder.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-       using namespace WrtDeviceApis::CommonsJavaScript;
-
-class GeocoderController :
-        public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Geocoder::EventGeocoder>
-{
-    public:
-        explicit             GeocoderController(const JSCallbackManagerPtr &callbackManager);
-        virtual              ~GeocoderController();
-        void                 setCallback(const JSCallbackManagerPtr &callbackManager );
-        JSCallbackManagerPtr getCallback() const;
-
-    protected:
-        void OnAnswerReceived(const Api::Geocoder::EventGeocoderPtr &event);
-
-    private:
-        JSCallbackManagerPtr m_callbackManager;
-};
-
-}
-} // WrtPlugins
-
-#endif //WRTPLUGINS_TIZEN_GEOCODER_CONTROLLER_H_
diff --git a/src/standards/Tizen/Geocoder/GeocoderProvider.cpp b/src/standards/Tizen/Geocoder/GeocoderProvider.cpp
new file mode 100755 (executable)
index 0000000..e13b5ba
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "GeocoderProvider.h"
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+GeocoderProvider::GeocoderProvider(std::string _name): name(_name)
+{      
+}
+
+GeocoderProvider::~GeocoderProvider()
+{
+}
+
+
+void GeocoderProvider::setName(std::string &setName)
+{
+       name = setName;
+}
+
+std::string GeocoderProvider::getName()
+{
+       return name;
+}
+
+std::string GeocoderProvider::getAttribution()
+{
+       return "";
+}
+
+       
+} //LBS
+} //Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Geocoder/GeocoderProvider.h b/src/standards/Tizen/Geocoder/GeocoderProvider.h
new file mode 100755 (executable)
index 0000000..57cd32d
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef __WRTPLUGINS_TIZEN_GEOCODER_PROVIDER__
+#define __WRTPLUGINS_TIZEN_GEOCODER_PROVIDER__
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "LocationServiceProvider.h"
+#include "GeoAddress.h"
+#include "GeocodeOptions.h"
+#include "ReverseGeocodeOptions.h"
+#include "LBSPending.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+typedef void (*GeocodeResultArrayCallback)( int result, std::vector<double> coordsArray, void *user_data);
+typedef void (*ReverseGeocodeResultArrayCallback)( int result,std::vector<std::string> strAddrArray, std::vector<GeoAddress> geoAddrArray, void *user_data);
+
+
+class GeocoderProvider :public LocationServiceProvider
+{
+private:
+       std::string name;
+
+protected:
+       void setName(std::string &name);
+               
+public:
+       enum GEOCODER_ERROR { NONE = 0 , INVALID_PARAMETER , OUT_OF_MEMORY, SERVICE_NOT_AVAILABLE, NETWORK_FAILED, TIMEOUT};
+               
+       GeocoderProvider(std::string _name);    
+       virtual ~GeocoderProvider();
+       virtual std::string getName();
+       virtual std::string getAttribution();
+       virtual std::vector<std::pair<std::string, std::string>> getMetadata()=0;
+       virtual std::vector<std::string> getSupportedOptions()=0;
+       virtual std::string getConnectivity()=0;
+       virtual int setOption(std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)=0;
+       virtual bool isUsedExternalNetwork()=0;
+
+       virtual int geocode(GeoAddress address  , GeocodeOptions& option ,  GeocodeResultArrayCallback callback, void *user_data)=0;
+       virtual int geocode(std::string& address   , GeocodeOptions& option ,  GeocodeResultArrayCallback callback, void *user_data)=0;
+       virtual int reverseGeocode(double latitude, double longitude , ReverseGeocodeOptions& option , ReverseGeocodeResultArrayCallback callback, void *user_data)=0;  
+};
+
+}
+}
+}
+
+#endif //__WRTPLUGINS_TIZEN_GEOCODER_PROVIDER__
+
diff --git a/src/standards/Tizen/Geocoder/JSAddress.cpp b/src/standards/Tizen/Geocoder/JSAddress.cpp
deleted file mode 100644 (file)
index 753897d..0000000
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @file          JSAcceleration.cpp
- * @author
- * @version     0.1
- * @brief
- */
-
-#include <cassert>
-#include <memory>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include "JSAddress.h"
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-using namespace WrtDeviceApis;
-using namespace Api::Geocoder;
-
-//namespace {
-#define GEOCODER_COUNTRY                                                "country"
-#define GEOCODER_REGION                                                 "region"
-#define GEOCODER_COUNTY                                                 "county"
-#define GEOCODER_CITY                                                  "city"
-#define GEOCODER_STREET                                                 "street"
-#define GEOCODER_STREET_NUMBER                                  "streetNumber"
-#define GEOCODER_PREMISES                                       "premises"
-#define GEOCODER_ADDITIONAL_INFORMATION         "additionalInformation"
-#define GEOCODER_POSTAL_CODE                            "postalCode"
-//} //private namespace
-
-JSClassDefinition JSAddress::m_classInfo = {
-               0,
-               kJSClassAttributeNone,
-               "address",
-               0,
-               m_property,
-               0,
-               initialize,
-               finalize,
-               NULL, //HasProperty,
-               getProperty,
-               NULL, //SetProperty,
-               NULL, //DeleteProperty,
-               NULL, //GetPropertyNames,
-               NULL, //CallAsFunction,
-               NULL, //CallAsConstructor,
-               hasInstance, NULL, //ConvertToType
-               };
-
-JSStaticValue JSAddress::m_property[] = {
-               { GEOCODER_COUNTRY,                                             getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_REGION,                                              getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_COUNTY,                                              getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_CITY,                                                        getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_STREET,                                              getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_STREET_NUMBER,                               getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_PREMISES,                                    getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_ADDITIONAL_INFORMATION,      getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { GEOCODER_POSTAL_CODE,                                 getProperty, NULL, kJSPropertyAttributeReadOnly },
-               { 0, 0, 0, 0 }
-};
-
-const JSClassRef JSAddress::getClassRef() {
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSAddress::getClassInfo() {
-       return &m_classInfo;
-}
-
-JSClassRef JSAddress::m_jsClassRef = JSClassCreate(JSAddress::getClassInfo());
-
-JSObjectRef JSAddress::createJSObject(JSContextRef context, const GeocoderProperties &geocoderProperties) {
-       LogDebug("<<< context:" << context);
-
-       std::auto_ptr<GeocoderProperties> accProps(new GeocoderProperties(geocoderProperties));
-       JSAddressPriv *priv = new JSAddressPriv(context, accProps.get());
-       accProps.release();
-       if (!priv) {
-               ThrowMsg(Commons::NullPointerException, "Can not new an object");
-       }
-
-       LogDebug(">>>");
-       return JSObjectMake(context, getClassRef(), priv);
-}
-
-void JSAddress::initialize(JSContextRef context, JSObjectRef object) {
-       LogDebug("Entered. Nothing to do.");
-}
-
-void JSAddress::finalize(JSObjectRef object) {
-       LogDebug("Entered");
-       JSAddressPriv* priv = static_cast<JSAddressPriv*> (JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting acceleration object");
-       delete priv;
-}
-
-JSValueRef JSAddress::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
-       LogDebug("<<< object" << object);
-
-       JSAddressPriv *priv = static_cast<JSAddressPriv*> (JSObjectGetPrivate(object));
-       assert(priv && "Private object not set.");
-
-       Try {
-               GeocoderProperties *geocoderProperties = priv->getObject();
-               WrtDeviceApis::CommonsJavaScript::Converter convert(context);
-
-
-               //TODO Add checking NULL String     2011.09.15
-               JSValueRef retValue;
-               if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_ADDITIONAL_INFORMATION)) {
-                       LogDebug("propertyName: " << GEOCODER_ADDITIONAL_INFORMATION);
-                       LogDebug("geocoderProperties->strAdditionalInformation:[" << geocoderProperties->strAdditionalInformation << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strAdditionalInformation);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_CITY)) {
-                       LogDebug("propertyName: " << GEOCODER_CITY);
-                       LogDebug("geocoderProperties->strCity:[" << geocoderProperties->strCity << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strCity);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_COUNTRY)) {
-                       LogDebug("propertyName: " << GEOCODER_COUNTRY);
-                       LogDebug("geocoderProperties->strCountryCode:[" << geocoderProperties->strCountry <<"]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strCountry);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_COUNTY)) {
-                       LogDebug("propertyName: " << GEOCODER_COUNTY);
-                       LogDebug("geocoderProperties->strCounty:[" << geocoderProperties->strCounty << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strCounty);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_POSTAL_CODE)) {
-                       LogDebug("propertyName: " << GEOCODER_POSTAL_CODE);
-                       LogDebug("geocoderProperties->strPostalCode:[" << geocoderProperties->strPostalCode << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strPostalCode);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_PREMISES)) {
-                       LogDebug("propertyName: " << GEOCODER_PREMISES);
-                       LogDebug("geocoderProperties->strBuildingNumber:[" << geocoderProperties->strPremises << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strPremises);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_REGION)) {
-                       LogDebug("propertyName: " << GEOCODER_REGION);
-                       LogDebug("geocoderProperties->strState:[" << geocoderProperties->strRegion << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strRegion);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_STREET)) {
-                       LogDebug("propertyName: " << GEOCODER_STREET);
-                       LogDebug("geocoderProperties->strStreet:[" << geocoderProperties->strStreet << "]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strStreet);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, GEOCODER_STREET_NUMBER)) {
-                       LogDebug("propertyName: " << GEOCODER_STREET_NUMBER);
-                       LogDebug("geocoderProperties->strStreetNumber:[" << geocoderProperties->strStreetNumber <<"]");
-                       retValue = convert.toJSValueRef(geocoderProperties->strStreetNumber);
-               } else {
-                       LogDebug(">>> make undefined");
-                       return JSValueMakeUndefined(context);
-               }
-
-               LogDebug(">>>");
-               return retValue;
-       }Catch (Commons::Exception){
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-       }
-
-       return NULL;
-}
-
-bool JSAddress::hasInstance(JSContextRef context, JSObjectRef constructor,
-       JSValueRef possibleInstance, JSValueRef* exception) {
-return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-} 
-} //WrtPlugins
-
diff --git a/src/standards/Tizen/Geocoder/JSAddress.h b/src/standards/Tizen/Geocoder/JSAddress.h
deleted file mode 100644 (file)
index 6b3f5ad..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @file         JSAddress.h
- * @author
- * @version     0.1
- * @brief
- */
-
-#ifndef WRTPLUGINS_TIZEN_JS_ADDRESS_H_
-#define WRTPLUGINS_TIZEN_JS_ADDRESS_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Geocoder/GeocoderProperties.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Geocoder::GeocoderProperties*>::Type JSAddressPriv;
-
-class JSAddress
-{
-public:
-       static const JSClassDefinition* getClassInfo();
-
-       static const JSClassRef getClassRef();
-
-       /**
-       * create an JSObject for callback function(onAnswerReceived).
-       */
-       static JSObjectRef createJSObject(JSContextRef context,
-                       const Api::Geocoder::GeocoderProperties &geocodoerProperties);
-
-private:
-       /**
-     * The callback invoked when an object is first created.
-     */
-       static void initialize(JSContextRef context, JSObjectRef object);
-
-       /**
-     * The callback invoked when an object is finalized.
-     */
-       static void finalize(JSObjectRef object);
-
-       /**
-     * The callback invoked when getting a property's value.
-     */
-       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-
-       /**
-     * The callback invoked when an object is used as the target of an 'instanceof' expression.
-     */
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
-
-       /**
-     * This structure contains properties and callbacks that define a type of object.
-     */
-       static JSClassDefinition m_classInfo;
-
-       /**
-     * This structure describes a statically declared value property.
-     */
-       static JSStaticValue m_property[];
-
-       static JSClassRef m_jsClassRef;
-};
-
-} 
-} //WrtPlugins
-
-#endif
-
diff --git a/src/standards/Tizen/Geocoder/JSCoordinates.cpp b/src/standards/Tizen/Geocoder/JSCoordinates.cpp
deleted file mode 100644 (file)
index 586814d..0000000
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @file        JSCoordinates.cpp
- * @author      
- * @version     0.1
- * @brief       Implementation of the JSCoordinates class
- */
-
-#include "JSCoordinates.h"
-
-#include <cassert>
-#include <memory>
-#include <dpl/log/log.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-//#include <Tizen/commons/JSDOMExceptionFactory.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace Api::Geocoder;
-
-//namespace {
-    #define COORDINATE_LATITUDE      "latitude"
-    #define COORDINATE_LONGITUDE     "longitude"
-    #define COORDINATE_ALTITUDE      "altitude"
-    #define COORDINATE_ACCURACY      "accuracy"
-    #define COORDINATE_ALTITUDE_ACC  "altitudeAccuracy"
-    #define COORDINATE_HEADING       "heading"
-    #define COORDINATE_SPEED         "speed"
-//} // private namespace
-
-JSClassRef JSCoordinates::m_jsClassRef = NULL;
-
-JSClassDefinition JSCoordinates::m_classInfo =
-{
-               0,
-               kJSClassAttributeNone,
-               "Coordinates",
-               0,
-               m_property,
-               0,
-               initialize,
-               finalize,
-               NULL, //hasProperty,
-               NULL, //getProperty,
-               NULL, //setProperty,
-               NULL, //deleteProperty,
-               NULL, //getPropertyNames,
-               NULL, //callAsFunction,
-               NULL, //callAsConstructor,
-               hasInstance,
-               NULL, //convertToType
-};
-
-JSStaticValue JSCoordinates::m_property[] =
-{
-    {COORDINATE_LATITUDE,              getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_LONGITUDE,             getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_ALTITUDE,              getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_ACCURACY,              getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_ALTITUDE_ACC,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_HEADING,               getProperty, NULL, kJSPropertyAttributeReadOnly},
-    {COORDINATE_SPEED,                 getProperty, NULL, kJSPropertyAttributeReadOnly},
-           { 0, 0, 0, 0 }
-};
-
-const JSClassRef JSCoordinates::getClassRef() {
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-JSObjectRef JSCoordinates::createJSObject(JSContextRef context, const GeocoderProperties &geocoderProperties) {
-       std::auto_ptr < GeocoderProperties > posProps(new GeocoderProperties(geocoderProperties));
-       JSCoordinatesPriv *priv = new JSCoordinatesPriv(context, posProps.get());
-       posProps.release();
-       return JSObjectMake(context, getClassRef(), priv);
-}
-
-const JSClassDefinition* JSCoordinates::getClassInfo() {
-       return &m_classInfo;
-}
-
-void JSCoordinates::initialize(JSContextRef context, JSObjectRef object) {
-       LogDebug("Entered. Nothing to do.");
-}
-
-void JSCoordinates::finalize(JSObjectRef object) {
-       LogDebug("Entered");
-       JSCoordinatesPriv* priv = static_cast<JSCoordinatesPriv*> (JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting coordinates object");
-       delete priv;
-}
-
-JSValueRef JSCoordinates::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception) {
-       LogDebug("<<< ");
-
-       JSCoordinatesPriv *priv = static_cast<JSCoordinatesPriv*> (JSObjectGetPrivate(object));
-       assert(priv && "Private object not set.");
-
-       JSValueRef retVal = NULL;
-
-       Try{
-               GeocoderProperties *props = priv->getObject();
-               Converter convert(context);
-
-               if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_LATITUDE)) {
-                       LogDebug(COORDINATE_LATITUDE << ":" << props->latitude);
-                       retVal = convert.toJSValueRef(props->latitude);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_LONGITUDE)) {
-                       LogDebug(COORDINATE_LONGITUDE << ":" << props->longitude);
-                       retVal = convert.toJSValueRef(props->longitude);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_ALTITUDE)) {
-                       LogDebug(COORDINATE_ALTITUDE << ":" << props->altitude);
-                       retVal = convert.toJSValueRef(props->altitude);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_ACCURACY)) {
-                       LogDebug(COORDINATE_ACCURACY << ":" << props->accuracy);
-                       retVal = convert.toJSValueRef(props->accuracy);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_ALTITUDE_ACC)) {
-                       LogDebug(COORDINATE_ALTITUDE_ACC << ":" << props->altitudeAccuracy);
-                       retVal = convert.toJSValueRef(props->altitudeAccuracy);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_HEADING)) {
-                       LogDebug(COORDINATE_HEADING << ":" << props->heading);
-                       retVal = convert.toJSValueRef(props->heading);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, COORDINATE_SPEED)) {
-                       LogDebug(COORDINATE_SPEED << ":" << props->speed);
-                       retVal = convert.toJSValueRef(props->speed);
-               }else{
-                       retVal = JSValueMakeUndefined(context);
-               }
-       }Catch (Exception){
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSDOMExceptionFactory::UnknownException.make(context, exception);
-       }
-
-       LogDebug(">>>");
-       return retVal;
-}
-
-bool JSCoordinates::hasInstance(JSContextRef context, JSObjectRef constructor,
-       JSValueRef possibleInstance, JSValueRef* exception){
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-} // Tizen1_0
-} // WrtPlugins
-
diff --git a/src/standards/Tizen/Geocoder/JSCoordinates.h b/src/standards/Tizen/Geocoder/JSCoordinates.h
deleted file mode 100644 (file)
index e6509ca..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-/*
- * @file        JSCoordinates.h
- * @author      
- * @version     0.1
- * @brief       Declaration of the JSCoordiates class
- */
-
-#ifndef WRTPLUGINS_TIZEN_JS_COORDINATES_H_
-#define WRTPLUGINS_TIZEN_JS_COORDINATES_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <dpl/shared_ptr.h>
-#include <API/Geocoder/GeocoderProperties.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Geocoder::GeocoderProperties*>::Type JSCoordinatesPriv;
-
-class JSCoordinates {
-public:
-       static const JSClassDefinition* getClassInfo();
-
-       static const JSClassRef getClassRef();
-
-       static JSObjectRef createJSObject(JSContextRef context, const Api::Geocoder::GeocoderProperties &geocoderProperties);
-
-private:
-       /**
-        * The callback invoked when an object is first created.
-        */
-       static void initialize(JSContextRef context, JSObjectRef object);
-
-       /**
-        * The callback invoked when an object is finalized.
-        */
-       static void finalize(JSObjectRef object);
-
-       /**
-        * The callback invoked when getting a property's value.
-        */
-       static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-
-       /**
-        * The callback invoked when an object is used as the target of an 'instanceof' expression.
-        */
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
-
-       /**
-        * This structure contains properties and callbacks that define a type of object.
-        */
-       static JSClassDefinition m_classInfo;
-
-       /**
-        * This structure describes a statically declared value property.
-        */
-       static JSStaticValue m_property[];
-
-       static JSClassRef m_jsClassRef;
-};
-
-} // Tizen1_0
-} // WrtPlugins
-
-#endif
-
diff --git a/src/standards/Tizen/Geocoder/JSGeocodeResult.cpp b/src/standards/Tizen/Geocoder/JSGeocodeResult.cpp
new file mode 100755 (executable)
index 0000000..6d77384
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSGeocodeResult.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+
+JSValueRef JSGeocodeResult::m_defaultObj = NULL;
+
+JSClassRef JSGeocodeResult::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeocodeResult::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "GeocodeResult",                                                                                                                // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       JSGeocodeResult::m_function,            // static functions
+       JSGeocodeResult::initialize,                    // initialize
+       JSGeocodeResult::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL, //call as function
+       NULL, //call as constructor
+       JSGeocodeResult::hasInstance,
+       NULL
+};
+
+JSStaticFunction JSGeocodeResult::m_function[] = {
+        { "toGeoJSON",JSGeocodeResult::toGeoJSON,kJSPropertyAttributeNone },
+               { 0, 0, 0 }
+};
+
+const JSClassRef JSGeocodeResult::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeocodeResult::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSGeocodeResult::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSGeocodeResult::finalize(JSObjectRef object) 
+{
+}
+
+bool JSGeocodeResult::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSGeocodeResult::toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       double lat = 0.0;
+       double lng = 0.0;
+       char geojson_str[1024];
+       Converter convert(context);
+
+
+       JSValueRef coordinates = LBSUtil::getPropertyToValueRef(context, thisObject, "coordinates");
+       JSObjectRef coordinatesObj = JSValueToObject(context, coordinates, NULL);
+       if(coordinatesObj!=NULL)
+       {
+               LOGD("%s - coordinates obj is not NULL",__func__);
+               lat = LBSUtil::getPropertyToDouble(context, coordinatesObj, "latitude");
+               lng = LBSUtil::getPropertyToDouble(context, coordinatesObj, "longitude");
+       }
+
+       snprintf(geojson_str, 1024, "{ \"type\": \"Point\", \"coordinates\": [%lf, %lf] }", lat, lng);
+       LOGD("%s - GeoJSON : %s",__func__,geojson_str);
+       return convert.toJSValueRef(string(geojson_str));
+}
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Geocoder/JSGeocodeResult.h b/src/standards/Tizen/Geocoder/JSGeocodeResult.h
new file mode 100755 (executable)
index 0000000..b547bec
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef __WRTPLUGINS_TIZEN_JS_GEOCODE_RESULT__
+#define __WRTPLUGINS_TIZEN_JS_GEOCODE_RESULT__
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeocodeResult
+{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+       static JSValueRef m_defaultObj;         
+       
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSValueRef toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+               
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //__WRTPLUGINS_TIZEN_JS_GEOCODE_RESULT__
diff --git a/src/standards/Tizen/Geocoder/JSGeocoder.cpp b/src/standards/Tizen/Geocoder/JSGeocoder.cpp
deleted file mode 100644 (file)
index 0c4c58c..0000000
+++ /dev/null
@@ -1,521 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-/*
- * @file        JSGeocoder.cpp
- * @author      Sangtai Kim (sangtai.kim@samsung.com)
- * @version     0.1
- * @brief       Implementation of the JSGeocoder class
- */
-
-#include "JSGeocoder.h"
-#include "GeocoderController.h"
-
-#include <API/Geocoder/GeocoderFactory.h>
-#include <API/Geocoder/EventGeocoder.h>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-
-#include <CommonsJavaScript/Utils.h>
-
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/SecurityExceptions.h>
-
-#include "plugin_config.h"
-
-using namespace std;
-using namespace DPL;
-//using namespace TizenApis::Tizen1_0::Platform;
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace TizenApis::Tizen1_0::Api::Geocoder;
-using namespace TizenApis::Commons;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-//#define GET_ADDRESS_ARGUMENT_COUNT  4
-//#define GET_POSITION_ARGUMENT_COUNT 3
-
-       const std::string JSGeocoder::JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT = "Invalid argument";
-
-const std::string JSGeocoder::GEOCODER_ADDRESS_COUNTRY                 = "country";
-const std::string JSGeocoder::GEOCODER_ADDRESS_REGION                  = "region";
-const std::string JSGeocoder::GEOCODER_ADDRESS_COUNTY                  = "county";
-const std::string JSGeocoder::GEOCODER_ADDRESS_CITY                    = "city";
-const std::string JSGeocoder::GEOCODER_ADDRESS_STREET                  = "street";
-const std::string JSGeocoder::GEOCODER_ADDRESS_STREET_NUMBER           = "streetNumber";
-const std::string JSGeocoder::GEOCODER_ADDRESS_PREMISES                = "premises";
-const std::string JSGeocoder::GEOCODER_ADDRESS_ADDTIONAL_INFORMATION   = "additionalInformation";
-const std::string JSGeocoder::GEOCODER_ADDRESS_POSTAL_CODE             = "postalCode";
-
-const std::string JSGeocoder::GEOCODER_COORDINATES_LATITUDE            = "latitude";
-const std::string JSGeocoder::GEOCODER_COORDINATES_LONGITUDE           = "longitude";
-
-const std::string JSGeocoder::gGeocoderAddressArray[] = {
-               GEOCODER_ADDRESS_COUNTRY,
-               GEOCODER_ADDRESS_REGION,
-               GEOCODER_ADDRESS_COUNTY,
-               GEOCODER_ADDRESS_CITY,
-               GEOCODER_ADDRESS_STREET,
-               GEOCODER_ADDRESS_STREET_NUMBER,
-               GEOCODER_ADDRESS_PREMISES,
-               GEOCODER_ADDRESS_ADDTIONAL_INFORMATION,
-               GEOCODER_ADDRESS_POSTAL_CODE
-};
-
-JSClassRef JSGeocoder::m_jsClassRef = NULL;
-
-JSClassDefinition JSGeocoder::m_classInfo = {
-               0,
-               kJSClassAttributeNone,
-               "Geocoder",
-               NULL,
-               NULL,
-               m_function,
-               initialize,
-               finalize,
-               NULL, //hasProperty,
-               NULL, //getProperty,
-               NULL, //setProperty,
-               NULL, //deleteProperty,Geolocation
-               NULL, //getPropertyNames,
-               NULL,
-               NULL,
-               hasInstance,
-               NULL
-};
-
-JSStaticFunction JSGeocoder::m_function[] = {
-               { "geocode",     JSGeocoder::geocode,     kJSPropertyAttributeNone },
-               { "reverseGeocode",    JSGeocoder::reverseGeocode,    kJSPropertyAttributeNone },
-               { 0, 0, 0 }
-};
-
-const JSClassRef JSGeocoder::getClassRef() {
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSGeocoder::getClassInfo() {
-       return &m_classInfo;
-}
-
-void JSGeocoder::initialize(JSContextRef context, JSObjectRef object) {
-       JSGeocoderPriv* priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(object));
-       assert(!priv && "Invalid object creation.");
-       IGeocoderPtr geocoder(GeocoderFactory::getInstance().getGeocoder());
-       priv = new JSGeocoderPriv(context, geocoder);
-       if (!JSObjectSetPrivate(object, static_cast<void*> (priv))) {
-               LogError("Object can't store private data.");
-               delete priv;
-       }
-}
-
-void JSGeocoder::finalize(JSObjectRef object) {
-       JSGeocoderPriv* priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting gallery");
-       delete priv;
-}
-
-GeocoderProperties JSGeocoder::toGeocoderProperties(JSContextRef context, const JSValueRef& arg){
-       GeocoderProperties properties;
-
-       CommonsJavaScript::Converter converter(context);
-
-       JSValueRef valueRefLatitude = JSUtils::getJSProperty(context, arg, GEOCODER_COORDINATES_LATITUDE);
-       if(valueRefLatitude!=NULL && JSValueIsNumber(context, valueRefLatitude)){
-               properties.latitude  = converter.toDouble(valueRefLatitude);
-       }else{
-               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-       }
-
-       JSValueRef valueRefLongitude = JSUtils::getJSProperty(context, arg, GEOCODER_COORDINATES_LONGITUDE);
-       if(valueRefLongitude!=NULL && JSValueIsNumber(context, valueRefLongitude)){
-               properties.longitude  = converter.toDouble(valueRefLongitude);
-       }else{
-               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-       }
-
-       return properties;
-}
-
-bool JSGeocoder::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSValueRef JSGeocoder::getAddressByCoordinates(JSContextRef context, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-
-       JSGeocoderPriv *priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(thisObject));
-
-       assert(priv && "Invalid private pointer.");
-       CommonsJavaScript::Converter converter(context);
-       Validator check(context, exception);
-
-       JSValueRef onSuccess = NULL;
-       JSValueRef onError  = NULL;
-
-       GeocoderProperties properties;
-       Try{
-               properties = toGeocoderProperties(context, arguments[0]);
-       }Catch(WrtDeviceApis::Commons::InvalidArgumentException){
-               return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-       }
-
-       double latitude         = properties.latitude;
-       double longitude        = properties.longitude;
-
-       if(argumentCount==2){
-               onSuccess = arguments[1];
-               onError   = NULL;
-               if(check.isCallback(onSuccess) != true){
-                                       LogError("Wrong callbacks parameters");
-                                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                               }
-       }else if(argumentCount==3){
-               onSuccess = arguments[1];
-               onError   = arguments[2];
-               if(check.isCallback(onSuccess)!=true || check.isCallback(onError)!=true){
-                       LogError("Wrong callbacks parameters");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-       }else{
-               LogError("Wrong callbacks parameters");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-       }
-
-       return getAddressInternal(context, latitude, longitude, thisObject, onSuccess, onError);
-}
-
-
-JSValueRef JSGeocoder::getAddressInternal(JSContextRef context, double latitude, double longitude, JSObjectRef thisObject, JSValueRef onSuccess, JSValueRef onError){
-               LogDebug(" <<< latitude:" << latitude << ", longitude:" << longitude);
-
-               JSGeocoderPriv *priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(thisObject));
-               JSContextRef gContext = priv->getContext();
-               assert(priv && "Invalid private pointer.");
-
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccess, onError));
-
-               EventGeocoderPtr event(new EventGeocoder());
-               SharedPtr < IEventController > eventContr = StaticPointerCast<IEventController> (event);
-               JSObjectRef pendingOperation = CommonsJavaScript::makePendingOperation(gContext, event);
-
-               Try{
-                       IGeocoderPtr geocoder(priv->getObject());
-
-                       event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-                       event->setForAsynchronousCall(new GeocoderController(cbm));
-                       event->setLatitude(latitude);
-                       event->setLongitude(longitude);
-                       event->setEventType(EventGeocoder::GEOCODER_EVENT_GET_ADDRESS);
-
-                       geocoder->getAddressFromPosition(event);
-               }Catch (WrtDeviceApis::Commons::PendingOperationException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT));
-               }Catch (WrtDeviceApis::Commons::ConversionException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT));
-               }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT));
-               }Catch(WrtDeviceApis::Commons::Exception){
-                       LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::UNKNOWN_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT ));
-               }
-
-               LogInfo(">>>");
-               return pendingOperation;
-}
-
-
-
-JSValueRef JSGeocoder::getAddressByPosition(JSContextRef context, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-
-       JSValueRef onSuccess = NULL;
-       JSValueRef onError  = NULL;
-
-       JSGeocoderPriv *priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(thisObject));
-
-       assert(priv && "Invalid private pointer.");
-       CommonsJavaScript::Converter converter(context);
-       Validator check(context, exception);
-
-       if(argumentCount==3){
-                       onSuccess = arguments[2];
-                       onError   = NULL;
-                       if(check.isCallback(onSuccess) != true){
-                               LogError("Wrong callbacks parameters");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                       }
-               }else if(argumentCount==4){
-                       onSuccess = arguments[2];
-                       onError   = arguments[3];
-                       if(check.isCallback(onSuccess)!=true || check.isCallback(onError)!=true){
-                               LogError("Wrong callbacks parameters");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                       }
-               }else{
-                       LogError("Wrong callbacks parameters");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               //check is valid ratitude and longitude
-               if(JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])){
-                       LogError("[ERROR]Wrong latitude");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               if(JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])){
-                       LogError("[ERROR]Wrong longitude");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               double l_latitude       = 0.0;
-               double l_longitude      = 0.0;
-
-               Try{
-                       l_latitude      = static_cast<double>(converter.toDouble(arguments[0]));
-                       l_longitude = static_cast<double>(converter.toDouble(arguments[1]));
-               }Catch(WrtDeviceApis::Commons::ConversionException){
-                       LogError("[ERROR]Conversion Exception");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               return getAddressInternal(context, l_latitude, l_longitude, thisObject, onSuccess, onError);
-}
-
-JSValueRef JSGeocoder::geocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-       LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
-
-               JSGeocoderPriv *priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(thisObject));
-               assert(priv && "Invalid private pointer.");
-
-               AceSecurityStatus status = GEOCODER_CHECK_ACCESS(priv->getContext(), GEOCODER_FUNCTION_API_REVERSE_GEOCODE);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               CommonsJavaScript::Converter converter(context);
-               Validator check(context, exception);
-
-               //argument[0] : Address
-               //argument[1] : success callback
-               //argument[2] : error callback  //Optional
-               //OR
-               //argument[0] : AddressString
-               //argument[1] : success callback
-               //argument[2] : error callback //Optional
-
-               if(argumentCount<GET_POSITION_ARGUMENT_COUNT || !check.isCallback(arguments[1])){
-                                       LogError("Wrong callbacks parameters");
-                                       return JSTizenExceptionFactory::postException(context, exception,
-                                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               JSValueRef onSuccess = NULL;
-               JSValueRef onError  = NULL;
-
-               if(argumentCount==2){
-                       onSuccess = arguments[1];
-                       onError   = NULL;
-                       if(check.isCallback(onSuccess) != true){
-                               LogError("Wrong callbacks parameters");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                       }
-               }else if(argumentCount==3){
-                       onSuccess = arguments[1];
-                       onError   = arguments[2];
-                       if(check.isCallback(onSuccess)!=true || check.isCallback(onError)!=true){
-                               LogError("Wrong callbacks parameters");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                               JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                       }
-               }else{
-                       LogError("Wrong callbacks parameters");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-               }
-
-               std::string strAddress;
-               EventGeocoderPtr event(new EventGeocoder());
-
-               if(JSValueIsString(context, arguments[0])==true){ //TYPE is B
-                       strAddress = converter.toString(arguments[0]);
-                       event->setAddressString(strAddress);
-               }else{ //TYPE is A
-                       JSValueRef addressUnit = NULL;
-                       int sizeOfGeocoderAddressUnit = sizeof(gGeocoderAddressArray) / sizeof(std::string);
-                       LogDebug("sizeOfGeocoderAddressUnit : " << sizeOfGeocoderAddressUnit);
-
-                       std::map<std::string, std::string> addressMap;
-
-                       //check is valid ratitude and address
-                       if ((!JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0]))){
-                               for(int i=0; i<sizeOfGeocoderAddressUnit; i++){
-                                       addressUnit = JSUtils::getJSProperty(context, arguments[0], gGeocoderAddressArray[i], exception);
-                                       if(addressUnit!=NULL && JSValueIsString(context, addressUnit)){
-                                               strAddress = converter.toString(addressUnit);
-
-                                               LogDebug("strAddress : " << strAddress);
-
-                                               addressMap.insert(pair<std::string, std::string>(gGeocoderAddressArray[i], strAddress));
-                                       }else{
-                                       }
-
-                                       addressUnit = NULL;
-                               }
-                       }else{
-                               LogError("[ERROR]Wrong Address");
-                               return JSTizenExceptionFactory::postException(context, exception,
-                                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT);
-                       }
-
-                       setAddressData(event, addressMap);
-               }       //else
-
-               JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccess, onError));
-
-               SharedPtr < IEventController > eventContr = StaticPointerCast<IEventController> (event);
-               JSObjectRef pendingOperation = CommonsJavaScript::makePendingOperation(context, event);
-
-               Try{
-                               IGeocoderPtr geocoder(priv->getObject());
-
-                               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-                               event->setForAsynchronousCall(new GeocoderController(cbm));
-                               event->setEventType(EventGeocoder::GEOCODER_EVENT_GET_POSITION);
-
-                               geocoder->getPositionFromAddress(event);
-               }Catch (WrtDeviceApis::Commons::PendingOperationException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT ));
-               }Catch (WrtDeviceApis::Commons::ConversionException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT ));
-               }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT ));
-               }Catch(WrtDeviceApis::Commons::Exception){
-                       LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
-                                       JSTizenException::INVALID_VALUES_ERROR, JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT ));
-               }
-
-               LogInfo(">>>");
-               return pendingOperation;
-}      //geocode
-
-JSValueRef JSGeocoder::reverseGeocode (JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-                       const JSValueRef arguments[], JSValueRef* exception) {
-       LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
-
-               JSGeocoderPriv *priv = static_cast<JSGeocoderPriv*> (JSObjectGetPrivate(thisObject));
-               AceSecurityStatus status = GEOCODER_CHECK_ACCESS(priv->getContext(), GEOCODER_FUNCTION_API_GEOCODE);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               //argument[0] : latitude
-               //argument[1] : longitude
-               //argument[2] : success callback
-               //argument[3] : error callback          //optional
-               //OR
-               //argument[0] : Coordinates
-               //argument[1] : success callback
-               //argument[2] : error callback          //optional
-               if(JSValueIsObject(context, arguments[0]) == true){             //argument[0] is Coordinates
-                       return getAddressByCoordinates(context, thisObject, argumentCount, arguments, exception);
-               }else{
-                       return getAddressByPosition(context, thisObject, argumentCount, arguments, exception);
-               }
-}      //reverseGeocode
-
-int JSGeocoder::setAddressData(const Api::Geocoder::EventGeocoderPtr& event, std::map<std::string, std::string>& addressMap)
-{
-       std::map<std::string, std::string>::iterator it;
-
-       it = addressMap.find(GEOCODER_ADDRESS_COUNTRY);
-       if(it != addressMap.end()){
-               event->setCountry(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_REGION);
-       if(it != addressMap.end()){
-               event->setRegion(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_COUNTY);
-       if(it != addressMap.end()){
-               event->setCounty(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_CITY);
-       if(it != addressMap.end()){
-               event->setCity(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_STREET);
-       if(it != addressMap.end()){
-               event->setStreet(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_STREET_NUMBER);
-       if(it != addressMap.end()){
-               event->setStreetNumber(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_PREMISES);
-       if(it != addressMap.end()){
-               event->setPremises(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_ADDTIONAL_INFORMATION);
-       if(it != addressMap.end()){
-               event->setAdditionalInformation(it->second);
-       }
-
-       it = addressMap.find(GEOCODER_ADDRESS_POSTAL_CODE);
-       if(it != addressMap.end()){
-               event->setPostalCode(it->second);
-       }
-
-       return 0;
-}
-
-}// Tizen1_0
-}// WrtPlugins
diff --git a/src/standards/Tizen/Geocoder/JSGeocoder.h b/src/standards/Tizen/Geocoder/JSGeocoder.h
deleted file mode 100644 (file)
index 27ef570..0000000
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-
-
-/*
- * @file        JSGeolocation.h
- * @author      
- * @version     0.1
- * @brief       Declaration of the JSGeolocation class
- */
-
-#ifndef WRTPLUGINS_TIZEN_JS_GEOLOCATION_H_
-#define WRTPLUGINS_TIZEN_JS_GEOLOCATION_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <API/Geocoder/IGeocoder.h>
-
-#include <API/Geocoder/GeocoderProperties.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Geocoder::IGeocoderPtr>::Type JSGeocoderPriv;
-
-class JSGeocoder {
-public:
-       static const JSClassDefinition* getClassInfo();
-
-       static const JSClassRef getClassRef();
-
-
-private:
-       /**
-        * The callback invoked when an object is first created.
-        */
-       static void initialize(JSContextRef context, JSObjectRef object);
-
-       /**
-        * The callback invoked when an object is finalized.
-        */
-       static void finalize(JSObjectRef object);
-
-       /**
-        * The callback invoked when an object is used as the target of an 'instanceof' expression.
-        */
-       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
-
-       /**
-        * Get address from postion.
-        */
-       static JSValueRef geocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-                       const JSValueRef arguments[], JSValueRef* exception);
-
-       /**
-        * Get address from postion.
-        */
-       static JSValueRef reverseGeocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-                       const JSValueRef arguments[], JSValueRef* exception);
-
-
-       static int setAddressData(const Api::Geocoder::EventGeocoderPtr& event, std::map<std::string, std::string>& addressMap);
-
-       static JSValueRef getAddressByCoordinates(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-       static  JSValueRef getAddressByPosition(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-       static JSValueRef getAddressInternal(JSContextRef context, double latitude, double longitude, JSObjectRef thisObject, JSValueRef onSuccess, JSValueRef onError);
-       static Api::Geocoder::GeocoderProperties toGeocoderProperties(JSContextRef context, const JSValueRef& arg);
-
-       /**
-        * This structure contains properties and callbacks that define a type of object.
-        */
-       static JSClassDefinition m_classInfo;
-
-       /**
-        * This structure describes a statically declared function property.
-        */
-       static JSStaticFunction m_function[];
-
-       static JSClassRef m_jsClassRef;
-
-private:
-       static const std::string JSGEOCODER_EXCEPTION_STRING_INVALID_ARGUMENT;
-       static const std::string GEOCODER_ADDRESS_COUNTRY;
-       static const std::string GEOCODER_ADDRESS_REGION;
-       static const std::string GEOCODER_ADDRESS_COUNTY;
-       static const std::string GEOCODER_ADDRESS_CITY;
-       static const std::string GEOCODER_ADDRESS_STREET;
-       static const std::string GEOCODER_ADDRESS_STREET_NUMBER;
-       static const std::string GEOCODER_ADDRESS_PREMISES;
-       static const std::string GEOCODER_ADDRESS_ADDTIONAL_INFORMATION;
-       static const std::string GEOCODER_ADDRESS_POSTAL_CODE;
-
-       static const std::string GEOCODER_COORDINATES_LATITUDE;
-       static const std::string GEOCODER_COORDINATES_LONGITUDE;
-
-       static const std::string gGeocoderAddressArray[];
-
-       enum{
-               GET_POSITION_ARGUMENT_COUNT = 2,
-               GET_ADDRESS_ARGUMENT_COUNT  = 3
-       };
-
-};
-
-} //Tizen1_0
-} //WrtPlugins
-
-#endif
-
diff --git a/src/standards/Tizen/Geocoder/JSGeocoderProvider.cpp b/src/standards/Tizen/Geocoder/JSGeocoderProvider.cpp
new file mode 100755 (executable)
index 0000000..5ae9b18
--- /dev/null
@@ -0,0 +1,541 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/TizenExceptionData.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <dlog.h>
+#include <vector>
+#include "JSGeocoderServiceManager.h"
+#include "JSGeocoderProvider.h"
+#include "JSLocationServiceProvider.h"
+#include "LBSUtil.h"
+#include "GeoAddress.h"
+#include "JSLBS.h"
+#include "JSSimpleCoordinates.h"
+#include "JSGeocodeResult.h"
+#include "GeocoderProvider.h"
+#include "GeocodeOptions.h"
+#include "ReverseGeocodeOptions.h"
+#include "GeocoderACE.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+struct CallbackData {
+       JSObjectRef onSuccess;
+       JSObjectRef onFail;
+};
+
+
+JSContextRef JSGeocoderProvider::m_globalContextRef = NULL;
+JSClassRef JSGeocoderProvider::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeocoderProvider::m_jsClassInfo = {
+       0,                                                                                                      // current (and only) version is 0
+       kJSClassAttributeNone,                          //attributes
+       "GeocoderProvider",                                                             // class name
+       JSLocationServiceProvider::getClassRef(),// parent class
+       NULL,                                                                                   // static values
+       JSGeocoderProvider::m_function,                                                         // static functions
+       JSGeocoderProvider::initialize,                                                                 // initialize
+       JSGeocoderProvider::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL, //call as function
+       NULL, //call as constructor
+       JSGeocoderProvider::hasInstance,
+       NULL
+};
+
+JSStaticFunction JSGeocoderProvider::m_function[] = {
+        { "geocode",JSGeocoderProvider::geocode,kJSPropertyAttributeNone },    
+        { "reverseGeocode",JSGeocoderProvider::reverseGeocode,kJSPropertyAttributeNone },
+        { 0, 0, 0 }
+};
+
+const JSClassRef JSGeocoderProvider::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeocoderProvider::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSGeocoderProvider::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+       LOGD("%s - JSGeocoderProvider", __func__);
+       if( JSGeocoderProvider::m_globalContextRef == NULL )
+       {
+               JSGeocoderProvider::m_globalContextRef = ctx;
+       }
+}
+
+void JSGeocoderProvider::finalize(JSObjectRef object) 
+{
+       LOGD("%s - JSGeocoderProvider", __func__);
+       GeocoderProvider * priv = reinterpret_cast<GeocoderProvider*>(JSObjectGetPrivate(object));
+       if( priv )
+       {
+               delete priv;
+               JSObjectSetPrivate(object, NULL);
+               LOGD("%s - delete the private object");
+       }
+}
+
+bool JSGeocoderProvider::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+std::string __convertErrorCode(int code)
+{
+               std::string convertedErr;
+               switch(code)
+               {
+                       case GeocoderProvider::GEOCODER_ERROR::INVALID_PARAMETER:
+                               convertedErr =  Commons::JSTizenException::INVALID_VALUES_ERROR;
+                               break;
+                       case GeocoderProvider::GEOCODER_ERROR::SERVICE_NOT_AVAILABLE:
+                               convertedErr =  Commons::JSTizenException::SERVICE_NOT_AVAILABLE;
+                               break;
+                       case GeocoderProvider::GEOCODER_ERROR::NETWORK_FAILED:
+                               convertedErr =  Commons::JSTizenException::NETWORK_ERROR;
+                               break;
+                       case GeocoderProvider::GEOCODER_ERROR::TIMEOUT:
+                               convertedErr =  Commons::JSTizenException::TIMEOUT_ERROR;
+                               break;
+                       case GeocoderProvider::GEOCODER_ERROR::OUT_OF_MEMORY:
+                       default:
+                               convertedErr = Commons::JSTizenException::UNKNOWN_ERROR;
+                               break;
+               }
+               return convertedErr;
+}
+
+void __geocodeResultArrayCallback(int result, std::vector<double> coordsArray, void *user_data)
+{
+       CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+       if ( userdata == NULL)
+               return;
+
+       if( result == 0 )
+       {
+               unsigned int numOfCoords = coordsArray.size()/2;
+               JSValueRef* geocodeResultValues = new JSValueRef[numOfCoords];
+               for( unsigned int i=0 ; i < numOfCoords; i++)
+               {
+                               JSObjectRef obj = JSObjectMake(JSLBS::getGlobalContext() , JSGeocodeResult::getClassRef(), NULL);
+                               JSObjectRef coordinates= JSObjectMake(JSLBS::getGlobalContext() , Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+                               LBSUtil::setProperty(JSLBS::getGlobalContext() , coordinates, "latitude", coordsArray[i] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(JSLBS::getGlobalContext() , coordinates, "longitude", coordsArray[i+1] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(JSLBS::getGlobalContext() , obj, "coordinates", coordinates , kJSPropertyAttributeReadOnly);
+                               geocodeResultValues[i] = obj;
+                               JSValueProtect(JSLBS::getGlobalContext(), geocodeResultValues[i]);
+               }
+               JSObjectRef jsGeocodeResultArray = JSObjectMakeArray(JSLBS::getGlobalContext(), numOfCoords, geocodeResultValues, NULL);
+               delete []geocodeResultValues;
+               JSValueRef args[1] = {jsGeocodeResultArray};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext(), userdata->onSuccess , NULL, 1, args, NULL);
+       }
+       else if(userdata->onFail)
+       {
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), __convertErrorCode(result ), "Fail to get geocode result");
+               JSValueRef args[1] = {error};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+       }
+       else
+       {
+               LOGD("%s -Consume the error (%d) : There is no error callback", __func__, result);
+       }
+
+       if( userdata->onSuccess )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onSuccess);
+       if( userdata->onFail )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onFail);
+
+       if(userdata)
+               delete userdata;
+}
+
+void __reverseGeocodeResultArrayCallback(int result, std::vector<std::string> strAddrArray, std::vector<GeoAddress> geoAddrArray, void *user_data)
+{
+       CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+       if ( userdata == NULL)
+               return;
+
+       if( result == 0 )
+       {
+               unsigned int size;
+               JSValueRef* reverseGeocodeResultValues;
+               if(!strAddrArray.empty())
+               {
+                       size = strAddrArray.size();
+                       reverseGeocodeResultValues = new JSValueRef[size];
+                       for( unsigned int i=0 ; i < size; i++)
+                       {
+                               Converter convert(JSLBS::getGlobalContext());
+                               reverseGeocodeResultValues[i] = convert.toJSValueRef(strAddrArray[i]);
+                               JSValueProtect(JSLBS::getGlobalContext(), reverseGeocodeResultValues[i]);
+                       }
+               }
+               else
+               {
+                       size = geoAddrArray.size();
+                       reverseGeocodeResultValues = new JSValueRef[size];
+                       
+                       for( unsigned int i=0 ; i < size; i++)
+                       {
+                               reverseGeocodeResultValues[i] = geoAddrArray[i].toJSObject(JSLBS::getGlobalContext());
+                               JSValueProtect(JSLBS::getGlobalContext(), reverseGeocodeResultValues[i]);
+                       }
+               }
+       
+               JSObjectRef jsReverseGeocodeResultArray = JSObjectMakeArray(JSLBS::getGlobalContext(), size, reverseGeocodeResultValues, NULL);
+               delete []reverseGeocodeResultValues;
+               JSValueRef args[1] = {jsReverseGeocodeResultArray};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext(), userdata->onSuccess , NULL, 1, args, NULL);
+       }
+       else if(userdata->onFail)
+       {
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), __convertErrorCode(result ), "Fail to get reverse geocode result");
+               JSValueRef args[1] = {error};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+       }
+       else
+       {
+               LOGD("%s -Consume the error (%d) : There is no error callback", __func__, result);
+       }
+
+       if( userdata->onSuccess )
+               JSValueUnprotect(JSLBS::getGlobalContext() , userdata->onSuccess);
+       if( userdata->onFail )
+               JSValueUnprotect(JSLBS::getGlobalContext() , userdata->onFail);
+
+       if(userdata)
+               delete userdata;
+}
+
+JSValueRef JSGeocoderProvider::geocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       LOGD("%s -start", __func__);
+
+       // Check the access control
+       AceSecurityStatus status = GEOCODER_CHECK_ACCESS(GEOCODER_FUNCTION_CATEGORY_BASIC);
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+       LOGD("%s - Access control pass!", __func__);
+       
+       // Check the Object type
+       GeocoderProvider * priv = reinterpret_cast<GeocoderProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+
+       JSValueRef convertedArg[4];
+       JSObjectRef convertedArgObjects[4];
+       for (unsigned int i=0; i<4; i++)
+       {
+               if(i<argumentCount)
+               {
+                       convertedArg[i] = arguments[i];
+                       convertedArgObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+               }
+               else
+               {
+                       convertedArg[i] = JSValueMakeUndefined(context);
+                       convertedArgObjects[i] = NULL;
+               }
+       }
+       //Check the first argument
+       if(JSValueIsNull(context, convertedArg[0]) || JSValueIsUndefined(context, convertedArg[0]))
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is invalid (null or undefined)");
+       }
+
+       bool isFormattedAddress;
+       if(JSValueIsString(context, convertedArg[0]))
+       {
+               LOGD("%s - It is formatted address", __func__);
+               isFormattedAddress = true;
+       }
+       else if(JSValueIsObject(context, convertedArg[0]))
+       {
+               LOGD("%s - It is Structed address", __func__);
+               isFormattedAddress = false;
+       }
+       else
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is invalid (It must be String or Address)");
+       }
+
+       //Check the second argument is function object
+       if(JSValueIsNull(context, convertedArg[1]) || JSValueIsUndefined(context, convertedArg[1]) || !JSObjectIsFunction(context, convertedArgObjects[1]))
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function");
+       }
+
+       //Check the third argument is NULL or Undefined or function object
+       bool isFunctionOnFail;
+       if(JSValueIsNull(context, convertedArg[2]) || JSValueIsUndefined(context, convertedArg[2]))
+       {
+               isFunctionOnFail = false;
+               LOGD("%s - 3rd argument is OK (Either null or undefined) ", __func__);
+       }
+       else if (JSObjectIsFunction(context, convertedArgObjects[2]))
+       {
+               isFunctionOnFail = true;
+               LOGD("%s - 3rd argument is OK (function) ", __func__);
+       }
+       else
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The 3rd argument must be function or null or undefined");
+       }
+
+       Converter convert(context);
+       CallbackData * userdata =  new CallbackData();
+       userdata->onFail = NULL;        
+
+       //set the success callback
+       userdata->onSuccess= convertedArgObjects[1];
+       JSValueProtect(context, convertedArg[1]);
+
+       //set the error callback
+       if(isFunctionOnFail)
+       {
+               userdata->onFail = convertedArgObjects[2];
+               JSValueProtect(context, convertedArg[2]);
+       }
+
+       //set the geocode option
+       GeocodeOptions options;
+       if(JSValueIsNull(context, convertedArg[3]) || JSValueIsUndefined(context, convertedArg[3]))
+       {
+               LOGD("%s - 4th argument (GeocodeOption) is NULL or Undefined", __func__);
+       }
+       else
+       {
+               if(!JSValueIsObject(context, convertedArg[3]))
+               {
+                       if(userdata)
+                               delete userdata;
+                       return Commons::JSTizenExceptionFactory::postException(context, exception, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The 4th  argument must be converted to GeocodeOptions");
+               }
+               else if(!GeocodeOptions::convert(context, convertedArgObjects[3], &options, exception))
+               {
+                       if(userdata)
+                               delete userdata;
+                       return JSValueMakeUndefined(context);
+               }
+               else
+               {
+                       LOGD("%s - 4th argument (GeocodeOption) is valid", __func__);
+               }
+       }
+
+       int ret;
+       // Is String object
+       if( isFormattedAddress)
+       {
+               string address = convert.toString(convertedArg[0]);
+               ret = priv->geocode(address , options, __geocodeResultArrayCallback, userdata);
+       }
+       else
+       {
+               GeoAddress address = GeoAddress::convert(context, convertedArgObjects[0] );
+               ret = priv->geocode(address, options, __geocodeResultArrayCallback, userdata);
+       }
+       
+       // Error, Should delete callback data
+       if (ret != 0 )
+       {
+               if(userdata->onSuccess)
+                       JSValueUnprotect(context, userdata->onSuccess);
+               if (userdata->onFail)
+               {
+                       LOGD("%s - Throw ErrorCB (%d)", __func__, ret);
+                       LOGD("%s - Throw ErrorCB (%d)", __func__, ret);
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), __convertErrorCode(ret), "Fail to geocode()");
+                       JSValueRef args[1] = {error};
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+                       JSValueUnprotect(context, userdata->onFail);
+               }
+               else
+               {
+                       LOGD("%s - Consume the error : There is no error callback (%d) ", __func__, ret);
+               }
+                       
+               if(userdata)
+                       delete userdata;
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSGeocoderProvider::reverseGeocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       LOGD("%s -start", __func__);
+
+       // Check the access control
+       AceSecurityStatus status = GEOCODER_CHECK_ACCESS(GEOCODER_FUNCTION_CATEGORY_BASIC);
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+       LOGD("%s - Access control pass!", __func__);
+
+       // Check the Object type
+       GeocoderProvider * priv = reinterpret_cast<GeocoderProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+
+       JSValueRef convertedArg[4];
+       JSObjectRef convertedArgObjects[4];
+       for (unsigned int i=0; i<4; i++)
+       {
+               if(i<argumentCount)
+               {
+                       convertedArg[i] = arguments[i];
+                       convertedArgObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+               }
+               else
+               {
+                       convertedArg[i] = JSValueMakeUndefined(context);
+                       convertedArgObjects[i] = NULL;
+               }
+       }
+
+       //Check the first argument
+       if(JSValueIsNull(context, convertedArg[0]) || JSValueIsUndefined(context, convertedArg[0]) || !JSValueIsObject(context, convertedArg[0]))
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is invalid (null or undefined or not object)");
+       }
+
+       //Check the second argument is function object
+       if(JSValueIsNull(context, convertedArg[1]) || JSValueIsUndefined(context, convertedArg[1]) || !JSObjectIsFunction(context, convertedArgObjects[1]))
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function");
+       }
+
+       //Check the third argument is NULL or Undefined or function object
+       bool isFunctionOnFail;
+       if(JSValueIsNull(context, convertedArg[2]) || JSValueIsUndefined(context, convertedArg[2]))
+       {
+               isFunctionOnFail = false;
+               LOGD("%s - 3rd argument is OK (Either null or undefined) ", __func__);
+       }
+       else if (JSObjectIsFunction(context, convertedArgObjects[2]))
+       {
+               isFunctionOnFail = true;
+               LOGD("%s - 3rd argument is OK (function) ", __func__);
+       }
+       else
+       {
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The 3rd argument must be function or null or undefined");
+       }
+
+       Converter convert(context);
+       CallbackData * userdata =  new CallbackData();
+
+       //set the success callback
+       userdata->onSuccess= convertedArgObjects[1];
+       JSValueProtect(context, convertedArg[1]);
+
+       //set the error callback
+       if(isFunctionOnFail)
+       {
+               userdata->onFail = convertedArgObjects[2];
+               JSValueProtect(context, convertedArg[2]);
+       }
+       else
+       {
+               userdata->onFail = NULL;
+       }
+
+       //set the reverse geocode option
+       ReverseGeocodeOptions options;
+       if(JSValueIsNull(context, convertedArg[3]) || JSValueIsUndefined(context, convertedArg[3]))
+       {
+               LOGD("%s - 4th argument (ReverseGeocodeOptions) is NULL or Undefined", __func__);
+       }
+       else
+       {
+               if(!JSValueIsObject(context, convertedArg[3]))
+               {
+                       if(userdata)
+                               delete userdata;
+                       return Commons::JSTizenExceptionFactory::postException(context, exception, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The 4th  argument must be converted to ReverseGeocodeOptions");
+               }
+               else if(!ReverseGeocodeOptions::convert(context, convertedArgObjects[3], &options, exception))
+               {
+                       if(userdata)
+                               delete userdata;
+                       return JSValueMakeUndefined(context);
+               }
+               else
+               {
+                       LOGD("%s - 4th argument (ReverseGeocodeOptions) is valid", __func__);
+               }
+       }
+
+       // Check the AbstarctCoordinates
+       double latitude = LBSUtil::getPropertyToDouble(context, convertedArgObjects[0], "latitude");
+       double longitude = LBSUtil::getPropertyToDouble(context, convertedArgObjects[0], "longitude");
+       int ret = priv->reverseGeocode(latitude, longitude, options, __reverseGeocodeResultArrayCallback, userdata);
+
+       // Error, Should delete callback data
+       if (ret != 0 )
+       {
+               if(userdata->onSuccess)
+                       JSValueUnprotect(context, userdata->onSuccess);
+               if (userdata->onFail)
+               {
+                       LOGD("%s - Throw ErrorCB (%d)", __func__, ret);
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), __convertErrorCode(ret), "Fail to reverseGeocode()");
+                       JSValueRef args[1] = {error};
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+                       JSValueUnprotect(context, userdata->onFail);
+               }
+               else
+               {
+                       LOGD("%s - Consume the error : There is no error callback (%d) ", __func__, ret);
+               }
+
+               if(userdata)
+                       delete userdata;
+       }
+       return JSValueMakeUndefined(context);
+}
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Geocoder/JSGeocoderProvider.h b/src/standards/Tizen/Geocoder/JSGeocoderProvider.h
new file mode 100755 (executable)
index 0000000..8a1c10d
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef __WRTPLUGINS_TIZEN_JS_GEOCODER_PROVIDER__
+#define __WRTPLUGINS_TIZEN_JS_GEOCODER_PROVIDER__
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeocoderProvider
+{
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+
+public:
+       static JSContextRef m_globalContextRef; 
+
+protected:
+       static void initialize(JSContextRef context, JSObjectRef object);
+       static void finalize(JSObjectRef object);
+       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+       static JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+       static JSValueRef geocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+       static JSValueRef reverseGeocode(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+public:
+       static const JSClassDefinition* getClassInfo();
+       static const JSClassRef getClassRef();
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //__WRTPLUGINS_TIZEN_JS_GEOCODER_PROVIDER__
diff --git a/src/standards/Tizen/Geocoder/JSGeocoderServiceManager.cpp b/src/standards/Tizen/Geocoder/JSGeocoderServiceManager.cpp
new file mode 100755 (executable)
index 0000000..c77f8e6
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSGeocoderServiceManager.h"
+#include "JSGeocoderProvider.h"
+#include "DefaultGeocoderProvider.h"
+#include "GeocoderACE.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSContextRef JSGeocoderServiceManager::m_globalContextRef = NULL;
+
+JSValueRef JSGeocoderServiceManager::m_defaultObj = NULL;
+
+JSClassRef JSGeocoderServiceManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeocoderServiceManager::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "Geocoder",                                                                                                             // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       JSGeocoderServiceManager::m_function,           // static functions
+       JSGeocoderServiceManager::initialize,                   // initialize
+       JSGeocoderServiceManager::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL, //call as function
+       NULL, //call as constructor
+       JSGeocoderServiceManager::hasInstance,
+       NULL
+};
+
+JSStaticFunction JSGeocoderServiceManager::m_function[] = {
+        { "getDefaultProvider",JSGeocoderServiceManager::getDefaultProvider,kJSPropertyAttributeNone },
+        { "getProviders",JSGeocoderServiceManager::getProviders,kJSPropertyAttributeNone },
+               { 0, 0, 0 }
+};
+
+const JSClassRef JSGeocoderServiceManager::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeocoderServiceManager::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSGeocoderServiceManager::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+       LOGD("%s - JSGeocoderServiceManager", __func__);
+       if( JSGeocoderServiceManager::m_globalContextRef == NULL )
+       {
+               JSGeocoderServiceManager::m_globalContextRef = ctx;
+       }
+}
+
+void JSGeocoderServiceManager::finalize(JSObjectRef object) 
+{
+       LOGD("%s - JSGeocoderServiceManager", __func__);
+       if( JSGeocoderServiceManager::m_defaultObj != NULL )
+       {
+               JSValueUnprotect(JSGeocoderServiceManager::m_globalContextRef, JSGeocoderServiceManager::m_defaultObj);
+       JSGeocoderServiceManager::m_defaultObj = NULL;
+       }
+}
+
+bool JSGeocoderServiceManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSGeocoderServiceManager::getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       AceSecurityStatus status = GEOCODER_CHECK_ACCESS(GEOCODER_FUNCTION_CATEGORY_BASIC);
+       
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       if( JSGeocoderServiceManager::m_defaultObj == NULL){
+               GeocoderProvider *geocoder = new DefaultGeocoderProvider();             
+               JSGeocoderServiceManager::m_defaultObj  = JSObjectMake(context , JSGeocoderProvider::getClassRef() , geocoder);
+               JSValueProtect(context, JSGeocoderServiceManager::m_defaultObj);
+       }
+       return JSGeocoderServiceManager::m_defaultObj;
+}
+
+JSValueRef JSGeocoderServiceManager::getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       AceSecurityStatus status = GEOCODER_CHECK_ACCESS(GEOCODER_FUNCTION_CATEGORY_BASIC);
+       
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+       
+       JSValueRef providers[1];
+       JSObjectRef array;
+       providers[0] = getDefaultProvider(context ,object, thisObject, argumentCount, arguments, exception);
+       array = JSObjectMakeArray( context, 1, providers, NULL);
+       return array;   
+}
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/Geocoder/JSGeocoderServiceManager.h b/src/standards/Tizen/Geocoder/JSGeocoderServiceManager.h
new file mode 100755 (executable)
index 0000000..a096862
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef __WRTPLUGINS_TIZEN_JS_GEOCODER_SERVICE_MANAGER__
+#define __WRTPLUGINS_TIZEN_JS_GEOCODER_SERVICE_MANAGER__
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeocoderServiceManager 
+{
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+       
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSValueRef getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+       static JSContextRef m_globalContextRef;
+       static JSValueRef m_defaultObj;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //__WRTPLUGINS_TIZEN_JS_GEOCODER_SERVICE_MANAGER__
+
diff --git a/src/standards/Tizen/Geocoder/ReverseGeocodeOptions.cpp b/src/standards/Tizen/Geocoder/ReverseGeocodeOptions.cpp
new file mode 100755 (executable)
index 0000000..a788541
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <limits>
+#include <dlog.h>
+#include "ReverseGeocodeOptions.h"
+#include "LBSUtil.h"
+#include "JSSortMode.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_W_GEOCODER"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+ReverseGeocodeOptions::ReverseGeocodeOptions()
+{
+       addressType = AddressType::FORMATTED;
+       sortOrder = SortOrder::ASC;
+       maxResult = 0;
+}
+
+bool ReverseGeocodeOptions::convert(JSContextRef ctx, JSObjectRef object, ReverseGeocodeOptions* options, JSValueRef* exception)
+{
+       LOGD("%s - start",__func__);
+       if(options == NULL)
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "ReverseGeocodeOptions is NULL");
+               return false;
+       }
+       
+       //convert "resultType"
+       std::string addrType = LBSUtil::getPropertyToString(ctx, object, "resultType"); 
+        if( addrType == "STRUCTURED" )
+               options->addressType = AddressType::STRUCTURED;
+        else //  addrType == "FORMATTED"  (default)
+               options->addressType = AddressType::FORMATTED;
+
+       //convert "sortMode"
+       JSValueRef sortModeValue = LBSUtil::getPropertyToValueRef(ctx, object, "sortMode");
+       if( JSValueIsObjectOfClass(ctx, sortModeValue, TizenApis::Tizen1_0::Tizen::JSSortMode::getClassRef()))
+       {
+               JSObjectRef sortModeObject = JSValueToObject(ctx, sortModeValue , NULL);
+               options->sortAttributeName = LBSUtil::getPropertyToString(ctx, sortModeObject, "attributeName");
+               std::string order = LBSUtil::getPropertyToString(ctx, sortModeObject, "order");
+               if( order == "ASC" )
+                       options->sortOrder = SortOrder::ASC;
+               else if( order == "DESC" )
+                       options->sortOrder = SortOrder::DESC;
+       }
+       else if( !JSValueIsNull(ctx, sortModeValue) && !JSValueIsUndefined(ctx, sortModeValue))
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "sortMode is not SortMode object");
+               return false;
+       }
+
+       //convert "maxResults"
+       JSValueRef maxResultsValue = LBSUtil::getPropertyToValueRef(ctx, object, "maxResults");
+       double maxresult = JSValueToNumber(ctx, maxResultsValue , NULL);
+       if( maxresult != std::numeric_limits<double>::quiet_NaN())
+               options->maxResult = maxresult;
+       else
+       {
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "maxResults is not number");
+               return false;
+       }
+       return true;
+}
+
+}//LSB
+}// Tizen1_0
+}// TizenApis
+
similarity index 52%
rename from src/platform/API/Call/EventLaunchDialer.cpp
rename to src/standards/Tizen/Geocoder/ReverseGeocodeOptions.h
index 18c66da..c1d0dde 100755 (executable)
  */
 
  
-#include "EventLaunchDialer.h"
+#ifndef __WRTPLUGINS_TIZEN_REVERSE_GEOCODE_OPTIONS__
+#define __WRTPLUGINS_TIZEN_REVERSE_GEOCODE_OPTIONS__
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
 
 namespace TizenApis {
-namespace Api {
-namespace Call {
-EventLaunchDialer::EventLaunchDialer()
-{
-}
+namespace Tizen1_0 {
+namespace LBS{
 
-void EventLaunchDialer::setRemoteParty(const std::string remoteParty)
-{
-       m_remoteParty = remoteParty;
-}
 
-void EventLaunchDialer::setExtension(const std::string extension)
+class ReverseGeocodeOptions
 {
-       m_extension = extension;
-}
+public:
+       enum AddressType { STRUCTURED , FORMATTED };
+       enum SortOrder { ASC , DESC };
 
-void EventLaunchDialer::setAppId(const std::string appId)
-{
-       m_appId = appId;
-}
+       AddressType addressType;
+       std::string sortAttributeName;
+       SortOrder sortOrder;
+       unsigned int maxResult;
 
-std::string EventLaunchDialer::getRemoteParty() const
-{
-       return m_remoteParty;
-}
-
-std::string EventLaunchDialer::getExtension() const
-{
-       return m_extension;
-}
-
-std::string EventLaunchDialer::getAppId() const
-{
-       return m_appId;
-}
+       ReverseGeocodeOptions();
+       static bool convert(JSContextRef ctx, JSObjectRef object, ReverseGeocodeOptions *options, JSValueRef* exception);
+};
 
 }
 }
 }
+
+#endif //__WRTPLUGINS_TIZEN_REVERSE_GEOCODE_OPTIONS__
old mode 100644 (file)
new mode 100755 (executable)
index b3b6a29..5cc2dc4
@@ -1,19 +1,15 @@
 <?xml version="1.0" ?>
 <!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
 <plugin-properties>
-    <library-name>libwrt-plugins-tizen-1.0-geocoder.so</library-name>
-    <feature-install-uri>geocoder.install.uri</feature-install-uri>
-    <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
-    <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
-    <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+       <library-name>libwrt-plugins-tizen-1.0-geocoder.so</library-name>
+       <feature-install-uri>geocoder.install.uri</feature-install-uri>
+       <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+       <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+       <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
 
-    <api-feature>
-        <name>http://tizen.org/api/geocoder</name>
-
-        <device-capability>geocoder</device-capability>
-        <Object name="geocoder">
-            <Function name="geocode"/>
-            <Function name="reverseGeocode"/>
-        </Object>
-    </api-feature>
+       <api-feature>
+               <name>http://tizen.org/api/geocoder</name>
+               <device-capability>geocoder</device-capability>
+       </api-feature>
 </plugin-properties>
+
diff --git a/src/standards/Tizen/Geocoder/plugin_config.cpp b/src/standards/Tizen/Geocoder/plugin_config.cpp
deleted file mode 100755 (executable)
index efceb97..0000000
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-#include <Commons/FunctionDefinition.h>
-#include "plugin_config.h"
-
-#define GEOCODER_FEATURE_API "http://tizen.org/api/geocoder"
-#define GEOCODER_DEVICE_CAP_GEOCODER "geocoder"
-
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
-
-namespace TizenApis {
-       namespace Tizen1_0 {
-
-               const char* GEOCODER_FUNCTION_API_GEOCODE = "geocode";
-               const char* GEOCODER_FUNCTION_API_REVERSE_GEOCODE = "reverseGeocode";
-
-               static Commons::FunctionMapping createGeocoderFunctions();
-
-               static Commons::FunctionMapping GeocoderFunctions = createGeocoderFunctions();
-
-               DEFINE_FUNCTION_GETTER(Geocoder, GeocoderFunctions)
-               ;
-
-               static Commons::FunctionMapping createGeocoderFunctions() {
-                       /**
-                        * Device capabilities
-                        */
-                       ACE_CREATE_DEVICE_CAP(DEVICE_CAP_GEOCODER, GEOCODER_DEVICE_CAP_GEOCODER);
-                       ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
-                       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_GEOCODER);
-                       ACE_ADD_DEVICE_CAP(DEVICE_LIST_GEOCODER, DEVICE_CAP_GEOCODER);
-
-                       /**
-                        * Api Features
-                        */
-                       ACE_CREATE_FEATURE(FEATURE_GEOCODER, GEOCODER_FEATURE_API);
-                       ACE_CREATE_FEATURE_LIST(GEOCODER_FEATURES_GEOCODER);
-                       ACE_ADD_API_FEATURE(GEOCODER_FEATURES_GEOCODER, FEATURE_GEOCODER);
-
-                       /**
-                        * Functions
-                        */
-                       FunctionMapping geocoderMapping;
-
-                       //geocode
-                       AceFunction geocodeFunc = ACE_CREATE_FUNCTION(
-                                       FUNCTION_GEOCODE,
-                                       GEOCODER_FUNCTION_API_GEOCODE,
-                                       GEOCODER_FEATURES_GEOCODER,
-                                       DEVICE_LIST_GEOCODER);
-
-                       geocoderMapping.insert(std::make_pair(GEOCODER_FUNCTION_API_GEOCODE, geocodeFunc));
-
-                       //reverseGeocode
-                       AceFunction reverseGeocodeFunc = ACE_CREATE_FUNCTION(
-                                       FUNCTION_REVERSE_GEOCODE,
-                                       GEOCODER_FUNCTION_API_REVERSE_GEOCODE,
-                                       GEOCODER_FEATURES_GEOCODER,
-                                       EMPTY_DEVICE_LIST);
-
-                       geocoderMapping.insert(std::make_pair(GEOCODER_FUNCTION_API_REVERSE_GEOCODE, reverseGeocodeFunc));
-
-                       return geocoderMapping;
-               }
-
-       } // namespace Tizen1_0
-} // namespace WrtPlugins
old mode 100644 (file)
new mode 100755 (executable)
index 8db9a30..7860b81
  */
 
 
-
-
-#include <dpl/log/log.h>
+#include <dlog.h>
 #include <Commons/plugin_initializer_def.h>
-#include "JSGeocoder.h"
-
-#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
-
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
-       LogDebug("[Tizen\\Geocoder] on_widget_start_callback ("<<widgetId<<")");
+#include <Commons/WrtAccess/WrtAccess.h>
+#include "JSGeocoderServiceManager.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId) 
+{
+       LOGD("on Geocoder widget start callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess initialization failed");
+    }
 }
 
-void on_widget_stop_callback(int widgetId) {
-       LogDebug("[Tizen\\Geocoder] on_widget_stop_callback ("<<widgetId<<")");
+void on_widget_stop_callback(int widgetId) 
+{
+    LOGD("on Geocoder widget stop callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
 PLUGIN_CLASS_MAP_BEGIN
-       PLUGIN_CLASS_MAP_ADD_CLASS(
-               WRT_JS_EXTENSION_OBJECT_TIZEN,
-               "geocoder",
-               TizenApis::Tizen1_0::JSGeocoder::getClassRef(),
-               NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN".lbs", "geocoder",
+      TizenApis::Tizen1_0::LBS::JSGeocoderServiceManager::getClassRef(),NULL)
 PLUGIN_CLASS_MAP_END
+
diff --git a/src/standards/Tizen/LBS/CMakeLists.txt b/src/standards/Tizen/LBS/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..f97e4c8
--- /dev/null
@@ -0,0 +1,47 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-lbs")
+set(DESTINATION_NAME "tizen-1.0-lbs")
+set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-lbs-impl")
+
+pkg_search_module(lbs REQUIRED dlog wrt-plugins-plugin-manager)
+
+include_directories(${lbs_INCLUDE_DIRS})
+
+set(CMAKE_INSTALL_RPATH
+  ${CMAKE_INSTALL_RPATH}
+  ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+)
+
+set(SRCS_IMPL
+  GeoAddress.cpp
+  LBSUtil.cpp
+  LBS.cpp
+  JSLBS.cpp
+  JSLocationServiceProvider.cpp
+  JSLBSPending.cpp
+  LBSPending.cpp  
+  LBSAce.cpp
+)
+
+
+add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+
+target_link_libraries(${TARGET_IMPL_NAME}
+  wrt-plugins-tizen-1.0-tizen-impl
+  ${LIBS_COMMON}
+  ${lbs_LIBRARIES}  
+)
+
+set(SRCS
+  plugin_initializer.cpp
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  ${TARGET_IMPL_NAME}
+)
+
+
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
+
old mode 100644 (file)
new mode 100755 (executable)
similarity index 61%
rename from src/platform/API/Geocoder/GeocoderFactory.h
rename to src/standards/Tizen/LBS/ConvertibleJSObject.h
index bd425e6..a0bd20e
  * limitations under the License. 
  */
 
+#ifndef _WRTPLUGINS_TIZEN_CONVERTIBLEJSOBJECT_
+#define _WRTPLUGINS_TIZEN_CONVERTIBLEJSOBJECT_
 
-
-
-
-/*
- * @author
- */
-
-#ifndef WRTPLUGINS_API_GEOCODERFACTORY_H_
-#define WRTPLUGINS_API_GEOCODERFACTORY_H_
-
-#include <dpl/noncopyable.h>
-#include "IGeocoder.h"
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
 
 namespace TizenApis {
-namespace Tizen1_0{
-namespace Api {
-namespace Geocoder {
+namespace Tizen1_0 {
+namespace LBS{
 
-class GeocoderFactory: DPL::Noncopyable {
+/**
+ * This inferface is able to convert to JSObjectRef
+*/
+class ConvertibleJSObject {
 public:
-       IGeocoderPtr getGeocoder();
+       virtual JSObjectRef toJSObject(JSContextRef context)=0;
+};
 
-       static GeocoderFactory& getInstance();
+} // LBS
+} // Tizen1_0
+} // TizenApis
 
-protected:
-       GeocoderFactory();
-};
+#endif // _WRTPLUGINS_TIZEN_CONVERTIBLEJSOBJECT_
 
-}
-}
-}
-}
 
-#endif //WRTPLUGINS_API_GEOCODERFACTORY_H_
diff --git a/src/standards/Tizen/LBS/GeoAddress.cpp b/src/standards/Tizen/LBS/GeoAddress.cpp
new file mode 100755 (executable)
index 0000000..2c77f68
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "GeoAddress.h"
+#include "LBSUtil.h"
+#include <dlog.h>
+#include <sstream>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSObjectRef GeoAddress::toJSObject(JSContextRef context)
+{
+        JSObjectRef obj = JSObjectMake(context, NULL, NULL);
+       LBSUtil::setProperty(context , obj, "country" , country,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "region" , region,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "county" , county,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "city" , city,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "street" , street,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "streetNumber" , streetNumber,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "premises" , premises,  kJSPropertyAttributeNone );
+       LBSUtil::setProperty(context , obj, "postalCode" , postalCode,  kJSPropertyAttributeNone );
+       return obj;
+}
+       
+
+GeoAddress GeoAddress::convert(JSContextRef ctx, JSObjectRef object){
+       GeoAddress address; 
+       convert(ctx,object, &address); 
+       return address;
+}
+
+void GeoAddress::convert(JSContextRef ctx, JSObjectRef object, GeoAddress *address){
+       if(address == NULL )
+               return;
+       if( object == NULL )
+               return;
+
+       JSValueRef vCountry = LBSUtil::getPropertyToValueRef(ctx, object, "country");
+       JSValueRef vRegion = LBSUtil::getPropertyToValueRef(ctx, object, "region");
+       JSValueRef vCounty = LBSUtil::getPropertyToValueRef(ctx, object, "county");
+       JSValueRef vCity = LBSUtil::getPropertyToValueRef(ctx, object, "city");
+       JSValueRef vStreet = LBSUtil::getPropertyToValueRef(ctx, object, "street");
+       JSValueRef vStreetNumber = LBSUtil::getPropertyToValueRef(ctx, object, "streetNumber");
+       JSValueRef vPremises = LBSUtil::getPropertyToValueRef(ctx, object, "premises");
+       JSValueRef vPostalCode = LBSUtil::getPropertyToValueRef(ctx, object, "postalCode");
+
+       if( !JSValueIsNull(ctx, vCountry ) && !JSValueIsUndefined(ctx, vCountry ) )
+               address->country = LBSUtil::getPropertyToString(ctx, object, "country");
+       if( !JSValueIsNull(ctx, vRegion ) && !JSValueIsUndefined(ctx, vRegion ) )
+               address->region = LBSUtil::getPropertyToString(ctx, object, "region");
+       if( !JSValueIsNull(ctx, vCounty ) && !JSValueIsUndefined(ctx, vCounty ) )
+               address->county = LBSUtil::getPropertyToString(ctx, object, "county");
+       if( !JSValueIsNull(ctx, vCity ) && !JSValueIsUndefined(ctx, vCity ) )
+               address->city = LBSUtil::getPropertyToString(ctx, object, "city");
+       if( !JSValueIsNull(ctx, vStreet ) && !JSValueIsUndefined(ctx, vStreet ) )
+               address->street = LBSUtil::getPropertyToString(ctx, object, "street");
+       if( !JSValueIsNull(ctx, vStreetNumber ) && !JSValueIsUndefined(ctx, vStreetNumber ) )
+               address->streetNumber = LBSUtil::getPropertyToString(ctx, object, "streetNumber");
+       if( !JSValueIsNull(ctx, vPremises ) && !JSValueIsUndefined(ctx, vPremises ) )
+               address->premises = LBSUtil::getPropertyToString(ctx, object, "premises");
+       if( !JSValueIsNull(ctx, vPostalCode ) && !JSValueIsUndefined(ctx, vPostalCode ) )
+               address->postalCode = LBSUtil::getPropertyToString(ctx, object, "postalCode");
+       
+}
+
+std::string GeoAddress::toSimpleAddress(){
+       std::stringstream simpleaddr;
+       if( postalCode != ""  ){
+               simpleaddr << postalCode;
+               simpleaddr << " ";
+       }
+       if( premises != "" ){
+               simpleaddr << premises;
+               simpleaddr << " ";
+       }
+       if( streetNumber != "" ){
+               simpleaddr << streetNumber;
+               simpleaddr << " ";
+       }
+       if( street != "" ){
+               simpleaddr << street;
+               simpleaddr << " ";
+       }
+       if( city != "" ){
+               simpleaddr << city;
+               simpleaddr << " ";
+       }
+       if( county != "" ){
+               simpleaddr << county;
+               simpleaddr << " ";
+       }
+       if( region != "" ){
+               simpleaddr << region;
+               simpleaddr << " ";
+       }
+       if( country != "" ){
+               simpleaddr << country;
+       }
+       return simpleaddr.str();
+}
+
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/LBS/GeoAddress.h b/src/standards/Tizen/LBS/GeoAddress.h
new file mode 100755 (executable)
index 0000000..461fb92
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_GEOADDRESS_
+#define _WRTPLUGINS_TIZEN_GEOADDRESS_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+       
+class GeoAddress : public ConvertibleJSObject{
+public:
+       std::string country;
+       std::string region;
+       std::string county;
+       std::string city;
+       std::string street;
+       std::string streetNumber;
+       std::string premises;
+       std::string postalCode;
+
+       std::string toSimpleAddress();
+       virtual JSObjectRef toJSObject(JSContextRef context);
+
+
+       static GeoAddress convert(JSContextRef ctx, JSObjectRef object);
+       static void convert(JSContextRef ctx, JSObjectRef object, GeoAddress *address);
+
+
+       
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_GEOADDRESS_
\ No newline at end of file
diff --git a/src/standards/Tizen/LBS/JSLBS.cpp b/src/standards/Tizen/LBS/JSLBS.cpp
new file mode 100755 (executable)
index 0000000..c12bde6
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <PluginManager/IPluginManager.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include <WidgetDB/WidgetDBMgr.h>
+#include <WidgetDB/IWidgetDB.h>
+#include <PluginManager/PluginManagerFactory.h>
+#include <dlog.h>
+#include "LBS.h"
+
+
+#include "JSLBS.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace std;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::PluginManager::Api;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSContextRef JSLBS::m_globalContextRef = NULL;
+JSClassRef JSLBS::m_jsClassRef = NULL;
+
+JSClassDefinition JSLBS::m_jsClassInfo = {
+       0,
+       kJSClassAttributeNone,
+       "LBS",
+       NULL,
+       m_properties,
+       NULL,
+       initialize,
+       finalize,
+    hasProperty,
+    getProperty,
+    setProperty,
+       NULL, //deleteProperty
+       getPropertyNames, //getPropertyNames
+       NULL,
+       NULL, // constructor
+       hasInstance,
+       NULL
+};
+
+JSStaticValue JSLBS::m_properties[] = {
+    { 0, 0, 0 }
+};
+
+const JSClassRef JSLBS::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSLBS::getClassInfo() 
+{
+       LOGE("%s", __func__);
+       return &m_jsClassInfo;
+}
+
+JSContextRef JSLBS::getGlobalContext()
+{
+       return JSLBS::m_globalContextRef;
+}
+
+void JSLBS::initialize(JSContextRef ctx, JSObjectRef object)
+{
+       LOGE("%s", __func__);
+       JSLBS::m_globalContextRef = ctx;
+
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
+       LBS *priv = new LBS(PluginManagerFactory::getInstance().getPluginManager(widgetId, "tizen.lbs", object, ctx));
+       JSObjectSetPrivate(object, priv);
+}
+
+void JSLBS::finalize(JSObjectRef object)
+{
+       LOGE("%s", __func__);
+
+       LBS *priv = (LBS*)JSObjectGetPrivate(object);
+       if( priv )
+               delete priv;
+}
+
+
+
+bool JSLBS::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       LOGE("%s", __func__);
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+bool JSLBS::hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName)
+{
+       LOGE("%s", __func__);
+       LBS *priv = (LBS*)JSObjectGetPrivate(object);
+       return priv->getPluginManager()->hasChild(CommonsJavaScript::Converter(context).toString(propertyName));
+}
+
+JSValueRef JSLBS::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
+{
+       LOGE("%s", __func__);
+       LBS *priv = (LBS*)JSObjectGetPrivate(object);
+       return priv->getPluginManager()->getProperty(CommonsJavaScript::Converter(context).toString(propertyName));
+}
+
+bool JSLBS::setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
+{
+    LOGE("%s", __func__);
+       LBS *priv = (LBS*)JSObjectGetPrivate(object);
+       return priv->getPluginManager()->setProperty(CommonsJavaScript::Converter(context).toString(propertyName),value);
+}
+
+void JSLBS::getPropertyNames(JSContextRef context, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
+{
+       LOGE("%s", __func__);
+       LBS *priv = (LBS*)JSObjectGetPrivate(object);
+       priv->getPluginManager()->addPropertiesToList(propertyNames);
+}
+
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/LBS/JSLBS.h b/src/standards/Tizen/LBS/JSLBS.h
new file mode 100755 (executable)
index 0000000..29f8de0
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_LBS_
+#define _WRTPLUGINS_TIZEN_JS_LBS_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSLBS {
+public:
+       static const JSClassDefinition* getClassInfo();
+       static const JSClassRef getClassRef();
+       static JSContextRef getGlobalContext();
+
+
+protected:
+       static void initialize(JSContextRef context, JSObjectRef object);
+       static void finalize(JSObjectRef object);       
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+private:
+
+    static bool hasProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName);
+    static JSValueRef getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+    static bool setProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
+    static void getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames);
+
+    static JSStaticValue m_properties[];
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+       static JSContextRef m_globalContextRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif // _WRTPLUGINS_TIZEN_JS_LBS_
+
diff --git a/src/standards/Tizen/LBS/JSLBSPending.cpp b/src/standards/Tizen/LBS/JSLBSPending.cpp
new file mode 100755 (executable)
index 0000000..c983467
--- /dev/null
@@ -0,0 +1,125 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License. \r
+ */\r
\r
+#include <CommonsJavaScript/Converter.h>\r
+#include <CommonsJavaScript/Validator.h>\r
+#include <CommonsJavaScript/JSUtils.h>\r
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>\r
+#include <PluginManager/IPluginManager.h>\r
+#include <Commons/WrtAccess/WrtAccess.h>\r
+#include <WidgetDB/WidgetDBMgr.h>\r
+#include <WidgetDB/IWidgetDB.h>\r
+#include <PluginManager/PluginManagerFactory.h>\r
+#include <dlog.h>\r
+\r
+#include "JSLBSPending.h"\r
+#include "LBSPending.h"\r
+#include "LBSUtil.h"\r
+\r
+#include <dlog.h>\r
+\r
+#undef LOG_TAG\r
+#define LOG_TAG "TIZEN_LBS"\r
+\r
+using namespace std;\r
+using namespace WrtDeviceApis;\r
+using namespace WrtDeviceApis::Commons;\r
+using namespace WrtDeviceApis::PluginManager::Api;\r
+\r
+namespace TizenApis {\r
+namespace Tizen1_0 {\r
+namespace LBS {\r
+\r
+JSClassRef JSLBSPending::m_jsClassRef = NULL;\r
+\r
+JSClassDefinition JSLBSPending::m_jsClassInfo = {\r
+       0,\r
+       kJSClassAttributeNone,\r
+       "PendingOperation",\r
+       NULL,\r
+       NULL,\r
+       m_function,\r
+       initialize,\r
+       finalize,\r
+       NULL,\r
+       NULL,\r
+       NULL,\r
+       NULL, //deleteProperty\r
+       NULL, //getPropertyNames\r
+       NULL,\r
+       NULL, // constructor\r
+       hasInstance,\r
+       NULL\r
+};\r
+\r
+\r
+JSStaticFunction JSLBSPending::m_function[] = {\r
+       { "cancel",JSLBSPending::cancel,kJSPropertyAttributeNone },\r
+       { 0, 0, 0 }\r
+};\r
+\r
+\r
+const JSClassRef JSLBSPending::getClassRef() \r
+{\r
+       if (!m_jsClassRef) {\r
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);\r
+       }\r
+       return m_jsClassRef;\r
+}\r
+\r
+const JSClassDefinition* JSLBSPending::getClassInfo() \r
+{\r
+       return &m_jsClassInfo;\r
+}\r
+\r
+void JSLBSPending::initialize(JSContextRef ctx, JSObjectRef object)\r
+{\r
+}\r
+\r
+void JSLBSPending::finalize(JSObjectRef object)\r
+{\r
+       LBSPending * priv = reinterpret_cast<LBSPending*>(JSObjectGetPrivate(object));\r
+       if( priv ){\r
+               delete priv;\r
+       }\r
+}\r
+\r
+JSValueRef JSLBSPending::cancel(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)\r
+{\r
+       bool ret = false;\r
+       LBSPending * priv = reinterpret_cast<LBSPending*>(JSObjectGetPrivate(thisObject));\r
+       if( priv ){\r
+               ret = priv->cancel();\r
+       }\r
+       return JSValueMakeBoolean(ctx, ret);\r
+}\r
+\r
+bool JSLBSPending::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)\r
+{\r
+       LOGE("%s", __func__);\r
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());\r
+}\r
+\r
+JSObjectRef JSLBSPending::makePending(JSContextRef context, LBSPending *pending){\r
+        JSObjectRef obj = JSObjectMake(context, getClassRef(), pending);\r
+       return obj;\r
+}\r
+\r
+\r
+} //LBS\r
+} // Tizen1_0\r
+} // TizenApis\r
+\r
diff --git a/src/standards/Tizen/LBS/JSLBSPending.h b/src/standards/Tizen/LBS/JSLBSPending.h
new file mode 100755 (executable)
index 0000000..7851df4
--- /dev/null
@@ -0,0 +1,51 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License. \r
+ */\r
+\r
\r
+#ifndef _WRTPLUGINS_TIZEN_JS_LBSPENDING_\r
+#define _WRTPLUGINS_TIZEN_JS_LBSPENDING_\r
+\r
+#include <string>\r
+#include <JavaScriptCore/JavaScript.h>\r
+\r
+namespace TizenApis {\r
+namespace Tizen1_0 {\r
+namespace LBS{\r
+\r
+class LBSPending;\r
+class JSLBSPending {\r
+public:\r
+       static const JSClassDefinition* getClassInfo();\r
+       static const JSClassRef getClassRef();\r
+       static JSObjectRef makePending(JSContextRef context, LBSPending *pending);\r
+protected:\r
+       static void initialize(JSContextRef context, JSObjectRef object);\r
+       static void finalize(JSObjectRef object);       \r
+       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);\r
+       static JSValueRef cancel(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);\r
+\r
+private:\r
+       static JSClassDefinition m_jsClassInfo;\r
+       static JSClassRef m_jsClassRef;\r
+       static JSStaticFunction m_function[];\r
+};\r
+\r
+} // LBS\r
+} // Tizen1_0\r
+} // TizenApis\r
+\r
+#endif // _WRTPLUGINS_TIZEN_JS_LBSPENDING_\r
+\r
diff --git a/src/standards/Tizen/LBS/JSLocationServiceProvider.cpp b/src/standards/Tizen/LBS/JSLocationServiceProvider.cpp
new file mode 100755 (executable)
index 0000000..d04d14b
--- /dev/null
@@ -0,0 +1,281 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include "JSLocationServiceProvider.h"
+#include "LocationServiceProvider.h"
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "LBSAce.h"
+#include "LBSUtil.h"
+#include "JSLBSPending.h"
+#include "JSLBS.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+struct CallbackData {
+       JSObjectRef onSuccess;
+       JSObjectRef onFail;
+};
+
+JSContextRef JSLocationServiceProvider::m_globalContextRef = NULL;
+JSClassRef JSLocationServiceProvider::m_jsClassRef = NULL;
+
+JSClassDefinition JSLocationServiceProvider::m_jsClassInfo = {
+       0,
+       kJSClassAttributeNone,
+       "LocationServiceProvider",
+       NULL,
+       NULL,
+       m_function,
+       initialize,
+       finalize,
+       NULL, //hasProperty
+       JSLocationServiceProvider::getProperty, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       NULL, // constructor
+       hasInstance,
+       NULL
+};
+
+
+JSStaticFunction JSLocationServiceProvider::m_function[] = {
+        { "setOptions",JSLocationServiceProvider::setOptions,kJSPropertyAttributeNone },
+               { 0, 0, 0 }
+};
+
+const JSClassRef JSLocationServiceProvider::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSLocationServiceProvider::getClassInfo()
+{
+       return &m_jsClassInfo;
+}
+
+void JSLocationServiceProvider::initialize(JSContextRef ctx, JSObjectRef object)
+{
+       if( JSLocationServiceProvider::m_globalContextRef == NULL ){
+               JSLocationServiceProvider::m_globalContextRef = ctx;
+       }
+}
+
+void JSLocationServiceProvider::finalize(JSObjectRef object)
+{
+       LocationServiceProvider * priv = reinterpret_cast<LocationServiceProvider*>(JSObjectGetPrivate(object));
+       if( priv ){
+               delete priv;
+               JSObjectSetPrivate(object, NULL);
+       }
+}
+
+bool JSLocationServiceProvider::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSLocationServiceProvider::getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
+
+       LocationServiceProvider * priv = reinterpret_cast<LocationServiceProvider*>(JSObjectGetPrivate(object));
+       if( priv == NULL)
+               return NULL;
+
+       if(JSStringIsEqualToUTF8CString(propertyName, "name")) {
+               JSStringRef name = JSStringCreateWithUTF8CString(priv->getName().c_str());
+               JSValueRef jsv = JSValueMakeString(ctx, name);
+               JSStringRelease(name);
+               return jsv;
+       }
+       else if(JSStringIsEqualToUTF8CString(propertyName, "metaData")) {
+               std::vector<std::pair<std::string, std::string>> options = priv->getMetadata();
+               JSObjectRef metaobject = JSObjectMake(ctx, NULL, NULL);
+               std::vector<std::pair<std::string, std::string>>::iterator pos;
+               for( pos = options.begin() ; pos != options.end(); ++pos){
+                       JSStringRef key = JSStringCreateWithUTF8CString(pos->first.c_str());
+                       JSStringRef value = JSStringCreateWithUTF8CString(pos->second.c_str());
+                       JSValueRef valueRef = JSValueMakeString(ctx, value);
+                       JSObjectSetProperty(ctx, metaobject , key , valueRef ,kJSPropertyAttributeReadOnly, NULL );
+                       JSStringRelease(key);
+                       JSStringRelease(value);
+               }               
+               return metaobject;
+       }
+       else if(JSStringIsEqualToUTF8CString(propertyName, "attribution")) {
+               JSStringRef attr = JSStringCreateWithUTF8CString(priv->getAttribution().c_str());
+               JSValueRef jsv = JSValueMakeString(ctx, attr);
+               JSStringRelease(attr);
+               return jsv;
+       }
+       else if(JSStringIsEqualToUTF8CString(propertyName, "supportedOptions")) {
+               std::vector<std::string> supportedOptionVector = priv->getSupportedOptions();
+               JSValueRef* supportedOptionValues = NULL;
+               supportedOptionValues = new JSValueRef[supportedOptionVector.size()];
+               for( unsigned int i=0 ; i < supportedOptionVector.size(); i++){
+                       JSStringRef optionString =  JSStringCreateWithUTF8CString( supportedOptionVector[i].c_str());
+                       supportedOptionValues[i] = JSValueMakeString(ctx, optionString);
+                       JSStringRelease(optionString);
+               }
+               JSObjectRef supportedOptionArray = JSObjectMakeArray(ctx, supportedOptionVector.size(), supportedOptionValues, NULL);
+               delete []supportedOptionValues;
+               return supportedOptionArray;
+       }
+       else if(JSStringIsEqualToUTF8CString(propertyName, "connectivity")) {           
+               JSStringRef conn = JSStringCreateWithUTF8CString(priv->getConnectivity().c_str());
+               JSValueRef jsv = JSValueMakeString(ctx, conn);
+               JSStringRelease(conn);
+               return jsv;
+       }
+
+       return NULL;
+}
+
+void _setOptionCb(int result , void * user_data){
+
+       CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+       if ( userdata == NULL)
+               return;
+
+       if( result == 0 && userdata->onSuccess ){
+               JSValueRef args[1] = {NULL};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onSuccess , NULL, 1, args, NULL);
+       }
+       else if( result != 0 && userdata->onFail ){
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), Commons::JSTizenException::INVALID_VALUES_ERROR , "Fail setOption");
+               JSValueRef args[1] = {error};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+       }
+
+       if( userdata->onSuccess )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onSuccess);
+       if( userdata->onFail )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onFail);
+
+       delete userdata;
+}
+
+JSValueRef JSLocationServiceProvider::setOptions(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+
+       // Check the access control
+       AceSecurityStatus status = LBS_CHECK_ACCESS(LBS_FUNCTION_CATEGORY_SERVICE_PROVIDER);
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       // Check the object type
+       LocationServiceProvider * priv = reinterpret_cast<LocationServiceProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL){
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The object is not LocationServiceProvider instance");
+       }
+
+       JSValueRef convertedArguments[3];
+       JSObjectRef convertedArgumentObjects[3];
+       for( unsigned int i = 0 ; i < 3; i++ ){
+               if( i < argumentCount ){
+                       convertedArguments[i] = arguments[i];
+                       if( JSValueIsObject(ctx, arguments[i]) )
+                               convertedArgumentObjects[i] = JSValueToObject(ctx, arguments[i] , NULL );
+                       else
+                               convertedArgumentObjects[i] = NULL;
+               }else{
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+                       convertedArgumentObjects[i] = NULL;
+               }
+       }
+
+       // The second argument is null or undefined or function object
+       if(  !JSValueIsNull(ctx, convertedArguments[1]) &&
+                 !JSValueIsUndefined(ctx, convertedArguments[1]) &&
+                 ( convertedArgumentObjects[1] == NULL || !JSObjectIsFunction(ctx, convertedArgumentObjects[1]) )
+         )
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument must be function or null");
+
+       // The third argument is null or undefined or function object
+       if(  !JSValueIsNull(ctx, convertedArguments[2]) &&
+                 !JSValueIsUndefined(ctx, convertedArguments[2]) &&
+                 ( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(ctx, convertedArgumentObjects[2]))
+          )
+               return Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument must be function or null");
+
+       // The first argument is option object
+       JSObjectRef jsOptions = convertedArgumentObjects[0];
+       if( jsOptions == NULL ){
+               return Commons::JSTizenExceptionFactory::postException(ctx, exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The option arguments is not Object");
+       }
+
+       // Initialize a CallbackData
+       CallbackData * userdata = NULL;
+
+       JSObjectRef onsuccess = convertedArgumentObjects[1];
+       JSObjectRef onfail = convertedArgumentObjects[2];
+       if( onsuccess != NULL || onfail != NULL ){
+               userdata = new CallbackData();
+               userdata->onSuccess = NULL;
+               userdata->onFail = NULL;
+
+               if( onsuccess ){
+                       userdata->onSuccess = onsuccess;
+                       JSValueProtect(ctx, onsuccess);
+               }
+               if( onfail ){
+                       userdata->onFail = onfail;
+                       JSValueProtect(ctx, onfail);
+               }
+       }
+
+       // Convert  Object to vector
+       std::vector<std::pair<std::string, std::string>> options = LBSUtil::convertObject(ctx, jsOptions);      
+
+       // Call native setOption function
+       int ret = priv->setOption(options , _setOptionCb , userdata, NULL);
+
+       // Invalid options values
+       if( ret != 0 ){
+               //remove callback values
+               if( userdata != NULL ){
+                       if( userdata->onSuccess )
+                               JSValueUnprotect(ctx, userdata->onSuccess);
+                       if( userdata->onFail )
+                               JSValueUnprotect(ctx, userdata->onFail);
+                       delete userdata;
+               }
+
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), Commons::JSTizenException::INVALID_VALUES_ERROR , "invalid option value");
+               JSValueRef args[1] = {error};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext(), onfail  , NULL, 1, args, NULL);
+       }
+
+       return JSValueMakeUndefined(ctx);
+}
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/LBS/JSLocationServiceProvider.h b/src/standards/Tizen/LBS/JSLocationServiceProvider.h
new file mode 100755 (executable)
index 0000000..72b2ca2
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_LOCATIONSERVICE_PROVIDER_
+#define _WRTPLUGINS_TIZEN_JS_LOCATIONSERVICE_PROVIDER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSLocationServiceProvider {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+       static void initialize(JSContextRef context, JSObjectRef object);
+       static void finalize(JSObjectRef object);
+       static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+       static JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+       static JSValueRef setOptions(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+               
+
+private:
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+    static JSStaticFunction m_function[];
+    static JSContextRef m_globalContextRef;
+               
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif // _WRTPLUGINS_TIZEN_JS_LOCATIONSERVICE_PROVIDER_
+
similarity index 65%
rename from src/platform/API/Call/ICallService.cpp
rename to src/standards/Tizen/LBS/LBS.cpp
index af337d7..8dbde30 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
-#include "ICallService.h"
+#include "LBS.h"
 
 namespace TizenApis {
-namespace Api {
-namespace Call {
+namespace Tizen1_0 {
+namespace LBS {
 
-using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::PluginManager::Api;
 
-ICallService::ICallService() : 
-       EventRequestReceiver<EventLaunchDialer>(ThreadEnum::TELEPHONY_THREAD),
-       EventRequestReceiver<EventSendUSSD>(ThreadEnum::TELEPHONY_THREAD)
+LBS::LBS(const IPluginManagerPtr &pluginManager) :
+    m_pluginManager(pluginManager)
 {
 }
 
-ICallService::~ICallService()
+LBS::~LBS()
 {
 }
 
+IPluginManagerPtr LBS::getPluginManager() const
+{
+    return m_pluginManager;
+}
+
 }
 }
 }
+
similarity index 56%
rename from src/platform/API/Calendar/CalendarItemGeo.cpp
rename to src/standards/Tizen/LBS/LBS.h
index e05e69b..4f9f730 100755 (executable)
  */
 
 
-#include "CalendarItemGeo.h"
+#ifndef _WRTPLUGINS_TIZEN_LBS_
+#define _WRTPLUGINS_TIZEN_LBS_
+
+#include <dpl/shared_ptr.h>
+#include <JavaScriptCore/JavaScript.h>
+#include <PluginManager/IPluginManager.h>
 
 namespace TizenApis {
-namespace Api {
-namespace Calendar {
+namespace Tizen1_0 {
+namespace LBS {
 
-CalendarItemGeo::CalendarItemGeo()
+class LBS
 {
-    m_latitude = GEO_UNDEFINED;
-    m_longitude = GEO_UNDEFINED;
-}
+public:
+       LBS(const WrtDeviceApis::PluginManager::Api::IPluginManagerPtr &pluginManager);
+       virtual ~LBS();
+       WrtDeviceApis::PluginManager::Api::IPluginManagerPtr getPluginManager() const;
 
-CalendarItemGeo::~CalendarItemGeo()
-{
-}
+private:
+       WrtDeviceApis::PluginManager::Api::IPluginManagerPtr m_pluginManager;
 
-double CalendarItemGeo::getLatitude() const
-{
-    return m_latitude;
-}
+};
 
-void CalendarItemGeo::setLatitude(const double &value)
-{
-    m_latitude = value;
 }
-
-double CalendarItemGeo::getLongitude() const
-{
-    return m_longitude;
 }
-
-void CalendarItemGeo::setLongitude(const double &value)
-{
-    m_longitude = value;
 }
 
-}
-}
-}
+#endif //_WRTPLUGINS_TIZEN_LBS_
+
diff --git a/src/standards/Tizen/LBS/LBSAce.cpp b/src/standards/Tizen/LBS/LBSAce.cpp
new file mode 100755 (executable)
index 0000000..f58d350
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <iostream>
+#include <vector>
+#include "LBSAce.h"
+
+#define FEATURE_POI_ALL "http://tizen.org/api/lbs.poi"
+#define FEATURE_POI_READ "http://tizen.org/api/lbs.poi.read"
+#define FEATURE_POI_WRITE "http://tizen.org/api/lbs.poi.write"
+#define FEATURE_ROTUE "http://tizen.org/api/lbs.route"
+#define FEATURE_MAP "http://tizen.org/api/lbs.map"
+#define FEATURE_GEOCODER "http://tizen.org/api/lbs.geocoder"
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+static AceFunction __create_lbs_service_provider_function();
+
+static AceFunction lbs_service_provider_function = __create_lbs_service_provider_function();
+
+static AceFunction __create_lbs_service_provider_function(){
+       AceFeature lbs_feature_poi_all(FEATURE_POI_ALL);
+       AceFeature lbs_feature_poi_read(FEATURE_POI_READ);
+       AceFeature lbs_feature_poi_write(FEATURE_POI_WRITE);
+       AceFeature lbs_feature_route(FEATURE_ROTUE);
+       AceFeature lbs_feature_map(FEATURE_MAP);
+       AceFeature lbs_feature_geocoder(FEATURE_GEOCODER);
+       AceDeviceCaps empty_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(lbs_feature_poi_all);
+       executable_feature_list.push_back(lbs_feature_poi_read);
+       executable_feature_list.push_back(lbs_feature_poi_write);
+       executable_feature_list.push_back(lbs_feature_route);
+       executable_feature_list.push_back(lbs_feature_map);
+       executable_feature_list.push_back(lbs_feature_geocoder);        
+       
+       return {LBS_FUNCTION_CATEGORY_SERVICE_PROVIDER , executable_feature_list, empty_device_caps };
+}
+
+AceFunction getLBSFunctionData(const std::string & functionId){
+       if( functionId == LBS_FUNCTION_CATEGORY_SERVICE_PROVIDER ){
+               return lbs_service_provider_function; 
+       }
+       return AceFunction();
+}
+       
+} //LBS
+} // Tizen1_0
+} //TizenApis
+
diff --git a/src/standards/Tizen/LBS/LBSAce.h b/src/standards/Tizen/LBS/LBSAce.h
new file mode 100755 (executable)
index 0000000..daca2ce
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _WRTPLUGINS_TIZEN_LBSACE_
+#define _WRTPLUGINS_TIZEN_LBSACE_
+
+#include <string>
+#include <Commons/FunctionDeclaration.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+#define LBS_FUNCTION_CATEGORY_SERVICE_PROVIDER "LocationServiceProvier"
+
+
+WrtDeviceApis::Commons::AceFunction getLBSFunctionData(const std::string & functionId);
+
+#define LBS_CHECK_ACCESS(functionName)                     \
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
+        getLBSFunctionData,           \
+        functionName)
+
+} // LBS
+} // Tizen1_0
+} // Tizen
+
+#endif // _WRTPLUGINS_TIZEN_LBSACE_
diff --git a/src/standards/Tizen/LBS/LBSConverter.h b/src/standards/Tizen/LBS/LBSConverter.h
new file mode 100755 (executable)
index 0000000..2b68c3d
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_LBSCONVERTER_
+#define _WRTPLUGINS_TIZEN_LBSCONVERTER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/Converter.h>
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class LBSConverter : public WrtDeviceApis::CommonsJavaScript::Converter
+{
+public:
+       explicit LBSConverter(JSContextRef context):WrtDeviceApis::CommonsJavaScript::Converter(context){};
+
+       std::vector<double> toVectorDouble(const JSValueRef& arg){
+           return toVectorOfT_(arg, &WrtDeviceApis::CommonsJavaScript::Converter::toDouble);
+       };
+
+       JSValueRef toJSValueRef(const std::vector<double>& arg){
+           return toJSValueRef_(arg);
+       };
+
+};
+
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif // _WRTPLUGINS_TIZEN_LBSCONVERTER_
+
diff --git a/src/standards/Tizen/LBS/LBSPending.cpp b/src/standards/Tizen/LBS/LBSPending.cpp
new file mode 100755 (executable)
index 0000000..7706f71
--- /dev/null
@@ -0,0 +1,44 @@
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+#include "LBSPending.h"\r
+\r
+namespace TizenApis {\r
+namespace Tizen1_0 {\r
+namespace LBS {\r
+\r
+LBSPending::LBSPending(cancel_cb callback , int id, void *user_data){\r
+       this->user_data = user_data;\r
+       this->callback = callback;\r
+       this->id = id;\r
+}\r
+\r
+LBSPending::~LBSPending()\r
+{\r
+}\r
+\r
+bool LBSPending::cancel(){\r
+       if( callback ){\r
+               return callback(id, user_data);\r
+       }\r
+       return false;\r
+}\r
+\r
+\r
+}\r
+}\r
+}\r
+\r
similarity index 57%
rename from src/platform/API/Account/AccountFilter.cpp
rename to src/standards/Tizen/LBS/LBSPending.h
index 2198f84..37f5f83 100755 (executable)
@@ -1,56 +1,48 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-#include "AccountFilter.h"
-#include <dpl/log/log.h>
-
-/**
- * @file        AccountFilter.cpp
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-namespace TizenApis {
-namespace Api {
-namespace Account {
-
-AccountFilter::AccountFilter()
-{
-}
-
-AccountFilter::~AccountFilter()
-{
-}
-
-std::string AccountFilter::getIdFilter() const
-{
-    return *m_id;
-}
-
-void AccountFilter::setIdFilter(const std::string &value)
-{
-    m_id = value;
-}
-
-bool AccountFilter::getIdIsSet() const
-{
-    return !m_id.IsNull();
-}
-}
-}
-}
-
+/*\r
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the License);\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an AS IS BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+\r
+#ifndef _WRTPLUGINS_TIZEN_LBSPENDING_\r
+#define _WRTPLUGINS_TIZEN_LBSPENDING_\r
+\r
+\r
+namespace TizenApis {\r
+namespace Tizen1_0 {\r
+namespace LBS {\r
+\r
+typedef bool (* cancel_cb)( int id, void * user_data );\r
+\r
+\r
+class LBSPending\r
+{\r
+public:\r
+       LBSPending(cancel_cb cb , int id , void *user_data);\r
+       virtual ~LBSPending();\r
+       bool cancel();  \r
+\r
+private:\r
+       int id;\r
+       void *user_data;\r
+       cancel_cb callback;\r
+\r
+};\r
+\r
+}\r
+}\r
+}\r
+\r
+#endif //_WRTPLUGINS_TIZEN_LBSPENDING_\r
+\r
diff --git a/src/standards/Tizen/LBS/LBSUtil.cpp b/src/standards/Tizen/LBS/LBSUtil.cpp
new file mode 100755 (executable)
index 0000000..cb75bd8
--- /dev/null
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <CommonsJavaScript/Converter.h>
+#include "LBSUtil.h"
+#include "LBSConverter.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSValueRef LBSUtil::getPropertyToValueRef(JSContextRef ctx , JSObjectRef object, const char *name){
+       JSValueRef value;
+       JSStringRef propertyName = JSStringCreateWithUTF8CString(name);
+       value = JSObjectGetProperty(ctx, object, propertyName, NULL);
+       JSStringRelease(propertyName);
+       return value;
+}
+
+string LBSUtil::getPropertyToString(JSContextRef ctx , JSObjectRef object, const char *name){
+       JSValueRef value = getPropertyToValueRef(ctx, object, name);
+       JSStringRef valueString = JSValueToStringCopy(ctx, value, NULL);
+       if( valueString == NULL)
+               return "";
+
+       int count = JSStringGetMaximumUTF8CStringSize(valueString);
+       string stdString;
+       {
+               char strBuffer[count];
+               JSStringGetUTF8CString(valueString, strBuffer, count);
+               stdString = strBuffer;
+       }
+       
+       JSStringRelease(valueString);
+       return stdString;
+}
+
+double LBSUtil::getPropertyToDouble(JSContextRef ctx , JSObjectRef object, const char *name){
+       JSValueRef value = getPropertyToValueRef(ctx, object, name);
+       double v = JSValueToNumber(ctx, value, NULL);
+       return v;
+}
+
+
+void LBSUtil::setProperty(JSContextRef ctx , JSObjectRef object, const char *name, JSValueRef value, JSPropertyAttributes attributes)
+{
+       JSStringRef propertyName = JSStringCreateWithUTF8CString(name);
+       JSObjectSetProperty(ctx, object, propertyName, value,attributes, NULL );
+       JSStringRelease(propertyName);
+}
+
+void LBSUtil::setProperty(JSContextRef ctx , JSObjectRef object, const char *name, std::string value, JSPropertyAttributes attributes)
+{
+       Converter convert(ctx);
+       JSStringRef propertyName = JSStringCreateWithUTF8CString(name);
+       if(value.size() > 0)
+               JSObjectSetProperty(ctx, object, propertyName, convert.toJSValueRef(value),attributes, NULL );
+       else
+               JSObjectSetProperty(ctx, object, propertyName, JSValueMakeNull(ctx),attributes, NULL );
+       JSStringRelease(propertyName);
+}
+
+void LBSUtil::setProperty(JSContextRef ctx , JSObjectRef object, const char *name, double value, JSPropertyAttributes attributes)
+{
+       Converter convert(ctx);
+       JSStringRef propertyName = JSStringCreateWithUTF8CString(name);
+       JSObjectSetProperty(ctx, object, propertyName, convert.toJSValueRef(value),attributes, NULL );
+       JSStringRelease(propertyName);
+}
+
+void LBSUtil::setProperty(JSContextRef ctx , JSObjectRef object, const char *name, ConvertibleJSObject& value, JSPropertyAttributes attributes)
+{
+       JSObjectRef objValue = value.toJSObject(ctx);
+       JSStringRef propertyName = JSStringCreateWithUTF8CString(name);
+       JSObjectSetProperty(ctx, object, propertyName, objValue ,attributes, NULL );
+       JSStringRelease(propertyName);
+}
+
+vector<pair<string, string>> LBSUtil::convertObject(JSContextRef ctx , JSObjectRef object)
+{
+       LBSConverter convert(ctx);
+       std::vector<std::pair<std::string, std::string>> converted;
+       JSPropertyNameArrayRef jsPropertyNames = JSObjectCopyPropertyNames(ctx, object);
+
+       int pCount = JSPropertyNameArrayGetCount(jsPropertyNames );
+
+       for( int i = 0 ; i < pCount ; i++){
+               JSStringRef key = JSPropertyNameArrayGetNameAtIndex(jsPropertyNames, i );
+               string keyStr = convert.toString(key);
+               string valueStr = LBSUtil::getPropertyToString(ctx , object, keyStr.c_str());
+               converted.push_back(std::make_pair(keyStr, valueStr));
+       }
+       JSPropertyNameArrayRelease(jsPropertyNames);
+       return converted;
+}
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/LBS/LBSUtil.h b/src/standards/Tizen/LBS/LBSUtil.h
new file mode 100755 (executable)
index 0000000..b8bad18
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_LBSUTIL_
+#define _WRTPLUGINS_TIZEN_JS_LBSUTIL_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class LBSUtil 
+{
+       
+public:        
+       static JSValueRef getPropertyToValueRef(JSContextRef ctx , JSObjectRef object, const char *name);
+       static std::string getPropertyToString(JSContextRef ctx , JSObjectRef object, const char *name);
+       static double getPropertyToDouble(JSContextRef ctx , JSObjectRef object, const char *name);     
+       static void setProperty(JSContextRef ctx , JSObjectRef object, const char *name, JSValueRef value, JSPropertyAttributes attributes);
+       static void setProperty(JSContextRef ctx , JSObjectRef object, const char *name, std::string value, JSPropertyAttributes attributes);   
+       static void setProperty(JSContextRef ctx , JSObjectRef object, const char *name, double value, JSPropertyAttributes attributes);                
+       static void setProperty(JSContextRef ctx , JSObjectRef object, const char *name, ConvertibleJSObject& value, JSPropertyAttributes attributes);          
+       static std::vector<std::pair<std::string, std::string>> convertObject(JSContextRef ctx , JSObjectRef object);
+};// LBSUtil
+
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif // _WRTPLUGINS_TIZEN_JS_LBSUTIL_
diff --git a/src/standards/Tizen/LBS/LocationServiceProvider.h b/src/standards/Tizen/LBS/LocationServiceProvider.h
new file mode 100755 (executable)
index 0000000..07bea73
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_LOCATIONSERVICEPROVIDER_
+#define _WRTPLUGINS_TIZEN_LOCATIONSERVICEPROVIDER_
+
+#include <string>
+#include <vector>
+#include <utility>
+#include <JavaScriptCore/JavaScript.h>
+#include "LBSPending.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+typedef void (* setOptionCb )(int result , void * user_data);
+
+class LocationServiceProvider {
+       public:
+               virtual ~LocationServiceProvider(){}
+               virtual std::string getName() = 0;
+               virtual std::string getAttribution()=0;
+               virtual std::vector<std::pair<std::string, std::string>> getMetadata()=0;
+               virtual std::vector<std::string> getSupportedOptions()=0;
+               virtual std::string getConnectivity()=0;
+               virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)=0;
+               virtual bool isUsedExternalNetwork()=0;
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_LOCATIONSERVICEPROVIDER_
diff --git a/src/standards/Tizen/LBS/config.xml b/src/standards/Tizen/LBS/config.xml
new file mode 100755 (executable)
index 0000000..1cf4109
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+       <library-name>libwrt-plugins-tizen-1.0-lbs.so</library-name>
+       <feature-install-uri>lbs.install.uri</feature-install-uri>
+       <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+       <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+       <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+
+       <api-feature>
+               <name>http://tizen.org/api/lbs</name>
+               <device-capability>lbs</device-capability>
+       </api-feature>
+</plugin-properties>
diff --git a/src/standards/Tizen/LBS/plugin_initializer.cpp b/src/standards/Tizen/LBS/plugin_initializer.cpp
new file mode 100755 (executable)
index 0000000..895c450
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#define LOG_TAG "TIZEN_LBS"
+
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include <dlog.h>
+#include "JSLBS.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId) {
+       LOGD("on LBS widget start callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess initialization failed");
+    }
+}
+
+void on_widget_stop_callback(int widgetId) {
+    LOGD("on LBS widget stop callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess deinitialization failed");
+    }
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "lbs", 
+      TizenApis::Tizen1_0::LBS::JSLBS::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_END
+
index 0eafde3..d015694 100644 (file)
@@ -11,7 +11,7 @@
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 #include <dpl/log/log.h>
@@ -20,7 +20,7 @@
 
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[TizenLog] on_widget_start_callback ("<<widgetId<<")");
 }
index 32bb344..45a88a0 100644 (file)
@@ -110,7 +110,12 @@ void JSAudio::finalize(JSObjectRef object)
 {
     LogDebug( "entered" );
        AudioPrivObject *priv =  static_cast<AudioPrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+       if (priv != NULL)
+       {
+               delete (priv);
+               priv = NULL;
+               JSObjectSetPrivate(object, NULL);               
+       }
 }
 
 const JSClassRef JSAudio::getClassRef()
index c487f11..981f12d 100644 (file)
@@ -106,7 +106,13 @@ void JSFolder::finalize(JSObjectRef object)
 {
     LogDebug( "entered" );
     FolderPrivObject *priv = static_cast<FolderPrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+       if (priv != NULL)
+       {
+               delete (priv);
+               priv = NULL;
+               JSObjectSetPrivate(object, NULL);               
+       }
+
 }
 
 
index 6443119..0043ad2 100644 (file)
@@ -92,9 +92,13 @@ void JSImage::initialize(JSContextRef context, JSObjectRef object)
 void JSImage::finalize(JSObjectRef object)
 {
     LogDebug( "entered" );
-       ImagePrivObject *priv =
-        static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+       ImagePrivObject *priv = static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) ) ;
+       if (priv != NULL)
+       {
+               delete (priv);
+               priv = NULL;
+               JSObjectSetPrivate(object, NULL);               
+       }
 }
 
 const JSClassRef JSImage::getClassRef()
index 85befab..630a848 100644 (file)
@@ -42,7 +42,7 @@ namespace Mediacontent {
 #define TIZEN_MEDIACONTENT_MEDIA_DESCRIPTION           "description"   
 #define TIZEN_MEDIACONTENT_MEDIA_RATING                                "rating"        
 #define TIZEN_MEDIACONTENT_MEDIA_SIZE                          "size"  
-#define TIZEN_MEDIACONTENT_MEDIA_EDIABLEATTR           "editableAttibutes"     
+#define TIZEN_MEDIACONTENT_MEDIA_EDIABLEATTR           "editableAttributes"    
 
 
 
@@ -110,7 +110,13 @@ void JSMedia::finalize(JSObjectRef object)
 {
     LogDebug( "entered" );
     MediaPrivObject *priv = static_cast<MediaPrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+       if (priv != NULL)
+       {
+               delete (priv);
+               priv = NULL;
+               JSObjectSetPrivate(object, NULL);
+       }
+    
 }
 
 const JSClassRef JSMedia::getClassRef()
@@ -445,7 +451,19 @@ bool       JSMedia::setPropertyFavorite(
         MediacontentMediaPtr event = getMediaObject(object);
            int rating = converter.toInt(value);
 
-           LogDebug("value : " << rating);
+           LogDebug("Inserted value : " << rating);
+
+               if(rating < 0)
+               {
+                       rating = 0;
+               LogDebug("Rating value set 0 as inserted value is too small");
+               }
+               else if(rating > 10)
+               {
+                       rating = 10;
+               LogDebug("Rating value set 10 as inserted value is too big");
+               }
+
         event->setFavorite(rating);
         return true;
     }
index 2700603..770b9de 100644 (file)
@@ -30,14 +30,9 @@ namespace Mediacontent {
 
 #define TIZEN_MEDIACONTENT_MEDIA_LYRICS                "MediaLyrics"
 #define TIZEN_MEDIACONTENT_LYRICS_TYPE         "type"
-#define TIZEN_MEDIACONTENT_LYRICS_TIMESTAMP "timeStamps"
+#define TIZEN_MEDIACONTENT_LYRICS_TIMESTAMP "timestamps"
 #define TIZEN_MEDIACONTENT_LYRICS_TEXT         "texts"
 
-
-
-
-
-
 JSClassDefinition JSMediaLyrics::m_classInfo =
 {
     0,
index 3829db3..5ebcb25 100644 (file)
@@ -22,6 +22,9 @@
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSPendingOperation.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
 
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "JSMediacontent.h"
 #include "JSMediacontentManager.h"
 #include "JSMedia.h"
+#include "JSImage.h"
+#include "JSVideo.h"
+#include "JSAudio.h"
 #include "MediaConverter.h"
 #include "plugin_config.h"
 
-
-
-
 using namespace TizenApis::Commons;
 using namespace TizenApis::Api::Tizen;
 using namespace TizenApis::Tizen1_0::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
 
 
 #define TIZEN_MEDIACONTENT_ATTRIBUTENAME       "MediaSource"
@@ -97,9 +102,8 @@ JSStaticValue JSMediacontent::m_property[] =
 
 JSStaticFunction JSMediacontent::m_function[] =
 {
-    { "findItems", findMedia, kJSPropertyAttributeNone },
+    { "findItems", findItems, kJSPropertyAttributeNone },
     { "getFolders", getFolders, kJSPropertyAttributeNone },
-    { "browseFolder", browseFolder, kJSPropertyAttributeNone },    
     { "updateItem", updateItem, kJSPropertyAttributeNone },        
     { "updateItemsBatch", updateItemsBatch, kJSPropertyAttributeNone },            
     { 0, 0, 0 }
@@ -133,7 +137,13 @@ void JSMediacontent::finalize(JSObjectRef object)
 {
     LogDebug("entered");
     MediacontentPrivObject *priv = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+    if(priv != NULL)
+    {
+               delete priv;
+               priv = NULL;
+               LogDebug("JSMediacontent::finalize entered");
+    }
+
 }
 
 const JSClassRef JSMediacontent::getClassRef()
@@ -150,104 +160,6 @@ const JSClassDefinition* JSMediacontent::getClassInfo()
     return &m_classInfo;
 }
 
-
-JSValueRef JSMediacontent::findMedia(
-                                                       JSContextRef context,
-                                                       JSObjectRef object,
-                                                       JSObjectRef thisObject,
-                                                       size_t argumentCount,
-                                                       const JSValueRef arguments[],
-                                                       JSValueRef* exception )
-{
-    LogDebug("JSMediacontent::findMedia entered");
-
-    MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
-    assert(privateObject);
-
-       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(privateObject->getContext(), MEDIACONTENT_FUNCTION_API_FIND_ITEMS);
-
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-    
-       JSContextRef globalContext = privateObject->getContext();
-       
-       Validator validator(context);
-    JSCallbackManagerPtr cbm(NULL);
-    FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
-       MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
-       cbm = JSCallbackManager::createObject(globalContext);
-
-       IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
-
-    Try
-    {
-        if (argumentCount == 0 ||
-            (!validator.isCallback(arguments[0])) ||
-            (argumentCount >= 2 && (!validator.isCallback(arguments[1]))) )
-        {
-            LogDebug("Argument type mismatch");
-            Throw(InvalidArgumentException);
-        }
-        if (cbm) 
-        {
-            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-            onSuccessForCbm = arguments[0];
-            if (argumentCount >= 2) 
-            {
-                onErrorForCbm = arguments[1];
-            }
-            cbm->setOnSuccess(onSuccessForCbm);
-            cbm->setOnError(onErrorForCbm);
-               }
-
-       
-               IEventFindMediaPtr dplEvent(new IEventFindMedia());
-               dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
-               dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
-               
-        if (argumentCount >= 3 && !validator.isNullOrUndefined(arguments[2]))
-        {
-            dplEvent->setFilter(filterConverter->toFilter(arguments[2]));
-        }
-               if (argumentCount >= 4 && !validator.isNullOrUndefined(arguments[3])) 
-               {
-            // Though the sortMode is a single type, we save it in an array internally.
-            TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
-            sortModes->push_back(filterConverter->toSortMode(arguments[3]));
-            dplEvent->setSortModes(sortModes);
-
-               }
-               if (argumentCount >= 5 && !validator.isNullOrUndefined(arguments[4])) 
-               {
-                       long limit = filterConverter->toLong(arguments[4]);
-                       dplEvent->setLimit(limit);
-               }
-               if (argumentCount >= 6 && !validator.isNullOrUndefined(arguments[5])) 
-               {
-                       long offset = filterConverter->toLong(arguments[5]);
-                       dplEvent->setOffset(offset);
-               }               
-
-               mediacontent->findMedia(dplEvent);
-               
-       }
-       Catch(InvalidArgumentException)
-       {
-               return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-       }
-       Catch(ConversionException)
-       {
-               return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
-       }
-       Catch(Exception)
-       {
-               return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-       }
-       
-       return JSValueMakeNull(context);
-
-}
-
-
 JSValueRef JSMediacontent::getFolders(
                                                        JSContextRef context, 
                                                        JSObjectRef object,
@@ -259,15 +171,19 @@ JSValueRef JSMediacontent::getFolders(
 
        LogDebug("JSMediacontent::findFolders entered");
 
-    MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
-    assert(privateObject);
-
+       MediacontentPrivObject *privateObject;
+       
+       privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+       if (!privateObject)
+       {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
 
-       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(privateObject->getContext(), MEDIACONTENT_FUNCTION_API_GET_FOLDERS);
+       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
+            MEDIACONTENT_FUNCTION_API_GET_FOLDERS);
 
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-
        JSContextRef globalContext = privateObject->getContext();
        Validator validator(context);
     JSCallbackManagerPtr cbm(NULL);
@@ -276,60 +192,88 @@ JSValueRef JSMediacontent::getFolders(
 
        cbm = JSCallbackManager::createObject(globalContext);
 
-       IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+       // Protect the super object until the callback operation is finished.
+       JSValueProtect(globalContext, thisObject);
 
     Try
     {
+               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
 
-        if ((!validator.isCallback(arguments[0])) ||
-            (argumentCount >= 2 && (!validator.isCallback(arguments[1]))) ||
-            (argumentCount >= 3 && (!JSValueIsObject(context, arguments[2]) && !validator.isNullOrUndefined(arguments[2])))) 
-               {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
+               JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-        if (cbm) 
-        {
-            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-            onSuccessForCbm = arguments[0];
-            if (argumentCount >= 2) 
-            {
-                onErrorForCbm = arguments[1];
-            }
-                       if (argumentCount >= 3) 
-            {
-                               onErrorForCbm = arguments[2];
-            }
-            cbm->setOnSuccess(onSuccessForCbm);
-            cbm->setOnError(onErrorForCbm);
+               if(argumentCount >= 1)  //MediaFolderArraySuccessCB successCallback
+               {
+                       if(validator.isCallback(arguments[0]))
+                       {
+                               onSuccessForCbm = arguments[0];
+                       }
+                       else
+                       {
+                               LogDebug("SuccessCallback type mismatched.");
+                               Throw(ConversionException);
+                       }
+               }
+               else
+               {
+                       LogDebug("There is no successCallback.");
+                       Throw(ConversionException);
+               }               
+               if(argumentCount >= 2)  //optional ErrorCallback? errorCallback
+               {       
+                       if(validator.isCallback(arguments[1]))
+                       {
+                               onErrorForCbm = arguments[1];
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[1]))             //nullable
+                       {
+                               LogDebug("ErrorCallback type mismatched.");
+                               Throw(ConversionException);                             
+                       }
+               }
+               if(cbm)
+               {
+                       cbm->setOnSuccess(onSuccessForCbm);
+                       cbm->setOnError(onErrorForCbm);
                }
 
         IEventFindFolderPtr dplEvent(new IEventFindFolder());
         dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
         dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
 
-
         mediacontent->findFolder(dplEvent);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 
 }
 
 
-JSValueRef JSMediacontent::browseFolder(
+JSValueRef JSMediacontent::findItems(
                                                        JSContextRef context, 
                                                        JSObjectRef object,
                                                        JSObjectRef thisObject, 
@@ -338,14 +282,19 @@ JSValueRef JSMediacontent::browseFolder(
                                                        JSValueRef* exception )
 {
 
-       LogDebug("JSMediacontent::browseFolder entered");
-
-    MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
-    assert(privateObject);
+       LogDebug("JSMediacontent::findItems entered");
 
+       MediacontentPrivObject *privateObject;
+       
+       privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+       if (!privateObject)
+       {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
 
 
-       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(privateObject->getContext(), MEDIACONTENT_FUNCTION_API_BROWSE_FOLDER);
+       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
+            MEDIACONTENT_FUNCTION_API_FIND_ITEMS);
 
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
@@ -359,76 +308,144 @@ JSValueRef JSMediacontent::browseFolder(
 
        cbm = JSCallbackManager::createObject(globalContext);
 
-       IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+       // Protect the super object until the callback operation is finished.
+       JSValueProtect(globalContext, thisObject);
 
     Try
     {
+               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+               IEventBrowseFolderPtr dplEvent(new IEventBrowseFolder());
+       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-        if (argumentCount == 0 ||
-            (!validator.isCallback(arguments[1])) ||
-            (argumentCount >= 3 && (!validator.isCallback(arguments[2]))) ||
-            (argumentCount >= 4 && (!JSValueIsObject(context, arguments[3]) )) )
-        {
-            LogDebug("Argument type mismatch");
-            Throw(InvalidArgumentException);
-        }
-
-        if (cbm) 
-        {
-            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-            onSuccessForCbm = arguments[1];
-            if (argumentCount >= 3) 
-            {
-                onErrorForCbm = arguments[2];
-            }
-            cbm->setOnSuccess(onSuccessForCbm);
-            cbm->setOnError(onErrorForCbm);
+               if(argumentCount >= 1)  //MediaItemArraySuccessCB successCallback
+               {
+                       if(validator.isCallback(arguments[0]))
+                       {
+                               onSuccessForCbm = arguments[0];
+                       }
+                       else
+                       {
+                               LogDebug("SuccessCallback type mismatched.");
+                               Throw(ConversionException);
+                       }
                }
-
-        IEventBrowseFolderPtr dplEvent(new IEventBrowseFolder());
-        dplEvent->setFolderID(mediaConverter.toString(arguments[0]));
-        dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
-        dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
-
-        if (argumentCount >= 4 && !validator.isNullOrUndefined(arguments[3]))
-        {
-            dplEvent->setFilter(filterConverter->toFilter(arguments[3]));
-        }
-               if (argumentCount >= 5 && !validator.isNullOrUndefined(arguments[4])) 
+               else
                {
-            TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
-            sortModes->push_back(filterConverter->toSortMode(arguments[3]));
-            dplEvent->setSortModes(sortModes);
-
+                       LogDebug("There is no SuccessCallback.");
+                       Throw(ConversionException);
+               }  
+               if(argumentCount >= 2)  //ErrorCallback? errorCallback
+               {       
+                       if(validator.isCallback(arguments[1]))
+                       {
+                               onErrorForCbm = arguments[1];
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[1]))             //nullable
+                       {
+                               LogDebug("ErrorCallback type mismatched.");
+                               Throw(ConversionException);                             
+                       }
                }
-               if (argumentCount >= 6 && !validator.isNullOrUndefined(arguments[5])) 
+               if(cbm)
+               {
+                       cbm->setOnSuccess(onSuccessForCbm);
+                       cbm->setOnError(onErrorForCbm);
+               }
+
+               if(argumentCount >= 3)  //MediaFolderId id,
+               {
+                       string folderId = mediaConverter.toString(arguments[2]);
+                       if(!(validator.isNullOrUndefined(arguments[2])) && (folderId.length() > 0)  )
+                       {
+                               LogDebug("folderId:"+ folderId);
+                               dplEvent->setFolderID(folderId);
+                       }
+               }               
+               
+               if(argumentCount >= 4)  //optional AbstractFilter? filter
                {
-                       long limit = filterConverter->toLong(arguments[5]);
-                       dplEvent->setLimit(limit);
+                       if(JSValueIsObject(context, arguments[3]))
+                       {
+                               dplEvent->setFilter(filterConverter->toFilter(arguments[3]));
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[3]))             //nullable
+                       {
+                               LogDebug("Filter type mismatched.");
+                               Throw(ConversionException);
+                       }
                }
-               if (argumentCount >= 7 && !validator.isNullOrUndefined(arguments[6])) 
+               if(argumentCount >= 5)  //optional SortMode? sortMode
                {
-                       long offset = filterConverter->toLong(arguments[6]);
-                       dplEvent->setOffset(offset);
+                       if(JSValueIsObject(context, arguments[4]))
+                       {
+                               LogDebug("sortmode is object");
+                               // Though the sortMode is a single type, we save it in an array internally.
+                               TizenApis::Api::Tizen::SortModeArrayPtr sortModes(new TizenApis::Api::Tizen::SortModeArray());
+                               sortModes->push_back(filterConverter->toSortMode(arguments[4]));
+                               dplEvent->setSortModes(sortModes);
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[4]))             //nullable
+                       {
+                               LogDebug("SortMode type mismatched.");
+                               Throw(ConversionException);
+                       }
                }               
+               if(argumentCount >= 6)  //optional unsigned long? count
+               {
+                       long count = filterConverter->toLong(arguments[5]);
+                       if(count != 0.0)
+                       {
+                               dplEvent->setLimit(count);
+                       }
+                       else
+                       {
+                               dplEvent->setLimit(-1);
+                       }
 
+               }               
+               if(argumentCount >= 7)  //optional unsigned long? offset
+               {
+                       long limit = filterConverter->toLong(arguments[6]);
+                       if(limit != 0.0)
+                       {
+                               dplEvent->setLimit(limit);
+                       }
+                       else
+                       {
+                               dplEvent->setLimit(-1);
+                       }
+               }               
+        dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
+        dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
         mediacontent->browseFolder(dplEvent);
     }
+    Catch(UnsupportedException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
     Catch(InvalidArgumentException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(ConversionException)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch (NotFoundException)
+    {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
     }
     Catch(Exception)
     {
-        return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
-
+    return JSValueMakeUndefined(context);
 }
 
 
@@ -442,11 +459,17 @@ JSValueRef JSMediacontent::updateItemsBatch(JSContextRef context,
 {
     LogDebug("entered");
 
-    MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
-    assert(privateObject);
+       MediacontentPrivObject *privateObject;
+       
+       privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+       if (!privateObject)
+       {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
 
        JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(globalContext, MEDIACONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH);
+       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
+            MEDIACONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        Validator validator(context);
@@ -456,46 +479,68 @@ JSValueRef JSMediacontent::updateItemsBatch(JSContextRef context,
 
        cbm = JSCallbackManager::createObject(globalContext);
 
-       IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+       // Protect the super object until the callback operation is finished.
+       JSValueProtect(globalContext, thisObject);
 
-    Try
+       Try
     {
-   
-        if (argumentCount>4 || argumentCount<1) {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
 
-        if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        }
+               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
 
-        MediacontentMediaListPtr events;
-        
-               events = converter->toVectorOfEvents(arguments[0]);
-        if (!events) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
-        }
-               if(cbm) 
-        {
-            JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-            if((argumentCount >= 2) && validator.isCallback(arguments[1]))
-            {
+               JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+               MediacontentMediaListPtr events;
+               if((argumentCount >= 1) && (JSIsArrayValue(context, arguments[0])))     //MediaItem[] items
+               {       
+                       events = converter->toVectorOfMediaItem(arguments[0]);
+                       if(!events) 
+                       {
+                               ThrowMsg(ConversionException, "Items type mismatched.");
+                       }
+               }
+               else
+               {
+                       ThrowMsg(ConversionException, "Items type mismatched.");
+               }                       
+
+               if(argumentCount >= 2)  //Function? successCallback, 
+               {
+                       if(validator.isCallback(arguments[1]))
+                       {
                                onSuccessForCbm = arguments[1];
-            }
-            
-            if((argumentCount >= 3) && validator.isCallback(arguments[2])) 
-            {
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[1]))             //nullable
+                       {
+                               LogDebug("successCallback type mismatched.");
+                               Throw(ConversionException);                             
+                       }
+               }
+       
+               if(argumentCount >= 3)  //ErrorCallback? errorCallback, 
+               {       
+                       if(validator.isCallback(arguments[2]))
+                       {
                                onErrorForCbm = arguments[2];
-            }
-            cbm->setOnSuccess(onSuccessForCbm);
-            cbm->setOnError(onErrorForCbm);
+                       }
+                       else if(!validator.isNullOrUndefined(arguments[2]))             //nullable
+                       {
+                               LogDebug("ErrorCallback type is mismatched.");
+                               Throw(ConversionException);                             
+                       }
+               }
+
+               if(cbm)
+               {
+                       cbm->setOnSuccess(onSuccessForCbm);
+                       cbm->setOnError(onErrorForCbm);
                }
+               
         IEventUpdateMediaItemsPtr dplEvent(new IEventUpdateMediaItems());
         dplEvent->setMediaItems(events);
         dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
         
         dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance()); 
         mediacontent->updateMediaItems(dplEvent);
+
     }
     Catch(UnsupportedException)
     {
@@ -523,7 +568,7 @@ JSValueRef JSMediacontent::updateItemsBatch(JSContextRef context,
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 }
 
 
@@ -536,63 +581,89 @@ JSValueRef JSMediacontent::updateItem(
                                                const JSValueRef arguments[],
                                                JSValueRef* exception)
 {
-               LogDebug("updateItem::entered");
+LogDebug("updateItem::entered");
+
+
+       MediacontentPrivObject *privateObject;
 
+       privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+       if (!privateObject)
+       {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
        
-               MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
-               assert(privateObject);
-               
-               AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(privateObject->getContext(), MEDIACONTENT_FUNCTION_API_UPDATE_ITEM);
-               
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(
+            MEDIACONTENT_FUNCTION_API_UPDATE_ITEM);
+       
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               Validator validator(context);
-               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+       Validator validator(context);
 
-               Try
-               {               
-               if (argumentCount == 0 ||
-                   (!JSValueIsObject(context, arguments[0])) ||
-                   (argumentCount >= 2 && (!validator.isNullOrUndefined(arguments[1]) && (!validator.isCallback(arguments[1])))) ||
-                   (argumentCount >= 3 && (!validator.isNullOrUndefined(arguments[2]) && (!validator.isCallback(arguments[2])))) )
-               {
-                   LogDebug("Argument type mismatch");
-                   Throw(InvalidArgumentException);
-               }               
-                       JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-                       MediacontentMediaPtr event = JSMedia::getMediaObject(arg);
-
-                       IEventUpdateMediaPtr dplEvent(new IEventUpdateMedia());
-                       dplEvent->setMediaItem(event);
-                       dplEvent->setForSynchronousCall();
-                       mediacontent->updateMedia(dplEvent);
-                   if (dplEvent->getResult()) 
-                   {
-                   return JSValueMakeNull(context);
-           } 
-           else
-           {
-               ThrowMsg(UnknownException, "Updating failed by unkown reason.");
-               }
-               }
-               Catch(InvalidArgumentException)
-               {
-                   return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
-               }
-               Catch(ConversionException)
+       Try
+       {               
+               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+       
+               //parameter : MediaItem item
+               
+               JSObjectRef arg;
+               if(argumentCount >= 1)
                {
-                   return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::INVALID_VALUES_ERROR);
+                       if (!JSValueIsObjectOfClass(context, arguments[0], JSMedia::getClassRef()) &&
+                               !JSValueIsObjectOfClass(context, arguments[0], JSImage::getClassRef()) &&
+                               !JSValueIsObjectOfClass(context, arguments[0], JSAudio::getClassRef()) &&                       
+                               !JSValueIsObjectOfClass(context, arguments[0], JSVideo::getClassRef())) {
+                                   ThrowMsg(ConversionException, "Item type mismatched.");
+                       }                       
+                       arg = JSValueToObject(context, arguments[0], exception);
                }
-               Catch(Exception)
+               else
                {
-                   return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+                        ThrowMsg(ConversionException, "Item type mismatched.");
                }
 
-               return JSValueMakeNull(context);                
-}
+               MediacontentMediaPtr event = JSMedia::getMediaObject(arg);
 
+               IEventUpdateMediaPtr dplEvent(new IEventUpdateMedia());
+               dplEvent->setMediaItem(event);
+               dplEvent->setForSynchronousCall();
+               mediacontent->updateMedia(dplEvent);
 
+        if (dplEvent->getResult()) {
+            return JSValueMakeUndefined(context);
+        } else {
+            ThrowMsg(UnknownException, "updating failed by unknown reason.");
+        }
 
+       }
+       Catch(UnsupportedException)
+       {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+       }
+       Catch(InvalidArgumentException)
+       {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+       }
+       Catch(ConversionException)
+       {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+       }
+       Catch (NotFoundException)
+       {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_FOUND_ERROR, _rethrown_exception.GetMessage());
+       }
+       Catch(Exception)
+       {
+               LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+       }
+
+       return JSValueMakeUndefined(context);
+
+}
 
 
 IMediacontentPtr JSMediacontent::getMediacontentObject(
@@ -605,7 +676,7 @@ IMediacontentPtr JSMediacontent::getMediacontentObject(
        {
         return priv->getObject();
     }
-    ThrowMsg(NullPointerException, "Private object is NULL.");
+    ThrowMsg(ConversionException, "Private object is NULL.");
 }
 
 
index 167e51d..d3df4fa 100644 (file)
@@ -81,14 +81,6 @@ class JSMediacontent
        */
        static void finalize(JSObjectRef object);
 
-       static JSValueRef findMedia(
-                       JSContextRef context, 
-                       JSObjectRef object,
-                       JSObjectRef thisObject, 
-                       size_t argumentCount,
-                       const JSValueRef arguments[], 
-                       JSValueRef* exception);
-
        static JSValueRef getFolders(
                        JSContextRef context, 
                        JSObjectRef object,
@@ -114,7 +106,7 @@ class JSMediacontent
                        JSValueRef* exception);
                        
 
-       static JSValueRef browseFolder(
+       static JSValueRef findItems(
                        JSContextRef context, 
                        JSObjectRef object,
                        JSObjectRef thisObject, 
index 84c7f84..55cdfd8 100644 (file)
@@ -30,6 +30,8 @@
 #include "MediaConverter.h"
 #include "JSMediacontentManager.h"
 #include "MediacontentController.h"
+#include "plugin_config.h"
+
 
 using namespace TizenApis::Commons;
 
@@ -86,27 +88,20 @@ JSValueRef JSMediacontentManager::getMediacontent(
                                                        JSValueRef* exception)
 {
        LogDebug("JSMediacontentManager::getMediacontent entered");
-    MediacontentManagerPrivObject *privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-
-    if (NULL == privateObject) 
-    {
-        LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR);
-    }
+    MediacontentManagerPrivObject *privateObject;
+       
+       privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       }
 
     JSContextRef globalContext = privateObject->getContext();
 
-       /*dy.kim-todo
-    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR);
-
-       */
+       AceSecurityStatus status = MEDIACONTENT_CHECK_ACCESS(MEDIACONTENT_FUNCTION_API_GET_LOCAL_MEDIASOURCE);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Try 
     {
-        if (argumentCount > 0) 
-        {
-            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
-        }
 
         MediaConverter converter(globalContext); 
   
@@ -122,7 +117,7 @@ JSValueRef JSMediacontentManager::getMediacontent(
         } 
         else 
         {
-            ThrowMsg(UnknownException, "Getting calendar failed by unkown reason.");
+            ThrowMsg(UnknownException, "Getting MediaSource failed by unkown reason.");
         }
     }
     Catch(UnsupportedException)
@@ -151,7 +146,7 @@ JSValueRef JSMediacontentManager::getMediacontent(
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
+    return JSValueMakeUndefined(context);
 
 }
 
@@ -191,9 +186,14 @@ void JSMediacontentManager::finalize(JSObjectRef object)
 {
        LogDebug("Entered");
        MediacontentManagerPrivObject* priv = static_cast<MediacontentManagerPrivObject*> (JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting coordinates object");
-       delete priv;
+       if(priv != NULL)
+       {
+               LogDebug("Deleting coordinates object");
+               delete priv;
+               JSObjectSetPrivate(object, NULL);
+               priv = NULL;
+       }
+
 }
 
 
index e95f70b..ecd2021 100644 (file)
@@ -102,7 +102,15 @@ void JSVideo::finalize(JSObjectRef object)
 {
     LogDebug( "entered" );
        VideoPrivObject *priv =  static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
-    delete priv;
+       if (priv != NULL)
+       {
+               delete (priv);
+               priv = NULL;
+               JSObjectSetPrivate(object, NULL);               
+       }
+
+       priv = NULL;
+
 }
 
 const JSClassRef JSVideo::getClassRef()
@@ -194,7 +202,21 @@ JSValueRef JSVideo::getPropertyArtist(
     {
         Converter converter(context);
         MediacontentVideoPtr event = getVideoObject(object);
-        return converter.toJSValueRef(event->getVideoArtist());
+        JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+
+               if (NULL == jsResult) 
+               {
+                       ThrowMsg(NullPointerException, "Could not create js array object");
+               }
+//             for(unsigned int i=0; i<event->getAudioArtist()->size(); i++) 
+               {
+                       JSValueRef val = converter.toJSValueRef(event->getVideoArtist());
+                       if(!JSSetArrayElement(context, jsResult, 0, val)) 
+                       {
+                          ThrowMsg(UnknownException, "Could not insert value into js array");
+                       }
+               }
+               return jsResult;  
     }
     Catch(Exception)
     {
index 724cbf5..12b16ff 100644 (file)
@@ -110,7 +110,7 @@ JSValueRef MediaConverter::toJSValueRef(const MediacontentLyricsPtr &arg)
 
 
 
-MediacontentMediaListPtr MediaConverter::toVectorOfEvents(JSValueRef events)
+MediacontentMediaListPtr MediaConverter::toVectorOfMediaItem(JSValueRef events)
 {
     LogDebug("entered");
     MediacontentMediaListPtr result(new MediacontentMediaList());
index bfa5601..8378862 100644 (file)
@@ -1,4 +1,3 @@
-/*
  /*
  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
  *
@@ -63,7 +62,7 @@ class MediaConverter : public Converter
        JSValueRef toJSValueRef(const MediacontentLyricsPtr &arg);
 
 
-       MediacontentMediaListPtr toVectorOfEvents(JSValueRef events);
+       MediacontentMediaListPtr toVectorOfMediaItem(JSValueRef events);
 
     
 };
index f982c98..5024e64 100644 (file)
@@ -70,16 +70,19 @@ void MediacontentManagerController::OnAnswerReceived(const IEventFindMediaPtr &e
             const std::vector<MediacontentMediaPtr> &results = event->getMedia();
             JSValueRef result = converter->toJSValueRef(results);
             cbm->callOnSuccess(result);
-            return;
         }
+        else
+        {
+                       JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                                       cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+                       cbm->callOnError(errorObject);
+        }        
+        return;
     }
     Catch(Exception)
     {
         LogError("error during processing answer");
     }
-    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
 }
 
 void MediacontentManagerController::OnAnswerReceived(const IEventUpdateMediaItemsPtr &event)
@@ -105,6 +108,7 @@ void MediacontentManagerController::OnAnswerReceived(const IEventUpdateMediaItem
                                        cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
                        cbm->callOnError(errorObject);
         }
+        return;
     }
     Catch(Exception)
     {
@@ -132,17 +136,19 @@ void MediacontentManagerController::OnAnswerReceived(const IEventBrowseFolderPtr
             const std::vector<MediacontentMediaPtr> &results = event->getMedia();
             JSValueRef result = converter->toJSValueRef(results);
             cbm->callOnSuccess(result);
-            return;
         }
+        else
+        {
+                       JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                                       cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+                       cbm->callOnError(errorObject);
+        }        
+               return;
     }
     Catch(Exception)
     {
         LogError("error during processing answer");
     }
-    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
-
 }
 
 
@@ -166,16 +172,19 @@ void MediacontentManagerController::OnAnswerReceived(const IEventFindFolderPtr &
             const std::vector<MediacontentFolderPtr> &results = event->getFolder();
             JSValueRef result = converter->toJSValueRef(results);
             cbm->callOnSuccess(result);
-            return;
         }
+        else
+        {
+                       JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+                                       cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+                       cbm->callOnError(errorObject);
+        }        
+               return;
     }
     Catch(Exception)
     {
         LogError("error during processing answer");
     }
-    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
-            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
-    cbm->callOnError(errorObject);
 
 }
 
index 7361475..01c2628 100755 (executable)
@@ -70,11 +70,11 @@ static FunctionMapping createMediacontentFunctions()
     ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_READ_WRITE, FEATURE_MEDIACONTENT_WRITE);
 
     ACE_CREATE_FEATURE_LIST(MEDIACONTENT_FEATURES_MEDIACONTENT_READ);
-    //ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_READ, FEATURE_MEDIACONTENT);
+    ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_READ, FEATURE_MEDIACONTENT);
     ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_READ, FEATURE_MEDIACONTENT_READ);
 
     ACE_CREATE_FEATURE_LIST(MEDIACONTENT_FEATURES_MEDIACONTENT_WRITE);
-    //ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_WRITE, FEATURE_MEDIACONTENT);
+    ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_WRITE, FEATURE_MEDIACONTENT);
     ACE_ADD_API_FEATURE(MEDIACONTENT_FEATURES_MEDIACONTENT_WRITE, FEATURE_MEDIACONTENT_WRITE);
 
     /**
@@ -116,17 +116,6 @@ static FunctionMapping createMediacontentFunctions()
                                MEDIACONTENT_FUNCTION_API_GET_FOLDERS,
                                getFoldersFunc));
 
-    //browseFolder
-    AceFunction browseFolderFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_BROWSE_FOLDER,
-            MEDIACONTENT_FUNCTION_API_BROWSE_FOLDER,
-            MEDIACONTENT_FEATURES_MEDIACONTENT_READ,
-            DEVICE_LIST_MEDIACONTENT_READ);
-
-    mediacontentMapping.insert(std::make_pair(
-                               MEDIACONTENT_FUNCTION_API_BROWSE_FOLDER,
-                               browseFolderFunc));
-
     //updateItem
     AceFunction updateItemFunc = ACE_CREATE_FUNCTION(
             FUNCTION_UPDATE_ITEM,
index cf7ce5d..96cbeb1 100755 (executable)
@@ -31,15 +31,13 @@ namespace Mediacontent {
 // Functions from mediacontent
 #define MEDIACONTENT_FUNCTION_API_FIND_ITEMS "findItems"
 #define MEDIACONTENT_FUNCTION_API_GET_FOLDERS "getFolders"
-#define MEDIACONTENT_FUNCTION_API_BROWSE_FOLDER "browseFolder"
 #define MEDIACONTENT_FUNCTION_API_UPDATE_ITEM "updateItem"
 #define MEDIACONTENT_FUNCTION_API_UPDATE_ITEMS_BATCH "updateItemsBatch"
 
 DECLARE_FUNCTION_GETTER(Mediacontent);
 
-#define MEDIACONTENT_CHECK_ACCESS(globalContext, functionName)                     \
+#define MEDIACONTENT_CHECK_ACCESS(functionName)                     \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getMediacontentFunctionData,           \
         functionName)
 
@@ -47,4 +45,4 @@ DECLARE_FUNCTION_GETTER(Mediacontent);
 }
 }
 
-#endif //  _MEDIACONTENT_PLUGIN_CONFIG_H_
\ No newline at end of file
+#endif //  _MEDIACONTENT_PLUGIN_CONFIG_H_
index 705ad6a..1333d1f 100644 (file)
 #include <dpl/log/log.h>
 
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <Commons/Exception.h>
 #include "JSMediacontentManager.h"
 
 
 using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
@@ -31,20 +32,17 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Mediacontent {
 
-void on_widget_start_callback(
-                               int widgetId,
-                               JavaScriptContext context,
-                               const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\mediacontent] on_widget_start_callback (" << widgetId << ")");
 
        Try
     {
-        WrtWrappersMgr::getInstance().registerWrapper(widgetId, context,interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
     }
-    Catch(Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper registration failed");
+        LogError("WrtAccess intialization failed");
     }
 
 }
@@ -52,7 +50,14 @@ void on_widget_start_callback(
 void on_widget_stop_callback(int widgetId)
 {
     LogDebug("[Tizen\\mediacontent] on_widget_stop_callback (" << widgetId << ")");
-    WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+    Try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+       }
+       Catch(Commons::Exception)
+    {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index 1bc83dd..5a912a5 100755 (executable)
@@ -59,9 +59,9 @@ namespace Tizen1_0 {
 
 MessageFunctions ConverterMessage::m_callbackNames[MESSAGING_MULTI_FUNTION_MAX]
 {
-       {"messagesAdded", "messagesUpdated", "messagesRemoved"},
-       {"conversationsAdded", "conversationsUpdated", "conversationsRemoved"},
-       {"foldersAdded", "foldersUpdated", "foldersRemoved"}
+       {"messagesadded", "messagesupdated", "messagesremoved"},
+       {"conversationsadded", "conversationsupdated", "conversationsremoved"},
+       {"foldersadded", "foldersupdated", "foldersremoved"}
 };
 
 ConverterMessage::ConverterMessage(JSContextRef context) :
@@ -531,8 +531,7 @@ JSValueRef ConverterMessage::toFunctionOrNull(const JSValueRef& arg)
 
     if (Validator(m_context).isCallback(arg)) {
         return arg;
-    } else if (!JSValueIsNull(m_context,
-                              arg) && !JSValueIsUndefined(m_context, arg)) {
+    } else if (!JSValueIsNull(m_context, arg) ) {
         ThrowMsg(ConversionException, "Not a function nor JS null.");
     }
     return NULL;
@@ -544,8 +543,8 @@ JSValueRef ConverterMessage::toFunction(const JSValueRef& arg)
 
     if (Validator(m_context).isCallback(arg)) {
         return arg;
-    } else if (JSValueIsNull(m_context,
-                             arg) || JSValueIsUndefined(m_context, arg)) {
+    } else if (JSValueIsNull(m_context, 
+               arg) || JSValueIsUndefined(m_context, arg)) {
         ThrowMsg(InvalidArgumentException, "JS null passed as function.");
     }
     ThrowMsg(ConversionException, "Not a function nor JS null.");
index 3ecb818..7ed4512 100755 (executable)
@@ -1,18 +1,18 @@
-/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. 
-*/
+/*\r
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+* http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License. \r
+*/\r
 \r
 #include "EventMessagingServicePrivateData.h"\r
 \r
@@ -26,11 +26,24 @@ EventMessagingServicePrivateData::EventMessagingServicePrivateData(const JSCallb
 {\r
 }\r
 \r
+EventMessagingServicePrivateData::EventMessagingServicePrivateData(const JSCallbackManagerPtr& callbackManager,\r
+       const JSCallbackManagerPtr& recipientCallbackManager) :\r
+       m_callbackManager(callbackManager),\r
+       m_recipientCallbackManager(recipientCallbackManager)\r
+{\r
+}\r
+\r
 JSCallbackManagerPtr EventMessagingServicePrivateData::getCallbackManager() const\r
 {\r
     return m_callbackManager;\r
 }\r
 \r
+JSCallbackManagerPtr EventMessagingServicePrivateData::getRecipientCallbackManager() const\r
+{\r
+               return m_recipientCallbackManager;\r
+}\r
+\r
+\r
 }\r
 }\r
 \r
index f3ba43d..b791e60 100755 (executable)
@@ -29,9 +29,13 @@ class EventMessagingServicePrivateData : public WrtDeviceApis::Commons::IEventPr
 
 public:
     EventMessagingServicePrivateData(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& callbackManager);
-
+    EventMessagingServicePrivateData(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& callbackManager, 
+               const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& recipientCallbackManager );
+       
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getCallbackManager() const;
 
+    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr getRecipientCallbackManager() const;
+
     void setMessageJSValueRef(const JSValueRef& msgJSValueRef)
     {
                m_messageJSValueRef = msgJSValueRef;
@@ -54,6 +58,7 @@ public:
        
 private:
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_callbackManager;
+    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_recipientCallbackManager;
     JSValueRef m_messageJSValueRef;
 
     int m_sync_handle; 
index b71c4f1..a7350ba 100755 (executable)
@@ -96,7 +96,7 @@ JSStaticValue JSMessage::m_property[] = {
     { "body", getMessageBody, setMessageBody, kJSPropertyAttributeNone },
     { "isRead", getIsRead, setIsRead, kJSPropertyAttributeNone },
     //{ "hasAttachment", getAttachmentExistence, NULL, kJSPropertyAttributeReadOnly },
-    { "priority", getMessagePriority, setMessagePriority, kJSPropertyAttributeNone },
+    { "isHighPriority", getMessagePriority, setMessagePriority, kJSPropertyAttributeNone },
     { "subject", getSubject, setSubject, kJSPropertyAttributeNone },
     { "inResponseTo", getInResponseTo, NULL, kJSPropertyAttributeNone },
     { "messageStatus", getMessageStatus, NULL, kJSPropertyAttributeReadOnly},
@@ -339,7 +339,6 @@ JSObjectRef JSMessage::constructor(JSContextRef context,
        {
                try 
                {
-
                        if ( argumentCount < 1 || argumentCount > 2) {
                                LogError("Wrong argument count");
                                ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong Message argumentCount");
@@ -347,14 +346,10 @@ JSObjectRef JSMessage::constructor(JSContextRef context,
                        else
                        {       
                                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-                               
-                               JSValueRef objMsg = NULL;
                                Api::Messaging::MessageType msgType = converter->toMessageType(arguments[0]);
-                               
                                //objMsg = JSMessage::createDummyMessageJSObject(globalContext, msgType);               //make message JSValueRef.
 
                                Api::Messaging::IMessagePtr msg;
-
                                if ( msgType == Api::Messaging::EMAIL )
                                {
                                        msg = Api::Messaging::MessageFactory::createEmailMessage();
@@ -381,7 +376,7 @@ JSObjectRef JSMessage::constructor(JSContextRef context,
                                                const ScopedJSStringRef bccStr(JSStringCreateWithUTF8CString("bcc"));
                                                const ScopedJSStringRef plainBodyStr(JSStringCreateWithUTF8CString("plainBody"));
                                                const ScopedJSStringRef htmlBodyStr(JSStringCreateWithUTF8CString("htmlBody"));
-                                               const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("priority"));
+                                               const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("isHighPriority"));
 
                                                JSObjectRef arg = converter->toJSObjectRef(arguments[1]);       //get dictionary
                                                JSValueRef subjectData = JSObjectGetProperty(globalContext, arg, subjectStr.get(), NULL);
@@ -485,7 +480,7 @@ JSObjectRef JSMessage::constructor(JSContextRef context,
                                {
                                        LogDebug("Message Creation failed");
                                        ThrowMsg(WrtDeviceApis::Commons::PlatformException, "message has been not created"); 
-                               }                                       
+                               }
 
                        }
                        
@@ -574,7 +569,7 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
 
                        JSObjectRef jsMessageAttachmentObject[count];   //make
                        
-                       for (int index = 0 ; index < attachments.size(); index++ )
+                       for (unsigned int index = 0 ; index < attachments.size(); index++ )
                        {
                                LogDebug( "Attachment ID : " << attachments[index]->getAttachmentID());
                                jsMessageAttachmentObject[index] = JSMessageAttachment::createJS(globalContext, attachments[index] );
@@ -1025,17 +1020,15 @@ JSValueRef JSMessage::getMessageBody(JSContextRef context,
     Try
     {
          JSMessagePrivateObject* priv = static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
-         Assert(priv && "Private object is NULL.");
+         if (!priv)
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Couldn't get Messaage Private Object");
 
          JSContextRef globalContext = priv->getContext();
 
          ConverterMessageFactory::ConverterType converter =
          ConverterMessageFactory::getConverter(globalContext);
-
          Api::Messaging::IMessagePtr msg = converter->toIMessage(object);      //get message point
-         LogInfo("create JS");
-
-        return JSMessageBody::createJS(globalContext, msg);
+          return JSMessageBody::createJS(globalContext, msg);
     }
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("Error on conversion");
index 8d9e895..50fb378 100755 (executable)
@@ -35,6 +35,7 @@
 #include "MessagingErrorMsg.h"
 #include <Messaging/Attachment.h>
 
+#if 0
 namespace {
 const char* MSG_ATTACHMENT_MIMETYPE            = "MIMEType";
 const char* MSG_ATTACHMENT_MESSAGEID           = "messageId";
@@ -42,6 +43,7 @@ const char* MSG_ATTACHMENT_CONTENTLOCATION    = "contentLocation";
 const char* MSG_ATTACHMENT_CONTENTID   = "contentId";
 const char* MSG_ATTACHMENT_LOADED              = "loaded";
 }
+#endif
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -273,19 +275,33 @@ JSValueRef JSMessageAttachment::getFile(JSContextRef context,
        if ( attachment )
        {
                Try
-               {
-                       std::string fullPath = attachment->getFullPath();
-                       LogDebug("fullPath=" << fullPath);
-
-                       if (fullPath.empty()) {
-                               return JSValueMakeNull(context);
+               {       
+                       WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+                       
+                       if ( (attachment->getVirtualPath()).length() > 0)
+                       {
+                               return converter.toJSValueRef(attachment->getVirtualPath());
                        }
                        else
-                       {       
-                               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-                               std::string virtualpath = AttachmentFactory::getVirtualPathFromRealPath(globalContext, fullPath);       
-                               return converter.toJSValueRef(virtualpath);
+                       {
+                               std::string fullPath = attachment->getFullPath();
+                               LogDebug("fullPath=" << fullPath);
+                               if (fullPath.empty()) {
+                                       return JSValueMakeNull(context);
+                               }
+                               else
+                               {       
+                                       std::string virtualpath = AttachmentFactory::getVirtualPathFromRealPath(globalContext, fullPath);
+                                       if ( virtualpath.length() == 0 )
+                                       {
+                                               virtualpath = AttachmentFactory::getVirtualPathFromEmailServiceFolder(globalContext, fullPath);
+                                               attachment->setVirtualPath(virtualpath);        //set virtual path
+                                       }
+
+                                       return converter.toJSValueRef(virtualpath);                                             
+                               }
                        }
+
                }
                Catch(WrtDeviceApis::Commons::InvalidArgumentException)
                {
@@ -422,9 +438,10 @@ JSObjectRef JSMessageAttachment::constructor(JSContextRef context,
                try
                {
                        LogDebug("argumentCount=" << argumentCount);
-                       if ( argumentCount < 1 || argumentCount > 2) {
+                       if ( argumentCount < 1 ) {
                                LogError("Wrong argument count");
-                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong Message argumentCount");
+                               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+                               return NULL;
                        }
                        else
                        {       
index fd855db..485f64d 100755 (executable)
@@ -30,6 +30,8 @@
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/Utils.h>                                   
 #include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <CommonsJavaScript/JSPendingOperation.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <Commons/StringUtils.h>
 
 #include <API/Messaging/ReqReceiverMessage.h>
@@ -83,18 +85,19 @@ namespace Tizen1_0 {
            {"id",                      getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"type",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"name",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
-           {"messagingStorage",                                getProperty, NULL, kJSPropertyAttributeReadOnly},
+           {"messageStorage",                          getProperty, NULL, kJSPropertyAttributeReadOnly},
            { 0, 0, 0, 0 }
        };
 
        JSStaticFunction JSMessagingService::m_function[] = {
-                       { "createMessage",        JSMessagingService::createMessage,       kJSPropertyAttributeNone },
+                       //{ "createMessage",      JSMessagingService::createMessage,       kJSPropertyAttributeNone },
                        { "sendMessage",          JSMessagingService::sendMessage,         kJSPropertyAttributeNone },
                        { "loadMessageBody",      JSMessagingService::loadMessageBody,     kJSPropertyAttributeNone },
                        { "loadMessageAttachment",        JSMessagingService::loadMessageAttachment,       kJSPropertyAttributeNone },
                        { "sync",         JSMessagingService::sync,        kJSPropertyAttributeNone },
                        { "syncFolder",   JSMessagingService::syncFolder,          kJSPropertyAttributeNone },
-                       { "cancelOperation",   JSMessagingService::cancelOperation,        kJSPropertyAttributeNone },
+                       //{ "cancelOperation",   JSMessagingService::cancelOperation,      kJSPropertyAttributeNone },
+                       { "stopSync",   JSMessagingService::stopSync,      kJSPropertyAttributeNone },
                        { 0, 0, 0 }
        };
 
@@ -154,10 +157,21 @@ namespace Tizen1_0 {
                                        }
                                        
                                        retVal = converter->toJSValueRef(stream.str());
-                               } else if (JSStringIsEqualToUTF8CString(propertyName, "messagingStorage")) {
-                                       LogDebug("messagingStorage" << ":" <<  imessagingService->getAccountID());
+                               } else if (JSStringIsEqualToUTF8CString(propertyName, "messageStorage")) {
                                        JSContextRef l_globalContext = converter->toJSGlobalContext(object);                                    
-                                       retVal = JSUtils::makeObject(l_globalContext, JSMessagingStorage::getClassRef(), NULL);
+                                       MessagingStoragePrivObjPtr storagePriv(new MessagingStoragePrivObj());
+//                                     MessagingListenerPtr listener_priv = MessagingListener::getInstance(l_globalContext) ;
+                                       storagePriv->m_index = imessagingService->getAccountID();
+                                       storagePriv->m_type = imessagingService->getType();
+                                       LogDebug("type" << ":" << imessagingService->getType());
+                                       LogDebug("accountId" << ":" <<  imessagingService->getAccountID());
+                                       
+                                       MessagingStoragePriv *priv = new MessagingStoragePriv(l_globalContext, storagePriv);
+                                       //MessagingStoragePrivObjPtr storagePriv = priv->getObject();
+
+//                                     retVal = JSUtils::makeObject(l_globalContext, JSMessagingStorage::getClassRef(), priv);
+                                       retVal = JSObjectMake(l_globalContext, JSMessagingStorage::getClassRef(), priv);
+
                                } else{
                                        retVal = JSValueMakeUndefined(context);
                                }
@@ -192,7 +206,6 @@ namespace Tizen1_0 {
                if (priv)
                {
                        AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
                                MessagingExportedNames[MESSAGING_FUNCTION_API_CREATE_MESSAGE]);
                        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                                
@@ -234,7 +247,7 @@ namespace Tizen1_0 {
                                        const ScopedJSStringRef bccStr(JSStringCreateWithUTF8CString("bcc"));
                                        const ScopedJSStringRef plainBodyStr(JSStringCreateWithUTF8CString("plainBody"));
                                        const ScopedJSStringRef htmlBodyStr(JSStringCreateWithUTF8CString("htmlBody"));
-                                       const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("priority"));
+                                       const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("isHighPriority"));
 
                                        JSObjectRef arg = converter->toJSObjectRef(arguments[0]);
                                        JSValueRef subjectData = JSObjectGetProperty(l_globalContext, arg, subjectStr.get(), NULL);
@@ -359,74 +372,94 @@ JSValueRef JSMessagingService::sendMessage(JSContextRef context,
     }
 
     JSContextRef globalContext = priv->getContext();
-
     LogInfo(">>> argument count : " << argumentCount);
 
-    if (argumentCount < 2) {
+    if (argumentCount < 1) {
                return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
     }
 
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr recipientCallbackManager;
 
     ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);  
-       Try {           
+    //check permission.
+    AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+               MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE]);
+       TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
 
-               if ( argumentCount > 1 && argumentCount < 4)
+
+Try {
+               //argu 1. Message ( mandatory )
+               if (!JSValueIsObject(context, arguments[0]))
                {
-                       if ( argumentCount > 1)
-                       {       
-                               if (JSValueIsObject(context, arguments[1]) && !Validator(context).isCallback(arguments[1])) //check
-                               {       
-                                       MessageSendCallback callbacks = converter->toMessageSendCallback(arguments[1]);
+                       LogDebug("arguments is invaild");
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+               }
+               
+               IMessagePtr msg = converter->toIMessage(arguments[0]);
+               
+               //argu 2. Success callback (optional)
+               if ( argumentCount > 1)
+               {
+                       if ( JSValueIsObject(context, arguments[1]) || Validator(context).isCallback(arguments[1]))
+                       {
+                               MessageSendCallback callbacks = converter->toMessageSendCallback(arguments[1]);                 
+                                                       
+                               if (!(JSValueIsUndefined(context, callbacks.onSuccess) || JSValueIsNull(context, callbacks.onSuccess)) )
+                               {
                                        callbackManager->setOnSuccess( converter->toFunctionOrNull(callbacks.onSuccess) );
                                }
                                else
                                {
-                               callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
-                       }
-
-                               if (    argumentCount == 3)
-                               {
-                                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
                                }
                        }
+                       else
+                       {       
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+                       }
                }
-               else
+               //argu 3. error callback (optional & nullable)
+               if ( argumentCount > 2)
                {
-                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+                       if ( Validator(context).isCallback(arguments[2]))
+                               callbackManager->setOnError(arguments[2]);
+                       else if(Validator(context).isNullOrUndefined(arguments[2]))
+                               callbackManager->setOnError(NULL);
+                       else
+                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                }
-
-             //check permission.
-               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                       priv->getContext(),
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_SEND_MESSAGE]);
-               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
-               
           //create PrivateData
-        EventSendMessagePrivateDataPtr privateData( new EventSendMessagePrivateData(callbackManager, recipientCallbackManager) );
-
-        Api::Messaging::EventSendMessagePtr event(new Api::Messaging::EventSendMessage());
+        EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager, recipientCallbackManager) );
 
-         LogDebug("Event size");
+        //Api::Messaging::EventSendMessagePtr event(new Api::Messaging::EventSendMessage());
+         Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());
 
          IMessagingServicePtr imessagingService = priv->getObject();
        
         event->opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_SEND_MESSAGE);
-        event->msg = converter->toIMessage(arguments[0]);
-          imessagingService->setMessageToOpId( event->opId, event->msg);
+        event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE);
+        event->m_message = msg;
+        imessagingService->setMessageToOpId( event->opId, event->m_message);
         event->store = true;           //always store message in sendbox after send , email Type.
         event->m_messagingService = imessagingService;
         event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
-         
-        //event->setForAsynchronousCall(&JSMessagingListener::getInstance());
-        //event->setForAsynchronousCall(&MessagingControllerSingleton::Instance());
          event->setForAsynchronousCall(&MessagingController::getInstance());
      
         Api::Messaging::ReqReceiverMessageSingleton::Instance().sendMessage(event);    //send message
+#if 0 //Pending Operation.
+       DPL::SharedPtr<IExternEventCanceler<EventMessagingService> > eventCanceller =
+               DPL::StaticPointerCast<IExternEventCanceler<EventMessagingService> >(imessagingService);
 
-        return converter->toJSValueRef(event->opId);
+       IJSExtCancelPendingOperationPrivateObject<EventMessagingService> *gcPendingOperation =
+               new IJSExtCancelPendingOperationPrivateObject<EventMessagingService>(event, eventCanceller);
+
+       return JSObjectMake(globalContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+#endif                 
+        //return converter->toJSValueRef(event->opId);
+
+       return JSValueMakeUndefined(context);
     }
     Catch(WrtDeviceApis::Commons::ConversionException) {
                return JSTizenExceptionFactory::postException(context, exception, 
@@ -437,8 +470,8 @@ JSValueRef JSMessagingService::sendMessage(JSContextRef context,
                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);        
     }
     Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);        
     }
 
     return JSValueMakeNull(context);
@@ -464,9 +497,9 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
     JSContextRef globalContext = priv->getContext();           //create global Context
     LogInfo(">>> argument count : " << argumentCount);
 
-       if (argumentCount < 2) {
+       if (argumentCount < 3) {
                return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
        }
 
        Validator check(context, exception);    //create check
@@ -474,105 +507,114 @@ JSValueRef JSMessagingService::loadMessageBody(JSContextRef context,
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
        ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(globalContext); //create converter
 
-       Try {
-               //create event
-               EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
-
-               //check permission.
-               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                       priv->getContext(),
+       //check permission.
+       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
                        MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY]);
-                       TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
-
-               if ( JSValueIsObject(context, arguments[0]) )
-               {
-                       switch(argumentCount){
-                               case 3:
-                               {
-                                       if ( Validator(context).isCallback(arguments[2]))
-                                       {
-                                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-                                       }
-                                       else
-                                       {
-                                               return JSTizenExceptionFactory::postException(context, exception, 
-                                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-                                       }
-                               }
-                               case 2:
-                               {
-                                       if ( Validator(context).isCallback(arguments[1]))
-                                       {
-                                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-                                       }
-                                       else
-                                       {
-                                               return JSTizenExceptionFactory::postException(context, exception, 
-                                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-                                       }       
-                               }
+               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
+                               
+       Try {
+                       //argu 1. message (mandatory)
+                       if (!JSValueIsObject(context, arguments[0]) )
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+                       }
+                       //argu 2. success callback
+                       if ( Validator(context).isCallback(arguments[1]))
+                       {
+                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
                        }
+                       else
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+                       }
+                       
+                       //argu 3. error callback (optional & nullable)
+                       if ( argumentCount > 2)
+                       {
+                               if ( check.isCallback(arguments[2]))
+                                       callbackManager->setOnError(arguments[2]);
+                               else if(check.isNullOrUndefined(arguments[2]))
+                                       callbackManager->setOnError(NULL);
+                               else
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       }
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
+
+       Try {
+                       IMessagePtr msg = converter->toIMessage(arguments[0]);
+                        LogInfo(" checked toIMessages " );             
+                       //create event
+                       EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
+                       Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     
+                       event->m_message = msg;
 
-                       Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create even
-                       event->m_message = converter->toIMessage(arguments[0]) ;
                        if ( event->m_message )
                        {       
                                int msgType = event->m_message->getMessageType();
-                               LogDebug("Message Type =" << event->m_message->getMessageType());
+                               
                                if (msgType == Api::Messaging::EMAIL)
                                {
                                        Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(event->m_message);
                                        if (email && email->isBodyDownloaded() > 0)
                                        {
-                                               callbackManager->callOnSuccess(arguments[0]);
-                                               return JSValueMakeNull(context);
+                                               callbackManager->callOnSuccess(arguments[1]);
                                        }
                                }
-                               else 
+                               else
                                {
-                                       callbackManager->callOnSuccess(arguments[0]);
+                                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
                                        return JSValueMakeNull(context);
                                }
 
                                privateData->setMessageJSValueRef(arguments[0]);        //set Message JSValueRef.
                        }
-
+                       LogInfo(" Checked Message Type " );
+                       
                        IMessagingServicePtr imessagingService = priv->getObject();
                        int opId = imessagingService->createOpId(MESSAGING_SERVICE_OP_DOWNLOAD_BODY);
                        LogDebug("Operation ID is = " << opId);
 
                        event->opId = opId;
                        imessagingService->setMessageToOpId(opId, event->m_message);
-                       event->setEventType(EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY);
+                       event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY);
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
                        event->setForAsynchronousCall(&MessagingController::getInstance());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().loadMessageBody(event); //load message Body
+#if 0
+                       DPL::SharedPtr<IExternEventCanceler<EventMessagingService> > eventCanceller =
+                               DPL::StaticPointerCast<IExternEventCanceler<EventMessagingService> >(imessagingService);
 
-                       return converter->toJSValueRef(event->opId);
-               }
-               else
-               {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }
+                       IJSExtCancelPendingOperationPrivateObject<EventMessagingService> *gcPendingOperation =
+                               new IJSExtCancelPendingOperationPrivateObject<EventMessagingService>(event, eventCanceller);
 
-       }
-       Catch(WrtDeviceApis::Commons::ConversionException) {
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+                       return JSObjectMake(globalContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+#endif
+                       //return converter->toJSValueRef(event->opId);
+                       return JSValueMakeUndefined(context);
        }
        Catch(WrtDeviceApis::Commons::NullPointerException) {
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }
-       Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+               return JSValueMakeNull(context);
        }
-       Catch(WrtDeviceApis::Commons::PlatformException) {
+       Catch(WrtDeviceApis::Commons::Exception) {
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
+               return JSValueMakeNull(context);
        }
 
        return JSValueMakeNull(context);
@@ -599,9 +641,9 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
        JSContextRef globalContext = priv->getContext();                //create global Context
        LogInfo(">>> argument count : " << argumentCount);
 
-       if (argumentCount < 2) {
+       if (argumentCount < 3) {
                return JSTizenExceptionFactory::postException(context, exception, 
-                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
        }
 
        Validator check(context, exception);    //create check
@@ -613,66 +655,64 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                       priv->getContext(),
                        MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT]);
                        TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);       
+               
+               //argu 1. Attachment (mandatory)
+               if (!JSValueIsObject(context, arguments[0]))
+               {
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+               }
+                               
+               //argu 2. success callback
+               if ( check.isCallback(arguments[1]))
+                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
+               else
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
 
-               if (JSValueIsObject(context, arguments[0]) && !JSValueIsNull(context, arguments[0]))
+               //argu 3. error callback (optional & nullable)
+               if ( argumentCount > 2)
                {
-                       EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
-                       if (!privateData)
-                                       return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-                       
-                       switch(argumentCount){
-                               case 3:
-                               {
-                                       if ( Validator(context).isCallback(arguments[2]))
-                                       {
-                                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-                                       }
-                                       else
-                                       {
-                                               return JSTizenExceptionFactory::postException(context, exception, 
-                                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-                                       }
-                               }
-                               case 2:
-                               {
-                                       if ( Validator(context).isCallback(arguments[1]))
-                                       {
-                                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-                                       }
-                                       else
-                                       {
-                                               return JSTizenExceptionFactory::postException(context, exception, 
-                                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-                                       }       
-                               }
-                       }
+                       if ( check.isCallback(arguments[2]))
+                               callbackManager->setOnError(arguments[2]);
+                       else if(check.isNullOrUndefined(arguments[2]))
+                               callbackManager->setOnError(NULL);
+                       else
+                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+               }
 
-                       Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event
-                       event->setEventType(EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT);
-                       event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
-                       event->setForAsynchronousCall(&MessagingController::getInstance());
-                       
-                       Api::Messaging::IAttachmentPtr iAttchmentPtr = converter->toIAttachment(arguments[0]);
-                       if (iAttchmentPtr)
-                       {       
-                               event->m_attachment = iAttchmentPtr;
-                               event->m_message = event->m_attachment->getMessage();
-                                                                       
-                               if (!event->m_message)
-                                       return JSTizenExceptionFactory::postException(context, exception, 
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+       }
+       Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+       }
+       Catch(WrtDeviceApis::Commons::Exception) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
 
-                               privateData->setMessageJSValueRef(arguments[0]); //set attachment JSValueRef.
-                       }
-                       else
-                       {
+       
+               EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
+               if (!privateData)
                                return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND);
-                       }
+                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+
+       Try {
+               Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event
+               event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT);
+               event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
+               event->setForAsynchronousCall(&MessagingController::getInstance());
+
+                       Api::Messaging::IAttachmentPtr iAttchmentPtr = converter->toIAttachment(arguments[0]);
+                               
+                       event->m_attachment = iAttchmentPtr;
+                       event->m_message = event->m_attachment->getMessage();                   
+                       
+                       privateData->setMessageJSValueRef(arguments[0]); //set attachment JSValueRef.   
                        
                        IMessagingServicePtr imessagingService = priv->getObject();
                        if (imessagingService)
@@ -685,42 +725,39 @@ JSValueRef JSMessagingService::loadMessageAttachment(JSContextRef context,
                                
                                //JSValueRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(globalContext, event);   //create pendingOperation.
                                Api::Messaging::ReqReceiverMessageSingleton::Instance().loadMessageAttachment(event);   //load message Body
+#if 0                          
+                               DPL::SharedPtr<IExternEventCanceler<EventMessagingService> > eventCanceller =
+                                       DPL::StaticPointerCast<IExternEventCanceler<EventMessagingService> >(imessagingService);
                                
-                               return converter->toJSValueRef(event->opId);
+                               IJSExtCancelPendingOperationPrivateObject<EventMessagingService> *gcPendingOperation =
+                                       new IJSExtCancelPendingOperationPrivateObject<EventMessagingService>(event, eventCanceller);
+                               
+                               return JSObjectMake(globalContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+#endif
+                               //return converter->toJSValueRef(event->opId);
+                               return JSValueMakeUndefined(context);
+
                        }
                        else
                        {
                                return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND);
                        }
-                       
-                       
-               }
-               else
-               {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-               }
 
-       }
-       Catch(WrtDeviceApis::Commons::ConversionException) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }
-       Catch(WrtDeviceApis::Commons::NullPointerException) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }
-       Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) {
                        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-       }
-       Catch(WrtDeviceApis::Commons::PlatformException) {
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                       return JSValueMakeNull(context);
+               }
+               Catch(WrtDeviceApis::Commons::Exception) {
                        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
-       }
+                       return JSValueMakeNull(context);
+               }
 
-       return JSValueMakeNull(context);
+                               
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
@@ -736,9 +773,9 @@ JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function,
 
                LogInfo(">>> argument count : " << argumentCount);
 
-               if (argumentCount > 4 || argumentCount < 2 ) {
+               if (argumentCount < 2 ) {
                        return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
                Validator check(context, exception);    //check context
@@ -751,30 +788,42 @@ JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function,
                Api::Messaging::MessageType msgType = (Api::Messaging::MessageType)imessagingService->getType();
                LogInfo("msgType :" << msgType);
 
+
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC]);
+               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);       
+                       
                Try {
 
                        int limit = -1; //sync limit
-
+                       //argu 1. success callback.                             
                        if (JSValueIsObject(context, arguments[0]) && Validator(context).isCallback(arguments[0])) //check
                        {
                                callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[0]));
-                               if (converter->toFunctionOrNull(arguments[1]) && Validator(context).isCallback(arguments[1]) )
-                               {
-                                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[1]));
-                               }
-
-                               //check permission.
-                               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                                       priv->getContext(),
-                                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC]);
-                               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);       
-                               
-                               EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
+                       }
+                       //argu 2. error callback ( nullable )
+                       if ( check.isCallback(arguments[1]))
+                               callbackManager->setOnError(arguments[1]);
+                       else if(check.isNullOrUndefined(arguments[1]))
+                               callbackManager->setOnError(NULL);
+                       else
+                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
 
-                               Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event
+                       //argu 3. limit ( optional )
+                       if (argumentCount > 2)
+                       {
+                               limit = converter->toInt(arguments[2]);
+                               if ( limit < 0 )
+                               {       
+                                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                                       return JSValueMakeNull(context);
+                               }
+                       }
 
-                               if (argumentCount == 3 && !JSValueIsNull(context, arguments[2]))
-                                       limit = converter->toInt(arguments[2]);
+                       EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
+                       Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event         
 
                                LogDebug("limit : " << limit);
 
@@ -782,21 +831,24 @@ JSValueRef JSMessagingService::sync(JSContextRef context, JSObjectRef function,
                                event->m_sync_account_id = imessagingService->getAccountID() ;
                                event->m_sync_limit = limit;
                                event->m_messagingService = imessagingService;
+                               imessagingService->setEventToOpId(event->opId, event);
 
-                               event->setEventType(EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC);
+                               event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_SYNC);
                                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
                                event->setForAsynchronousCall(&MessagingController::getInstance());
 
                                Api::Messaging::ReqReceiverMessageSingleton::Instance().sync(event);    //load message Body
-
+#if 0
+                               DPL::SharedPtr<IExternEventCanceler<EventMessagingService> > eventCanceller =
+                                       DPL::StaticPointerCast<IExternEventCanceler<EventMessagingService> >(imessagingService);
+                        
+                               IJSExtCancelPendingOperationPrivateObject<EventMessagingService> *gcPendingOperation =
+                                        new IJSExtCancelPendingOperationPrivateObject<EventMessagingService>(event, eventCanceller);
+
+                               return JSObjectMake(globalContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+#endif         
                                return converter->toJSValueRef(event->opId);
-
-                       }
-                       else
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-                       }
+                       
                }
                Catch(WrtDeviceApis::Commons::ConversionException) {
                        return JSTizenExceptionFactory::postException(context, exception, 
@@ -838,16 +890,11 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
        if (priv) {
                JSContextRef globalContext = priv->getContext();                //get global Context
 
-#if 0
-       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-               globalContext,
-               MESSAGING_FUNCTION_API_SYNC);
-#endif
                LogInfo(">>> argument count : " << argumentCount);
 
-               if (argumentCount > 4 || argumentCount < 1) {
+               if (argumentCount < 3) {
                        return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
                Validator check(context, exception);    //check context
@@ -860,48 +907,56 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
                Api::Messaging::MessageType msgType = (Api::Messaging::MessageType)imessagingService->getType();
                LogInfo("msgType :" << msgType);
 
+               //check permission
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER]);
+               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
+
                Try {
 
                        int limit = -1;
-
-                       if (JSValueIsObject(context, arguments[0]) && !Validator(context).isCallback(arguments[0])) //check
-                       {       
-                               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                                       priv->getContext(),
-                                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER]);
-                               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
-
-                               EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
-                               //private->setSyncAccountID( imessagingService->getAccountID());                  //set account ID
-
-                               Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event
-                               
+                       //argu 1. Folder (mandatory)
+                       if (!JSValueIsObject(context, arguments[0]))
+                       {
+                               return JSTizenExceptionFactory::postException(context, exception, 
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       }
+                       IMessageFolderPtr folder = converter->toIMessageFolder(arguments[0]);           
                        
-                               IMessageFolderPtr folder = converter->toIMessageFolder(arguments[0]);
-                               if ( folder )
+                       //argu 2. success callback.
+                       if (Validator(context).isCallback(arguments[1]))
+                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
+                       else
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+
+                       //argu 3. error callback (optional & nullable)
+                       if ( argumentCount > 2)
+                       {
+                               if ( check.isCallback(arguments[2]))
+                                       callbackManager->setOnError(arguments[2]);
+                               else if(check.isNullOrUndefined(arguments[2]))
+                                       callbackManager->setOnError(NULL);
+                               else
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       }
+                       //argu 4. limit ( optional )
+                       if ( argumentCount > 3 )
+                       {
+                               limit = converter->toInt(arguments[3]);
+                               if ( limit < 0 )
                                {
-                                       //event->m_folder_name = folder->getName();             //it will be changed to the folder ptr
-                                       event->m_folder_name = folder->getPath();               //it will be changed to the folder ptr
+                                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                                       return JSValueMakeNull(context);
                                }
-
-                               if ( argumentCount > 1 )
+                       }
+                       
+                       Api::Messaging::EventMessagingServicePtr event(new Api::Messaging::EventMessagingService());     //create event                         
+                       EventMessagingServicePrivateDataPtr privateData( new EventMessagingServicePrivateData(callbackManager) );
+                               
+                               if ( folder )
                                {
-                                       if (JSValueIsObject(context, arguments[1]) && Validator(context).isCallback(arguments[1])) //check
-                                       {
-                                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-                                       }
-
-                                       if ( argumentCount > 2 )
-                                       {
-                                               if (JSValueIsObject(context, arguments[2]) && Validator(context).isCallback(arguments[2])) //check
-                                               {
-                                                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-                                               }
-                                       }
-
-                                       if (argumentCount == 4 && !JSValueIsNull(context, arguments[3]))
-                                               limit = converter->toInt(arguments[3]);
-                                       
+                                   event->m_folder_name = folder->getPath();           //it will be changed to the folder ptr
                                }
 
                                LogDebug("limit : " << limit);
@@ -910,21 +965,24 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
                                event ->m_sync_account_id = imessagingService->getAccountID() ;
                                event ->m_sync_limit = limit;
                                event->m_messagingService = imessagingService;
+                               imessagingService->setEventToOpId(event->opId, event);
 
-                               event->setEventType(EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER);
+                               event->setEventType(MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER);
                                event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privateData));
                                event->setForAsynchronousCall(&MessagingController::getInstance());
 
                                Api::Messaging::ReqReceiverMessageSingleton::Instance().syncFolder(event);      //load message Body
 
+#if 0
+                               DPL::SharedPtr<IExternEventCanceler<EventMessagingService> > eventCanceller =
+                                       DPL::StaticPointerCast<IExternEventCanceler<EventMessagingService> >(imessagingService);
+                               
+                               IJSExtCancelPendingOperationPrivateObject<EventMessagingService> *gcPendingOperation =
+                                       new IJSExtCancelPendingOperationPrivateObject<EventMessagingService>(event, eventCanceller);
+                               
+                               return JSObjectMake(globalContext, JSPendingOperation::getClassRef(), gcPendingOperation);
+#endif         
                                return converter->toJSValueRef(event->opId);
-               
-                       }
-                       else
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-                       }
                }
                Catch(WrtDeviceApis::Commons::UnsupportedException) {
                        return JSTizenExceptionFactory::postException(context, exception, 
@@ -935,12 +993,14 @@ JSValueRef JSMessagingService::syncFolder(JSContextRef context, JSObjectRef func
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
                Catch(WrtDeviceApis::Commons::NullPointerException) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                       return JSValueMakeNull(context);
                }
                Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
                        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                       return JSValueMakeNull(context);
                }
                Catch(WrtDeviceApis::Commons::PlatformException) {
                        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
@@ -1004,13 +1064,19 @@ JSValueRef JSMessagingService::cancelOperation(JSContextRef context, JSObjectRef
                                {       //for email.
                                        if (msgType == Api::Messaging::EMAIL)
                                        {       
+                                               IMessagePtr msg = imessagingService->getMessageFromOpId(opId);
+                                               Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                                                       
                                                if ( opType == Api::Messaging::MESSAGING_SERVICE_OP_DOWNLOAD_BODY )
                                                {       
-                                                       IMessagePtr msg = imessagingService->getMessageFromOpId(opId);
-                                                       Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
                                                        LogDebug("Cancel Download Body , handle = " << handle);
                                                        email->downloadBodyCancel(handle);
                                                }
+                                               else if ( opType == Api::Messaging::MESSAGING_SERVICE_OP_DOWNLOAD_ATTACHMENT)
+                                               {
+                                                       LogDebug("Cancel Download Attachment , handle = " << handle);
+                                                       email->downloadAttachmentCancel(handle);
+                                               }
                                                else if (  opType == Api::Messaging::MESSAGING_SERVICE_OP_SYNC )
                                                {       
                                                        LogDebug("Cancel Sync , handle = " << handle);
@@ -1066,9 +1132,119 @@ JSValueRef JSMessagingService::cancelOperation(JSContextRef context, JSObjectRef
        }
 
        LogDebug(">>>");
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSMessagingService::stopSync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
+                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       LogDebug("entered");
+
+       JSMessagingServicePriv* priv = static_cast<JSMessagingServicePriv*>(JSObjectGetPrivate(thisObject));    //get private object
+
+       if (priv)
+       {
+               IMessagingServicePtr imessagingService = priv->getObject();
+               Try
+               {
+                       LogInfo(">>> argument count : " << argumentCount);
+
+                       if ( argumentCount > 0 && !Validator(context).isCallback(arguments[0]))
+                       {
+                               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                               Api::Messaging::MessageType msgType = (Api::Messaging::MessageType)imessagingService->getType();
+                               LogInfo("msgType :" << msgType);
+
+                               int opId = converter->toLong( arguments[0]);    //Fetch operation ID
+                               int handle = imessagingService->getHandleFromOpId(opId);
+                               if ( handle < 0 )
+                               {
+                                       ThrowMsg(WrtDeviceApis::Commons::NotFoundException,"Operation ID Not found");
+                               }
+                               
+                               int opType = imessagingService->getOpTypeFromOpId(opId);
+                               LogInfo("operation ID :" << opId << " operation Type : "  << opType);
+
+                               if (msgType == Api::Messaging::EMAIL)
+                               {                       
+                                       if (  opType == Api::Messaging::MESSAGING_SERVICE_OP_SYNC )
+                                       {       
+                                               LogDebug("Cancel Sync , handle = " << handle);
+                                               imessagingService->syncCancel(handle);
+                                       }
+                                       else if ( opType == Api::Messaging::MESSAGING_SERVICE_OP_SYNC_FOLDER )
+                                       {
+                                               LogDebug("Cancel Sync Folder, handle = " << handle);
+                                               imessagingService->syncFolderCancel(handle);
+                                       }
+
+                                       //call error callback.
+                                       EventMessagingServicePtr event = imessagingService->getEventFromOpId(opId);
+                                       if (event)
+                                       {
+                                               LogDebug("get callback Manager");
+                                               EventMessagingServicePrivateDataPtr privateData = 
+                                                       DPL::StaticPointerCast<EventMessagingServicePrivateData>(event->getPrivateData());
+       
+                                               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = privateData->getCallbackManager();             //get callback manager
+                                               JSContextRef globalContext = callbackManager->getContext();
+                                               if (callbackManager)
+                                               {
+                                                       LogDebug("call error callback.");
+                                                       callbackManager->callOnError(JSDOMExceptionFactory::AbortException.make(globalContext, exception));
+                                               }
+                                       }
+
+                                       imessagingService->deleteOpId(opId);
+
+                               }
+                               else
+                               {
+                                       ThrowMsg(WrtDeviceApis::Commons::UnsupportedException, "Operation Type is mismatched");
+                               }
+                               
+                       }
+                       else
+                       {
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,"invalid argument exception");
+                       }
+
+               }
+               Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+                       LogError("Exception: " << _rethrown_exception.GetMessage());
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                                            
+               }
+               Catch (WrtDeviceApis::Commons::NotFoundException){
+                       LogError("Exception: " << _rethrown_exception.GetMessage());
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                               //JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND);                                              
+               }
+               Catch (WrtDeviceApis::Commons::UnsupportedException){
+                       LogError("Exception: " << _rethrown_exception.GetMessage());
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);                                                
+               } 
+               Catch (WrtDeviceApis::Commons::Exception){
+                       LogError("Exception: " << _rethrown_exception.GetMessage());
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);                    
+               }
+               
+       }
+       else
+       {       
+               LogDebug(" Private Object is NULL ");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::NOT_FOUND_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_FOUND);
+       }
+
+       LogDebug(">>>");
+       return JSValueMakeUndefined(context);
 }
 
+
 }
 }
 
index c6704b5..a9e076f 100755 (executable)
@@ -91,6 +91,9 @@ private :
 
        static JSValueRef cancelOperation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
                                size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+       static JSValueRef stopSync(JSContextRef context, JSObjectRef function, JSObjectRef thisObject,
+                               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
        
        /**
         * This structure contains properties and callbacks that define a type of object.
index cc58cde..8c4e83c 100755 (executable)
@@ -37,6 +37,7 @@
 
 #include "JSMessagingServiceManager.h"
 #include "MessagingController.h"
+#include "MessagingListener.h"
 #include "ConverterMessage.h"
 #include "plugin_config.h"
 #include "MessagingErrorMsg.h"
@@ -59,7 +60,7 @@ namespace Tizen1_0 {
                kJSClassAttributeNone,
                "messaging",
                NULL,
-               NULL,
+               m_property,
                m_function,
                initialize,
                finalize,
@@ -74,6 +75,11 @@ namespace Tizen1_0 {
                NULL
        };
 
+       JSStaticValue JSMessagingServiceManager::m_property[] =
+       {
+           { 0, 0, 0, 0 }
+       };
+
        JSStaticFunction JSMessagingServiceManager::m_function[] = {
                        { "getMessageServices",   JSMessagingServiceManager::getMessagingServices,         kJSPropertyAttributeNone },
                        { 0, 0, 0 }
@@ -111,6 +117,7 @@ namespace Tizen1_0 {
        void JSMessagingServiceManager::finalize(JSObjectRef object) {
                LogDebug("enter");
                JSMessagingServiceManagerPriv* priv = static_cast<JSMessagingServiceManagerPriv*>(JSObjectGetPrivate(object));
+               MessagingListener::getInstance().deregisterMessageReceivedEmitter();
 
                if (priv) {
                        JSObjectSetPrivate(object, NULL);
@@ -133,216 +140,123 @@ JSValueRef JSMessagingServiceManager::getMessagingServices(JSContextRef context,
                const JSValueRef arguments[], JSValueRef* exception) 
 {
                LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
-
                JSMessagingServiceManagerPriv* priv = static_cast<JSMessagingServiceManagerPriv*>(JSObjectGetPrivate(thisObject));
-               JSContextRef gContext = priv->getContext();
+               if (!priv) {
+                       LogError("Null pointer");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                          JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);         
+               }
 
-               assert(priv && "Invalid private pointer.");
+               JSContextRef gContext = priv->getContext();             
                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
                Validator check(context, exception);
 
+               if (argumentCount < 2) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               
                LogInfo(">>> argument count : " << argumentCount);
-
-               //argument[0] : service type
-               //argument[1] : success callback
-               //argument[2] : error callback (optional)
-               //argument[3] : AccountID (optional)
-
                int messagingType = -1;
                int accountId = -1;
+               bool accountIdFlag = false;
 
                WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(gContext);     //create callback manager
                
                Try{
-                       if ( argumentCount >= 2 ) 
-                       {
-                               if ( !check.isCallback(arguments[0]) && check.isCallback(arguments[1]))
-                               {
-                                       messagingType = converter->toMessageType(arguments[0]);
-                                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-                               }
-                               else
-                               {
-                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
-                               }
 
-                               if ( argumentCount == 3 )
-                               {
-                                       if ( check.isCallback(arguments[2]))
-                                       {
-                                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-                                       }
-                                       else
-                                       {
-                                               std::stringstream ss;
-                                               ss << converter->toString(arguments[3]);        
-                                               ss >> accountId;
-                                               LogDebug("acount Id : " << accountId );
-                                       }
-                                       
-                               }
-
-                               if ( argumentCount == 4 )
-                               {       
-                                       if ( check.isCallback(arguments[2]))
-                                       {
-                                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-                                       }
-                                       else
-                                       {
-                                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);        
-                                       }
-                                       
-                                       std::stringstream ss;
-                                       ss << converter->toString(arguments[3]);
-                                       if (ss.fail()) {
-                                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);        
-                                       }
-                                       ss >> accountId;
-                                       LogDebug("acount Id : " << accountId );
-                               }
-                                                               
-                               if ( argumentCount > 4 )
-                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);                                        
+                       // argu 1. message type (mandatory)
+                       if (JSValueIsString(context, arguments[0]))
+                               messagingType = converter->toMessageType(arguments[0]);
+                       else
+                               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       
+                       //argu 2. success callback.
+                       if ( check.isCallback(arguments[1]))
+                       {
+                               callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
                        }
                        else
                        {
                                Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                        }
-                       
+                       //argu 3. error callback (optional & nullable)
+                       if ( argumentCount > 2)
+                       {
+                               if ( check.isCallback(arguments[2]))
+                                       callbackManager->setOnError(arguments[2]);
+                               else if(check.isNullOrUndefined(arguments[2]))
+                                       callbackManager->setOnError(NULL);
+                               else
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                       }       
+                       //arg 4. optional account ID
+                       if ( argumentCount > 3)
+                       {
+                               accountId = converter->toInt(arguments[3]);
+                               LogDebug("acount Id : " << accountId );
+                               accountIdFlag = true;
+                       }
+               }
+               Catch (WrtDeviceApis::Commons::InvalidArgumentException)
+               {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch (WrtDeviceApis::Commons::Exception)
+               {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
+               
+               try {
                        LogDebug("Messaging Service Type =" << messagingType);
 
                        // JSCallbackManager contains function pointers of successCallback and errorCallback.
                        // The function pointers is be using to return results to Javascriptcore.  So JSCallbackManager should be executed by main thread.
        
-
-                  //check permission.
+                       //check permission.
                        AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(), MessagingExportedNames[MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE]);
+                               MessagingExportedNames[MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE]);
                        TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, callbackManager);
                        
-                       LogDebug("create event");
-                       EventGetMessagingServicePtr event(new EventGetMessagingService());      //create event
-                       LogDebug("pendingOperation");
-                                       
-                       LogDebug("IMessagingServiceManagerPtr");
+                       EventGetMessagingServicePtr event(new EventGetMessagingService());      //create event          
+                       
                        IMessagingServiceManagerPtr messagingServiceManager(priv->getObject());
-                       LogDebug("setPrivateData");
+                       
                        event->setPrivateData(StaticPointerCast<IEventPrivateData> (callbackManager));  //callback manager
-                       LogDebug("setForAsynchronousCall");
                        event->setForAsynchronousCall(&MessagingController::getInstance());
 
                        event->setEventType(EventGetMessagingService::MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ALL);
-                       if ( accountId >= 0 )   //if vaild account id
-                               event->setAccountID(accountId);
+                       if (accountIdFlag)
+                       {
+                               if ( accountId > 0 )            //vaild account id must be positive number.
+                               {
+                                       event->setAccountID(accountId);
+                               }
+                               else
+                               {       // invaild value.
+                                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
+                                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
+                                       return JSValueMakeUndefined(context);
+                               }
+                       }
                        event->setMessagingServiceType(messagingType);
 
                        messagingServiceManager->getMessagingServiceManager(event);     //call postEvent
-
-               }Catch (WrtDeviceApis::Commons::PendingOperationException){
-               
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        
-               
-               }Catch (WrtDeviceApis::Commons::ConversionException){
-
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);        
                        
-               }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
-               
-                       return JSTizenExceptionFactory::postException(context, exception,
-                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-                       
-               }Catch(WrtDeviceApis::Commons::Exception){
-                       LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-       
+                       return makePendingOperation(gContext, event);
+               }
+               Catch(WrtDeviceApis::Commons::Exception)
+               {
                        return JSTizenExceptionFactory::postException(context, exception,
                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
                }
 
                LogInfo(">>>");
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
 }
 
-#if 0
-       JSValueRef JSMessagingServiceManager::getMessagingService(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception)
-       {
-               LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
-
-               JSMessagingServiceManagerPriv* priv = static_cast<JSMessagingServiceManagerPriv*>(JSObjectGetPrivate(thisObject));
-               JSContextRef gContext = priv->getContext();
-
-               assert(priv && "Invalid private pointer.");
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-               Validator check(context, exception);
-
-               LogInfo(">>> argument count : " << argumentCount);
-
-               int messagingServiceType = -1;
-               int accountID = -1;     // account not implemente yet.
-
-               //check arguments.
-               if (!check.isCallback(arguments[0]) || !check.isCallback(arguments[1])) {
-                       LogError("Wrong callbacks parameters");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               } else if ( argumentCount != 4) {
-                       LogError("Wrong parameters count :" << argumentCount);
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-               } else {
-                       accountID = converter.toLong(arguments[2]);
-                       messagingServiceType = converter.toLong(arguments[3]);
-               }
-
-               LogDebug("Messaging Service Type =" << messagingServiceType);
-
-               // JSCallbackManager contains function pointers of successCallback and errorCallback.
-               // The function pointers is be using to return results to Javascriptcore.  So JSCallbackManager should be executed by main thread.
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), arguments[0], arguments[1]));
-           //check permission.
-               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-               priv->getContext(),
-               MessagingExportedNames[MESSAGING_FUNCTION_API_GET_MESSAGING_SERVICE]);
-               TIZEN_ASYNC_CBM_ACCESS_HANDLER(status, context, cbm);
-
-               EventGetMessagingServicePtr event(new EventGetMessagingService());      //create event
-               JSObjectRef pendingOperation = WrtDeviceApis::CommonsJavaScript::makePendingOperation(gContext, event);
-
-               Try{
-                       IMessagingServiceManagerPtr messagingServiceManager(priv->getObject());
-
-                       event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
-                       event->setForAsynchronousCall(&MessagingController::getInstance());
-
-                       event->setEventType(EventGetMessagingService::MESSAGING_SERVICE_MANAGER_EVENT_TYPE_ACCOUNT);
-                       event->setAccountID(accountID);
-                       event->setMessagingServiceType(messagingServiceType);
-
-                       messagingServiceManager->getMessagingServiceManager(event);     //call postEvent
-               }Catch (WrtDeviceApis::Commons::PendingOperationException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,              
-                                                               JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED));
-               }Catch (WrtDeviceApis::Commons::ConversionException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,              
-                                                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH));
-               }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,              
-                                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-               }Catch(WrtDeviceApis::Commons::Exception){
-                       LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
-                       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,              
-                                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
-               }
-
-               LogInfo(">>>");
-               return pendingOperation;
-       }
-#endif
 
 }
 }
index 8a7793a..f146893 100755 (executable)
@@ -23,6 +23,7 @@
  */
 
 #include "JSMessagingStorage.h"
+#include "JSMessagingService.h"
 #include "MessagingListener.h"
 #include "ConverterMessage.h"
 #include "MessagingStorageMultiCallback.h"
@@ -60,10 +61,11 @@ namespace Tizen1_0 {
 
        JSClassRef JSMessagingStorage::m_jsClassRef = NULL;
 
-       JSClassDefinition JSMessagingStorage::m_classInfo = {
+       JSClassDefinition JSMessagingStorage::m_classInfo = 
+       {
                0,
                kJSClassAttributeNone,
-               "messagingStorage",
+               "messageStorage",
                NULL,
                NULL,
                m_function,
@@ -80,7 +82,8 @@ namespace Tizen1_0 {
                NULL
        };
 
-       JSStaticFunction JSMessagingStorage::m_function[] = {
+       JSStaticFunction JSMessagingStorage::m_function[] = 
+       {
                        { "addDraftMessage",                    JSMessagingStorage::addDraftMessage,                                     kJSPropertyAttributeNone },            
                        { "findMessages",                       JSMessagingStorage::findMessages,                                        kJSPropertyAttributeNone },
                        { "removeMessages",                     JSMessagingStorage::removeMessages,                      kJSPropertyAttributeNone },
@@ -95,343 +98,545 @@ namespace Tizen1_0 {
                        { 0, 0, 0 }
        };
 
-       const JSClassRef JSMessagingStorage::getClassRef() {
-               if (!m_jsClassRef) {
+       const JSClassRef JSMessagingStorage::getClassRef() 
+       {
+               if (!m_jsClassRef) 
+               {
                        m_jsClassRef = JSClassCreate(&m_classInfo);
                }
                return m_jsClassRef;
        }
 
-       void JSMessagingStorage::initialize(JSContextRef context, JSObjectRef object) {
+       void JSMessagingStorage::initialize(JSContextRef context, JSObjectRef object) 
+       {
                LogDebug("creation messaging instance");
-
-               MessagingListener* priv = new MessagingListener(context);
-               JSObjectSetPrivate(object, static_cast<void*>(priv));
-               LogDebug("global context=" << priv->getContext());
-
        }
 
-       void JSMessagingStorage::finalize(JSObjectRef object) {
+       void JSMessagingStorage::finalize(JSObjectRef object) 
+       {
                LogDebug("enter");
-               MessagingListener* priv =
-                       static_cast<MessagingListener*>(JSObjectGetPrivate(object));
-               if (priv) {
-                       // deregister from incoming message notifications
-                       priv->deregisterMessageReceivedEmitter();
 
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(object));
+               if (priv)
+               {
                        LogDebug("deleting private object (messaging)");
                        // for messaging object, private object is shared pointer, so will be deleted automatically
                        delete priv;
                        // object will be deleted, but used to show that private object is deleted
                        JSObjectSetPrivate(object, NULL);
                }
-
        }
 
-       bool JSMessagingStorage::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       bool JSMessagingStorage::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) 
+       {
                return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
        }
 
        JSValueRef JSMessagingStorage::getProperty(JSContextRef context, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
-               {
+       {
                LogDebug("<<< ");
                JSValueRef retVal = NULL;
 
-               Try{
+               Try
+               {
                        Converter convert(context);
-                       if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_INBOX")) {
+                       if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_INBOX")) 
+                       {
                                LogDebug("FOLDER_INBOX" << ":" << "1");
                                retVal = convert.toJSValueRef(Api::Messaging::INBOX);
-                       } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_OUTBOX")) {
+                       }
+                       else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_OUTBOX")) 
+                       {
                                LogDebug("FOLDER_OUTBOX" << ":" << "2");
                                retVal = convert.toJSValueRef(Api::Messaging::OUTBOX);
-                       } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_DRAFTS")) {
+                       }
+                       else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_DRAFTS")) 
+                       {
                                LogDebug("FOLDER_DRAFTS" << ":" << "3");
                                retVal = convert.toJSValueRef(Api::Messaging::DRAFTBOX);
-                       } else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_SENTBOX")) {
+                       }
+                       else if (JSStringIsEqualToUTF8CString(propertyName, "FOLDER_SENTBOX")) 
+                       {
                                LogDebug("FOLDER_SENTBOX" << ":" << "4");
                                retVal = convert.toJSValueRef(Api::Messaging::SENTBOX);
-                       } else{
+                       }
+                       else
+                       {
                                retVal = JSValueMakeUndefined(context);
+                       }
                }
-               }Catch (WrtDeviceApis::Commons::Exception){
+               Catch (WrtDeviceApis::Commons::Exception)
+               {
                        LogError("Exception: " << _rethrown_exception.GetMessage());
                        return JSTizenExceptionFactory::postException(context, exception, 
                           JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-
-       }
+               }
 
                LogDebug(">>>");
                return retVal;
        }
 
        JSValueRef JSMessagingStorage::addDraftMessage(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-
-       LogDebug("<<<");
-
-       MessagingListener* priv = static_cast<MessagingListener*>
-       (JSObjectGetPrivate(thisObject));
-
-       if (!priv) {
-               LogError(">>> Null pointer");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                  JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-
-       }
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
 
-       JSContextRef globalContext = priv->getContext();
+               LogDebug("<<<");
 
-       if (argumentCount < 1) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-       }
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
-       WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-       Try {
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                       priv->getContext(),
                        MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE]);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-               Api::Messaging::EventAddDraftMessagePtr event(new Api::Messaging::EventAddDraftMessage());
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+               
+               Try
+               {
+                       Api::Messaging::EventAddDraftMessagePtr event(new Api::Messaging::EventAddDraftMessage());
 
                        FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-               if (argumentCount > 1) {
-                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-               }
-               
-               if (argumentCount > 2) {
-                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-               }
-               
-               event->msg = converter->toIMessage(arguments[0]);
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
 
-        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(
-                                  callbackManager));
-        event->setForAsynchronousCall(priv);
+                       if(argumentCount >= 1)  // Message object
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       event->msg = converter->toIMessage(arguments[0]);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Invalid argument exception");
+                                       Throw(ConversionException);                     
+                               }
+                       }               
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[1]))    //nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
+                       }
+               
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
+                       event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
 
-        Api::Messaging::ReqReceiverMessageSingleton::Instance().addDraftMessage(event);
+                       Api::Messaging::ReqReceiverMessageSingleton::Instance().addDraftMessage(event);
 
-        return JSValueMakeNull(context);
-       }Catch(WrtDeviceApis::Commons::ConversionException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::NullPointerException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-               LogError(">>> InvalidValuesException");
-               if(argumentCount < 3)
+                       return makePendingOperation(context, event);
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
                {
+                       LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-               }                       
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-       }Catch(WrtDeviceApis::Commons::PlatformException) {
-               LogError(">>> UnknownException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-       }               
-
-       LogError(">>> JSValueMakeNull");
-       return JSValueMakeNull(context);
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
+                       LogError(">>> TypeMismatchException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError(">>> InvalidValuesException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError(">>> UnknownException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
+
+               LogError(">>> JSValueMakeNull");
+               return JSValueMakeNull(context);
+                               
        
        }
 
 
-               JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-                       const JSValueRef arguments[], JSValueRef* exception) {
+       JSValueRef JSMessagingStorage::findMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception)
+       {
 
                LogDebug("<<<");
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-               (JSObjectGetPrivate(thisObject));
-
-               if (!priv) {
-                       LogError(">>> Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                          JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSContextRef globalContext = priv->getContext();
-
-               if (argumentCount < 2) {
-                       LogError(">>> TypeMismatchException");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
-
-               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-               Try {
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
 
-                       //check permission.
-                       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
-                               MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_MESSAGES]);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+               
+               Try
+               {
                        Api::Messaging::EventQueryMessagesPtr event(new Api::Messaging::EventQueryMessages());
-                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
-                       LogDebug("start filter");
-                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
-                       event->setFilter(filter);
-                       LogDebug("end filter");
-                       callbackManager->setOnSuccess(converter->toFunction(arguments[1]));     
                        
-                       if(argumentCount > 2)
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
                        {
-                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
                        }
-
-                       if ((argumentCount >= 3) && !JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) {
-                               switch(argumentCount){
-                                       case 6:{
-                                               long offset = filterConverter->toLong(arguments[5]);
-                                               LogDebug("offset:" << offset);
-                                               event->setOffset(offset);
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
                                        }
-                                       case 5:{
-                                               long limit = filterConverter->toLong(arguments[4]);
-                                               LogDebug("limit:" << limit);
-                                               event->setLimit(limit);
+                               }
+                       }
+
+                       if(argumentCount >= 1)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
+                                       event->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(argumentCount >= 4)  //optional SortMode? sortMode
+                       {
+                               if(JSValueIsObject(context, arguments[3]))
+                               {
+                                       Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
+                                       event->setSortMode(sortMode);
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[3]))    //nullable
+                               {
+                                       LogDebug("SortMode type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }               
+                       if(argumentCount >= 5)  //optional unsigned long? limit JSValueIsUndefined(context, arguments[0]), JSValueIsNull(context, arguments[0])
+                       {
+                               if (!Validator(context).isNullOrUndefined(arguments[4]))
+                               {
+                                       if (!JSValueIsNumber(context, arguments[4]))
+                                       {
+                                               Throw(ConversionException);                                     
                                        }
-                                       case 4:{
-                                               Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
-                                               event->setSortMode(sortMode);
-                                               break;
+                                       long limit = filterConverter->toULong(arguments[4]);
+                                       event->setLimit(limit);
+                               }                       
+                       }               
+                       if(argumentCount >= 6)  //optional unsigned long? offset JSValueIsUndefined(context, arguments[0]), JSValueIsNull(context, arguments[0])
+                       {
+                               if (!Validator(context).isNullOrUndefined(arguments[5]))
+                               {
+                                       if (!JSValueIsNumber(context, arguments[5]))
+                                       {
+                                               Throw(ConversionException);                                     
                                        }
+                                       long offset = filterConverter->toULong(arguments[5]);
+                                       event->setOffset(offset);                                       
                                }
+                       }               
+                       
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
                        }
 
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
-                       event->setForAsynchronousCall(priv);
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().queryMessages(event);
 
                        LogError(">>>");
-                       return JSValueMakeNull(context);
-               }Catch(WrtDeviceApis::Commons::ConversionException) {
+                       return makePendingOperation(context, event);
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::NullPointerException) {
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
                        LogError(">>> InvalidValuesException");
-                       if(argumentCount < 3)
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-                       }                       
-                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-               }Catch(WrtDeviceApis::Commons::PlatformException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
                        LogError(">>> UnknownException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-               }               
+               }
 
                LogError(">>> JSValueMakeNull");
                return JSValueMakeNull(context);
        }
 
        JSValueRef JSMessagingStorage::removeMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-                       const JSValueRef arguments[], JSValueRef* exception) {
-
-               LogDebug("enter");
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-               (JSObjectGetPrivate(thisObject));
+               LogDebug("<<<");
 
-               if (!priv) {
-                       LogError("Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSContextRef globalContext = priv->getContext();
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-               if (argumentCount < 1) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-               Try {
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-                       //check permission.
-                       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
-                               MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_MESSAGES]);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                       
+               Try 
+               {
 
                        Api::Messaging::EventDeleteMessagesPtr event(new Api::Messaging::EventDeleteMessages());
+                       
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
+                       JSObjectRef objArg = NULL;
 
-                       if (argumentCount > 1) {
-                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
                        }
 
-                       if (argumentCount > 2) {
-                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                       if(argumentCount >= 1)  // Message object
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       objArg = converter->toJSObjectRef(arguments[0]);                                
+                               }
+                               else
+                               {
+                                       LogDebug("Invalid argument exception");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[1]))    //nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
                        }
 
                        std::vector<Api::Messaging::IMessagePtr> msgs;
-                               
-                       JSObjectRef objArg = converter->toJSObjectRef(arguments[0]);
+                                               
                        LogDebug("array length "<<JSGetArrayLength(context, objArg));
-                       for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++){
+                       for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++)
+                       {
                                JSValueRef element = JSGetArrayElement(context, objArg, i);
                                JSObjectRef arg = JSValueToObject(context, element, NULL);
                                Api::Messaging::IMessagePtr msg = converter->toIMessage(arg);
                                msgs.push_back(msg);
                        }
-                               event->msgArray = msgs;
+
+                       event->msgArray = msgs;
 
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
-                       event->setForAsynchronousCall(priv);
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().deleteMessages(event);
 
-                       return JSValueMakeNull(context);
-               }Catch(WrtDeviceApis::Commons::ConversionException) {
+                       return makePendingOperation(context, event);
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException)
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::NullPointerException) {
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
                        LogError(">>> InvalidValuesException");
-                       if(argumentCount < 3)
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-                       }
-                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-               }Catch(WrtDeviceApis::Commons::PlatformException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
                        LogError(">>> UnknownException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
@@ -440,199 +645,322 @@ namespace Tizen1_0 {
                return JSValueMakeNull(context);
        }
 
-    JSValueRef JSMessagingStorage::updateMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
-
-    LogDebug("enter");
-
-    MessagingListener* priv = static_cast<MessagingListener*>
-        (JSObjectGetPrivate(thisObject));
-
-    if (!priv) {
-        LogError("Null pointer");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       JSValueRef JSMessagingStorage::updateMessages(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
 
-    }
+               LogDebug("<<<");
 
-    JSContextRef globalContext = priv->getContext();
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-    if (argumentCount < 1) {
-          return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
-    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(
-            globalContext);
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-    ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-       
-    Try {
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                       priv->getContext(),
                        MessagingExportedNames[MESSAGING_FUNCTION_API_UPDATE_MESSAGES]);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-        Api::Messaging::EventUpdateMessagesPtr event(new Api::Messaging::EventUpdateMessages());
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-               if (argumentCount > 1) {
-                       callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
-               }
-               
-               if (argumentCount > 2) {
-                       callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
-               }
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                       
+               Try 
+               {
 
+                       Api::Messaging::EventUpdateMessagesPtr event(new Api::Messaging::EventUpdateMessages());
 
-               std::vector<Api::Messaging::IMessagePtr> msgs;
-               
-               JSObjectRef objArg = converter->toJSObjectRef(arguments[0]);
-               LogDebug("array length "<<JSGetArrayLength(context, objArg));
-               for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++)
-               {
-                       JSValueRef element = JSGetArrayElement(context, objArg, i);
-                       JSObjectRef arg = JSValueToObject(context, element, NULL);
-                       Api::Messaging::IMessagePtr msg = converter->toIMessage(arg);
-                       msgs.push_back(msg);
-               }
-               event->msgArray = msgs;
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(
-                                  callbackManager));
-        event->setForAsynchronousCall(priv);
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-        Api::Messaging::ReqReceiverMessageSingleton::Instance().updateMessages(event);
+                       JSObjectRef objArg = NULL;
 
-        return JSValueMakeNull(context);
-       }
-       Catch(WrtDeviceApis::Commons::ConversionException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::NullPointerException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-               LogError(">>> InvalidValuesException");
-               if(argumentCount < 3)
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
+
+                       if(argumentCount >= 1)  // Message object
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       objArg = converter->toJSObjectRef(arguments[0]);                                
+                               }
+                               else
+                               {
+                                       LogDebug("Invalid argument exception");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[1]))    //nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
+                       }
+
+                       std::vector<Api::Messaging::IMessagePtr> msgs;
+                       LogDebug("array length "<<JSGetArrayLength(context, objArg));
+                       for (std::size_t i = 0; i < JSGetArrayLength(context, objArg); i++)
+                       {
+                               JSValueRef element = JSGetArrayElement(context, objArg, i);
+                               JSObjectRef arg = JSValueToObject(context, element, NULL);
+                               Api::Messaging::IMessagePtr msg = converter->toIMessage(arg);
+                               msgs.push_back(msg);
+                       }
+
+                       event->msgArray = msgs;
+                       event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
+
+                       Api::Messaging::ReqReceiverMessageSingleton::Instance().updateMessages(event);
+
+                       return makePendingOperation(context, event);
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
+                       LogError(">>> TypeMismatchException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
                {
+                       LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-               }               
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-       }Catch(WrtDeviceApis::Commons::PlatformException) {
-               LogError(">>> UnknownException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError(">>> InvalidValuesException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError(">>> UnknownException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
+               return JSValueMakeNull(context);
        }
 
-    return JSValueMakeNull(context);
-    }
-
        JSValueRef JSMessagingStorage::findConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception)
+                       const JSValueRef arguments[], JSValueRef* exception)
        {
 
                LogDebug("<<<");
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-               (JSObjectGetPrivate(thisObject));
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               if (!priv) {
-                       LogError(">>> Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSContextRef globalContext = priv->getContext();
-
-               if (argumentCount < 2) {
-                       LogError(">>> TypeMismatchException");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-               Try {
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-                       //check permission.
-                       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
-                               MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_CONVERSATIONS]);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                       
+               Try 
+               {
                        Api::Messaging::EventQueryConversationsPtr event(new Api::Messaging::EventQueryConversations());
-
+                       
                        FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
-                       event->setFilter(filter);
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-                       callbackManager->setOnSuccess(converter->toFunction(arguments[1]));
-                       
-                       if (argumentCount > 2)
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
                        {
-                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
                        }
-
-                       // setup message filter
-                       if ((argumentCount >= 3) && !JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0]))
+                       else
                        {
-                               switch(argumentCount)
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
                                {
-                                       case 6:
+                                       if(objectPriv->getIndex()  < 1)
                                        {
-                                               long offset = filterConverter->toLong(arguments[5]);
-                                               LogDebug("offset:" << offset);
-                                               event->setOffset(offset);
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
                                        }
-                                       case 5:
+                               }
+                       }
+
+                       if(argumentCount >= 1)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
+                                       event->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(argumentCount >= 4)  //optional SortMode? sortMode
+                       {
+                               if(JSValueIsObject(context, arguments[3]))
+                               {
+                                       Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
+                                       event->setSortMode(sortMode);
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[3]))    //nullable
+                               {
+                                       LogDebug("SortMode type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }               
+                       if(argumentCount >= 5)  //optional unsigned long? limit JSValueIsUndefined(context, arguments[0]), JSValueIsNull(context, arguments[0])
+                       {
+                               if (!Validator(context).isNullOrUndefined(arguments[4]))
+                               {
+                                       if (!JSValueIsNumber(context, arguments[4]))
                                        {
-                                               long limit = filterConverter->toLong(arguments[4]);
-                                               LogDebug("limit:" << limit);
-                                               event->setLimit(limit);
+                                               Throw(ConversionException);                                     
                                        }
-                                       case 4:
+                                       long limit = filterConverter->toULong(arguments[4]);
+                                       event->setLimit(limit);
+                               }                       
+                       }               
+                       if(argumentCount >= 6)  //optional unsigned long? offset JSValueIsUndefined(context, arguments[0]), JSValueIsNull(context, arguments[0])
+                       {
+                               if (!Validator(context).isNullOrUndefined(arguments[5]))
+                               {
+                                       if (!JSValueIsNumber(context, arguments[5]))
                                        {
-                                               Api::Tizen::SortModePtr sortMode = filterConverter->toSortMode(arguments[3]);
-                                               event->setSortMode(sortMode);
-                                               break;
+                                               Throw(ConversionException);                                     
                                        }
+                                       long offset = filterConverter->toULong(arguments[5]);
+                                       event->setOffset(offset);                                       
                                }
                        }
-
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
+                       }
+                       
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
-                       event->setForAsynchronousCall(priv);
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().queryConversations(event);
 
-                       return JSValueMakeNull(context);
+                       return makePendingOperation(context, event);
                }
-               Catch(WrtDeviceApis::Commons::ConversionException) {
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::NullPointerException) {
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
                        LogError(">>> InvalidValuesException");
-                       if(argumentCount < 3)
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-                       }
-                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));                   
-               }Catch(WrtDeviceApis::Commons::PlatformException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
                        LogError(">>> UnknownException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
@@ -640,81 +968,141 @@ namespace Tizen1_0 {
 
                LogError(">>> JSValueMakeNull");
                return JSValueMakeNull(context);
-
-
        }
 
        JSValueRef JSMessagingStorage::removeConversations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception)
+                       const JSValueRef arguments[], JSValueRef* exception)
        {
-               LogDebug("enter");
+               LogDebug("<<<");
 
-               MessagingListener* priv = static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               if (!priv) {
-                       LogError("Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSContextRef globalContext = priv->getContext();
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-               if (argumentCount < 1) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(
-               globalContext);
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                               MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
                ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                       
+               Try 
+               {
 
-               Try {
+                       Api::Messaging::EventDeleteConversationsPtr event(new Api::Messaging::EventDeleteConversations());
+                       
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-                       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
-                               MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CONVERSATIONS]);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-                       Api::Messaging::EventDeleteConversationsPtr event(new Api::Messaging::EventDeleteConversations());
+                       std::vector<Api::Messaging::IConversationPtr> deleteConversationArray;
 
-                       if (argumentCount > 1) {
-                               callbackManager->setOnSuccess(converter->toFunctionOrNull(arguments[1]));
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
                        }
 
-                       if (argumentCount > 2) {
-                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                       if(argumentCount >= 1)  // Message object
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       deleteConversationArray = converter->toVectorOfConversation(arguments[0]);                              
+                               }
+                               else
+                               {
+                                       LogDebug("Invalid argument exception");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[1]))    //nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
                        }
-                       //check permission.
 
-                       std::vector<Api::Messaging::IConversationPtr> deleteConversationArray = converter->toVectorOfConversation(arguments[0]);
                        event->setConversations(deleteConversationArray);
                        event->setFilterUsing(false);
 
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
-                       event->setForAsynchronousCall(priv);
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().deleteConversations(event);
 
+                       return makePendingOperation(context, event);
                }
-               Catch(WrtDeviceApis::Commons::ConversionException) {
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::NullPointerException) {
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
                        LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-               }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
                        LogError(">>> InvalidValuesException");
-                       if(argumentCount < 3)
-                       {
-                               return JSTizenExceptionFactory::postException(context, exception, 
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-                       }
-                       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));                   
-               }Catch(WrtDeviceApis::Commons::PlatformException) {
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
                        LogError(">>> UnknownException");
                        return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
@@ -723,440 +1111,657 @@ namespace Tizen1_0 {
        }
 
        JSValueRef JSMessagingStorage::findFolders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception)
+                       const JSValueRef arguments[], JSValueRef* exception)
        {
+               LogDebug("<<<");
 
-               LogDebug("enter");
-
-               MessagingListener* priv = static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               if (!priv) {
-                       LogError("Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               JSContextRef globalContext = priv->getContext();
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-               if (argumentCount < 2) {
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
-               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS]);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-               // TODO : need to re-implement for supporting filter
-               Try {
-                       //check permission.
-                       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-                               priv->getContext(),
-                               MessagingExportedNames[MESSAGING_FUNCTION_API_FIND_FOLDERS]);
-                       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-                       
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+               
+               Try
+               {
                        Api::Messaging::EventQueryFoldersPtr event(new Api::Messaging::EventQueryFolders());
-       
-                       // setup message filter
+                       
                        FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);                                                         
-                       event->setFilter(filter);
+                       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
 
-                       callbackManager->setOnSuccess(converter->toFunction(arguments[1]));     
-                       
-                       if(argumentCount > 2)
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
                        {
-                               callbackManager->setOnError(converter->toFunctionOrNull(arguments[2]));
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
+       
+                       if(argumentCount >= 1)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[0]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[0]);
+                                       event->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);             
+                               }
+                       }
+                       if(argumentCount >= 2)  // successCallback
+                       {
+                               if(Validator(context).isCallback(arguments[1]))
+                               {
+                                       onSuccessForCbm = arguments[1];
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
+                       if(argumentCount >= 3)  //optional ErrorCallback? errorCallback
+                       {       
+                               if(Validator(context).isCallback(arguments[2]))
+                               {
+                                       onErrorForCbm = arguments[2];
+                               }
+                               else if(!Validator(context).isNullOrUndefined(arguments[2]))    //nullable
+                               {
+                                       LogDebug("ErrorCallback type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                               callbackManager->setOnError(onErrorForCbm);
                        }
 
                        event->setPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData >(callbackManager));
-                       event->setForAsynchronousCall(priv);
+                       event->setForAsynchronousCall(&MessagingListener::getInstance());
+                       event->setIndex(objectPriv->getIndex());
+                       event->setType(objectPriv->getType());
 
                        Api::Messaging::ReqReceiverMessageSingleton::Instance().queryFolders(event);
 
-                       return JSValueMakeNull(context);
+                       return makePendingOperation(context, event);
 
-       }
-       Catch(WrtDeviceApis::Commons::ConversionException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::NullPointerException) {
-               LogError(">>> TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-       }Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-               LogError(">>> InvalidValuesException");
-               if(argumentCount < 3)
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
                {
+                       LogError(">>> TypeMismatchException");
                        return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);                    
-               }               
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
-       }Catch(WrtDeviceApis::Commons::PlatformException) {
-               LogError(">>> UnknownException");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-       }
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::NullPointerException) 
+               {
+                       LogError(">>> TypeMismatchException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError(">>> InvalidValuesException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError(">>> UnknownException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
 
-    return JSValueMakeNull(context);
-    }
+               return JSValueMakeNull(context);
+       }
 
        JSValueRef JSMessagingStorage::addMessagesChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
 
-               LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
+               LogDebug("<<<");
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-                       (JSObjectGetPrivate(thisObject));
-                       
-               if (!priv) {
-                       LogError("Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-               }
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               if (argumentCount < 1 ||
-                       JSValueIsUndefined(context, arguments[0]) ||
-                       JSValueIsNull(context, arguments[0]))
+               if (!priv) 
                {
-                       LogError("bad argument");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               MessagingListener* listener =
-                       static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
-               if (!listener) {
-                       LogError("no private object");
-                       return JSValueMakeUndefined(context);
-               }
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-    Try
-    {
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-               priv->getContext(),
-               MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER]);      
-
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_MESSAGES_CHANGE_LISTNER]);      
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-        ConverterMessageFactory::ConverterType converter =
-            ConverterMessageFactory::getConverter(context);
-        JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
-
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
-                                                                                                               NULL,
-                                                                                                               NULL);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm(NULL);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm(NULL);
+               
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-               OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
-               int funtionIndex = result.functionIndex;
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
 
-               callbackManager->setOnSuccess(result.messagesAdded);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
+               Try
+               {
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
+                       JSValueRef onSuccessForCbm = NULL;
 
-               EventOnMessagingStorageChangesPrivateDataPtr privData(
-                       new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       OnMessagesChanged functionResult;
+                       int funtionIndex = -1;
+                       
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
 
-        //filter
-        if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
-        {
-            FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
-            privData->setFilter(filterConverter->toFilter(arguments[1]));
-        }
+                       if(argumentCount >= 1)  // successCallback
+                       {
+                               if(!Validator(context).isNullOrUndefined(arguments[0]))
+                               {
+                                       functionResult = converter->toMessageMultifunctions(arguments[0]);
+                                       funtionIndex = functionResult.functionIndex;
+                                       
+                                       onSuccessForCbm = functionResult.messagesAdded;
+                                       messagesUpdatedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesUpdated, NULL);
+                                       messagesRemovedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesRemoved, NULL);
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
 
-               listener->registerMessageReceivedEmitter(privData);
+                       if(funtionIndex < 0)
+                       {
+                               LogError("funtionIndex is not valid");
+                               Throw(ConversionException);                     
+                       }
 
-        // add to map and return index
-        return JSValueMakeNumber(context,
-                                 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
+                       EventOnMessagingStorageChangesPrivateDataPtr privData(
+                               new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       
+                       if(argumentCount >= 2)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[1]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[1]);
+                                       privData->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                       }
 
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-        LogError("Invalid argument exception");
-         return JSTizenExceptionFactory::postException(context, exception, 
-                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-    Catch(WrtDeviceApis::Commons::UnsupportedException) {
-        LogError("Unsupported exception");
-               return JSTizenExceptionFactory::postException(context, exception, 
-               JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
-    }
-    Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
-        LogError("Already in use exception");
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        LogError("not registered for incoming message notifications");
-    }
-
-    return JSValueMakeUndefined(context);
-    }
+                       privData->setIndex(objectPriv->getIndex());
+                       privData->setType(objectPriv->getType());                       
 
-       JSValueRef JSMessagingStorage::addConversationsChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
+                       MessagingListener::getInstance().registerMessageReceivedEmitter(privData);
 
-               LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
+                       // add to map and return index
+                       return JSValueMakeNumber(context,
+                                       MessagingListener::getInstance().addIncomingMsgCallback(callbackManager, funtionIndex));
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-                       (JSObjectGetPrivate(thisObject));
-                       
-               if (!priv) {
-                       LogError("Null pointer");
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
+                       LogError("Error on conversion");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+                       LogError("Invalid argument exception");
                        return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
                }
-
-               if (argumentCount < 1 ||
-                       JSValueIsUndefined(context, arguments[0]) ||
-                       JSValueIsNull(context, arguments[0]))
+               Catch(WrtDeviceApis::Commons::UnsupportedException) 
                {
-                       LogError("bad argument");
+                       LogError("Unsupported exception");
                        return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                                       JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
                }
+               Catch(WrtDeviceApis::Commons::AlreadyInUseException) 
+               {
+                       LogError("Already in use exception");
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError("not registered for incoming message notifications");
+               }
+
+               return JSValueMakeUndefined(context);
+       }
+
+       JSValueRef JSMessagingStorage::addConversationsChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
+               LogDebug("<<<");
+
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               MessagingListener* listener =
-                       static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
-               if (!listener) {
-                       LogError("no private object");
-                       return JSValueMakeUndefined(context);
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-    Try
-    {
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
+
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-               priv->getContext(),
-               MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER]);         
-
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_CONVERSATIONS_CHANGE_LISTNER]);         
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-        ConverterMessageFactory::ConverterType converter =
-            ConverterMessageFactory::getConverter(context);
-        JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm(NULL);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm(NULL);
+               
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
-                                                                                                               NULL,
-                                                                                                               NULL);
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
 
-               OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
-               int funtionIndex = result.functionIndex;
+               Try
+               {
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-               callbackManager->setOnSuccess(result.messagesAdded);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
+                       JSValueRef onSuccessForCbm = NULL;
 
+                       OnMessagesChanged functionResult;
+                       int funtionIndex = -1;
+                       
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
 
-               EventOnMessagingStorageChangesPrivateDataPtr privData(
-                       new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       if(argumentCount >= 1)  // successCallback
+                       {
+                               if(!Validator(context).isNullOrUndefined(arguments[0]))
+                               {
+                                       functionResult = converter->toMessageMultifunctions(arguments[0]);
+                                       funtionIndex = functionResult.functionIndex;
+                                       
+                                       onSuccessForCbm = functionResult.messagesAdded;
+                                       messagesUpdatedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesUpdated, NULL);
+                                       messagesRemovedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesRemoved, NULL);
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
 
-        //filter
-        if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
-        {
-            FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
-            privData->setFilter(filterConverter->toFilter(arguments[1]));
-        }
+                       if(funtionIndex < 0)
+                       {
+                               LogError("funtionIndex is not valid");
+                               Throw(ConversionException);                     
+                       }
 
-               listener->registerMessageReceivedEmitter(privData);
+                       EventOnMessagingStorageChangesPrivateDataPtr privData(
+                               new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       
+                       if(argumentCount >= 2)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[1]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[1]);
+                                       privData->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                       }
 
-        // add to map and return index
-        return JSValueMakeNumber(context,
-                                 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
+                       privData->setIndex(objectPriv->getIndex());
+                       privData->setType(objectPriv->getType());                       
+               
+                       MessagingListener::getInstance().registerMessageReceivedEmitter(privData);
 
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-        LogError("Invalid argument exception");
-         return JSTizenExceptionFactory::postException(context, exception, 
+                       // add to map and return index
+                       return JSValueMakeNumber(context,
+                                       MessagingListener::getInstance().addIncomingMsgCallback(callbackManager, funtionIndex));
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
+                       LogError("Error on conversion");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError("Invalid argument exception");
+                       return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-    Catch(WrtDeviceApis::Commons::UnsupportedException) {
-        LogError("Unsupported exception");
-               return JSTizenExceptionFactory::postException(context, exception, 
-               JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
-    }
-    Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
-        LogError("Already in use exception");
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        LogError("not registered for incoming message notifications");
-    }
-
-    return JSValueMakeUndefined(context);
-    }
+               }
+               Catch(WrtDeviceApis::Commons::UnsupportedException) 
+               {
+                       LogError("Unsupported exception");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
+               }
+               Catch(WrtDeviceApis::Commons::AlreadyInUseException) 
+               {
+                       LogError("Already in use exception");
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError("not registered for incoming message notifications");
+               }
+
+               return JSValueMakeUndefined(context);
+       }
 
 
        JSValueRef JSMessagingStorage::addFoldersChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
+                       const JSValueRef arguments[], JSValueRef* exception) 
+       {
 
-               LogInfo("<<<");
-               LogDebug("arumentConunt:" << argumentCount);
+               LogDebug("<<<");
 
-               MessagingListener* priv = static_cast<MessagingListener*>
-                       (JSObjectGetPrivate(thisObject));
-                       
-               if (!priv) {
-                       LogError("Null pointer");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-               }
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
 
-               if (argumentCount < 1 ||
-                       JSValueIsUndefined(context, arguments[0]) ||
-                       JSValueIsNull(context, arguments[0]))
+               if (!priv) 
                {
-                       LogError("bad argument");
-                       return JSTizenExceptionFactory::postException(context, exception, 
-                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
                }
 
-               MessagingListener* listener =
-                       static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
-               if (!listener) {
-                       LogError("no private object");
-                       return JSValueMakeUndefined(context);
-               }
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
 
-    Try
-    {
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
 
                //check permission.
                AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-               priv->getContext(),
-               MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER]);       
-
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_FOLDERS_CHANGE_LISTNER]);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
-        ConverterMessageFactory::ConverterType converter =
-            ConverterMessageFactory::getConverter(context);
-        JSContextRef l_globalContext = converter->toJSGlobalContext(thisObject);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm(NULL);
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm(NULL);
+               
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
+
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+
+               Try
+               {
 
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager =
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManager::createObject(l_globalContext,
-                                                                                                               NULL,
-                                                                                                               NULL);
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
-               OnMessagesChanged result = converter->toMessageMultifunctions(arguments[0]);
-               int funtionIndex = result.functionIndex;
+                       JSValueRef onSuccessForCbm = NULL;
 
-               callbackManager->setOnSuccess(result.messagesAdded);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesUpdatedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesUpdated, NULL);
-               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr messagesRemovedCbm = JSCallbackManager::createObject(listener->getContext(), result.messagesRemoved, NULL);
+                       OnMessagesChanged functionResult;
+                       int funtionIndex = -1;
+                       
+                       if((objectPriv->getType() < Api::Messaging::SMS) || (objectPriv->getType() > Api::Messaging::EMAIL))
+                       {
+                               ThrowMsg(InvalidArgumentException, "Message type is not SMS or MMS or EMAIL.");
+                       }
+                       else
+                       {
+                               if(objectPriv->getType() == Api::Messaging::EMAIL)
+                               {
+                                       if(objectPriv->getIndex()  < 1)
+                                       {
+                                               ThrowMsg(InvalidArgumentException, "serviceId is not defined.");
+                                       }
+                               }
+                       }
+
+                       if(argumentCount >= 1)  // successCallback
+                       {
+                               if(!Validator(context).isNullOrUndefined(arguments[0]))
+                               {
+                                       functionResult = converter->toMessageMultifunctions(arguments[0]);
+                                       funtionIndex = functionResult.functionIndex;
+                                       
+                                       onSuccessForCbm = functionResult.messagesAdded;
+                                       messagesUpdatedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesUpdated, NULL);
+                                       messagesRemovedCbm = JSCallbackManager::createObject(priv->getContext(), functionResult.messagesRemoved, NULL);
+                               }
+                               else // NOT nullable
+                               {
+                                       LogDebug("SuccessCallback type is mismatched.");
+                                       Throw(ConversionException);
+                               }
+                       }
 
+                       if(funtionIndex < 0)
+                       {
+                               LogError("funtionIndex is not valid");
+                               Throw(ConversionException);                     
+                       }
 
-               EventOnMessagingStorageChangesPrivateDataPtr privData(
-                       new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       EventOnMessagingStorageChangesPrivateDataPtr privData(
+                               new EventOnMessagingStorageChangesPrivateData(callbackManager, messagesUpdatedCbm, messagesRemovedCbm, funtionIndex));
+                       
+                       if(argumentCount >= 2)  //optional AbstractFilter? filter
+                       {
+                               if(JSValueIsObject(context, arguments[1]))
+                               {
+                                       Api::Tizen::FilterPtr filter = filterConverter->toFilter(arguments[1]);
+                                       privData->setFilter(filter);
+                               }
+                               else    // NOT nullable 
+                               {
+                                       LogDebug("Filter type is mismatched.");
+                                       Throw(ConversionException);                     
+                               }
+                       }
+                       if(callbackManager)
+                       {
+                               callbackManager->setOnSuccess(onSuccessForCbm);
+                       }
 
-        //filter
-        if ((argumentCount == 2) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]))
-        {
-            FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
-            privData->setFilter(filterConverter->toFilter(arguments[1]));
-        }
+                       privData->setIndex(objectPriv->getIndex());
+                       privData->setType(objectPriv->getType());
 
-               listener->registerMessageReceivedEmitter(privData);
+                       MessagingListener::getInstance().registerMessageReceivedEmitter(privData);
 
-        // add to map and return index
-        return JSValueMakeNumber(context,
-                                 listener->addIncomingMsgCallback(callbackManager, funtionIndex));
+                       // add to map and return index
+                       return JSValueMakeNumber(context,
+                                       MessagingListener::getInstance().addIncomingMsgCallback(callbackManager, funtionIndex));
 
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("Error on conversion");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
-        LogError("Invalid argument exception");
-         return JSTizenExceptionFactory::postException(context, exception, 
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
+                       LogError("Error on conversion");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError("Invalid argument exception");
+                       return JSTizenExceptionFactory::postException(context, exception, 
                                        JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-    Catch(WrtDeviceApis::Commons::UnsupportedException) {
-        LogError("Unsupported exception");
-               return JSTizenExceptionFactory::postException(context, exception, 
-               JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
-    }
-    Catch(WrtDeviceApis::Commons::AlreadyInUseException) {
-        LogError("Already in use exception");
-    }
-    Catch(WrtDeviceApis::Commons::PlatformException) {
-        LogError("not registered for incoming message notifications");
-    }
-
-    return JSValueMakeUndefined(context);
-    }
-
-    JSValueRef JSMessagingStorage::removeChangeListener(JSContextRef context,
-        JSObjectRef function,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-    {
-    LogInfo("entered");
-
-    MessagingListener* priv = static_cast<MessagingListener*>
-        (JSObjectGetPrivate(thisObject));
-
-    if (!priv) {
-        LogError("Null pointer");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-    }
-
-    if (argumentCount < 1) {
-        LogError("wrong argument count");
-               return JSTizenExceptionFactory::postException(context, exception, 
-                                JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-    }
-
-       //check permission.
-       AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
-       priv->getContext(),
-       MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER]);   
-       
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-
-    MessagingListener* listener =
-        static_cast<MessagingListener*>(JSObjectGetPrivate(thisObject));
-    if (!listener) {
-        LogError("no private object");
-        return JSValueMakeUndefined(context);
-    }
-
-    WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-    Try {
-        double handler = converter.toDouble(arguments[0]);
-        listener->removeIncomingMsgCallback(handler);
-    }
-    Catch(WrtDeviceApis::Commons::ConversionException) {
-        LogError("conversion error");
-          return JSTizenExceptionFactory::postException(context, exception, 
-                                JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
-    }
-
-    return JSValueMakeUndefined(context);
-    }
+               }
+               Catch(WrtDeviceApis::Commons::UnsupportedException) 
+               {
+                       LogError("Unsupported exception");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);        // unsupported type
+               }
+               Catch(WrtDeviceApis::Commons::AlreadyInUseException) 
+               {
+                       LogError("Already in use exception");
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) 
+               {
+                       LogError("not registered for incoming message notifications");
+               }
 
+               return JSValueMakeUndefined(context);
+       }
+
+       JSValueRef JSMessagingStorage::removeChangeListener(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, 
+                       const JSValueRef arguments[], JSValueRef* exception)
+       {
+               LogDebug("<<<");
+
+               MessagingStoragePriv* priv = static_cast<MessagingStoragePriv*>(JSObjectGetPrivate(thisObject));
+
+               long handler = -1;
+               
+               if (!priv) 
+               {
+                       LogDebug("priv is NULL.");
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+
+               MessagingStoragePrivObjPtr objectPriv = priv->getObject();
+
+               if (!objectPriv)
+               {
+                       LogDebug("objectPriv is NULL.");                
+                       return JSTizenExceptionFactory::postException(
+                               context, exception, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+
+               //check permission.
+               AceSecurityStatus status = MESSAGING_CHECK_ACCESS(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_REMOVE_CHANGE_LISTENER]);   
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager(NULL);
+               callbackManager = JSCallbackManager::createObject(priv->getContext());
+
+               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+
+               Try 
+               {
+                       FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
+               
+                       if(argumentCount >= 1)  //optional unsigned long? limit JSValueIsUndefined(context, arguments[0]), JSValueIsNull(context, arguments[0])
+                       {
+                               if (!Validator(context).isNullOrUndefined(arguments[0]))
+                               {
+                                       if (!JSValueIsNumber(context, arguments[0]))
+                                       {
+                                               Throw(ConversionException);                                     
+                                       }
+                                       handler = filterConverter->toLong(arguments[0]);
+                               }
+                               else
+                               {
+                                       Throw(ConversionException);
+                               }
+                       }               
+                       if(handler < 0)
+                       {
+                               LogError("handler is not valid");
+                               Throw(ConversionException);                     
+                       }
+                       MessagingListener::getInstance().removeIncomingMsgCallback(handler, objectPriv->getType(), objectPriv->getIndex());
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) 
+               {
+                       LogError("conversion error");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
+               {
+                       LogError(">>> InvalidValuesException");
+                       return JSTizenExceptionFactory::postException(context, exception, 
+                                       JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               return JSValueMakeUndefined(context);
+       }
 
 }
 }
index 1fdc8fa..6b0da45 100755 (executable)
 
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
+#include "MessagingListener.h"
+
 
 namespace TizenApis {
 namespace Tizen1_0 {
 
+class MessagingStoragePrivObj
+{
+public:
+       long m_index;
+       int m_type;
+//     MessagingListener instance;
+
+long getIndex() const
+{
+       return m_index;
+}
+
+int getType() const
+{
+       return m_type;
+}
+       
+};
+
+typedef DPL::SharedPtr<MessagingStoragePrivObj> MessagingStoragePrivObjPtr;
+       
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<MessagingStoragePrivObjPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> MessagingStoragePriv;
+
 class JSMessagingStorage {
 public:
 //@struct JSClassDefinition
index 1c82123..9b7759c 100755 (executable)
@@ -126,15 +126,15 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventMessagingS
                DPL::StaticPointerCast<EventMessagingServicePrivateData>(event->getPrivateData());
        
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = privateData->getCallbackManager();             //get callback manager
-       JSContextRef l_globalContext = callbackManager->getContext();
+       JSContextRef globalContext = callbackManager->getContext();
 
        int MessagingServiceEventType = event->getEventType();
        LogDebug(" MessagingServiceEvent Type :" << MessagingServiceEventType); 
 
        ConverterMessageFactory::ConverterType converter =
-                ConverterMessageFactory::getConverter(l_globalContext);
+                ConverterMessageFactory::getConverter(globalContext);
 
-       if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY)
+       if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_BODY)
        {       
                LogDebug(" Message Sync Folder");
                LogDebug("Operation ID : " << event->opId);
@@ -153,7 +153,7 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventMessagingS
                        callbackManager->callOnError(msg);
                }
        }
-       else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
+       else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_LOAD_MESSAGE_ATTACHMENT)
        {
                if (event->getExceptionCode() == ExceptionCodes::None)
                {
@@ -166,7 +166,7 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventMessagingS
                        callbackManager->callOnError();
                }
        }
-       else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC)
+       else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC)
        {       
                LogDebug(" Message Sync :");
                LogDebug("Operation ID : " << event->opId);
@@ -182,7 +182,7 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventMessagingS
                        callbackManager->callOnError();
                }
        }
-       else if (MessagingServiceEventType == EventMessagingService::MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER)
+       else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SYNC_FOLDER)
        {       
                LogDebug(" Message Sync Folder");
                LogDebug("Operation ID : " << event->opId);
@@ -197,9 +197,59 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventMessagingS
                        callbackManager->callOnError();
                }
        }
+       else if (MessagingServiceEventType == MESSAGING_SERVICE_EVENT_TYPE_SEND_MESSAGE)
+       {
+               JSValueRef error = NULL;
+               WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr recipientCallbackManager = privateData->getRecipientCallbackManager();
+
+               if (WrtDeviceApis::Commons::ExceptionCodes::None != event->getExceptionCode()) {
+                       switch (event->getExceptionCode()) {
+                               case WrtDeviceApis::Commons::ExceptionCodes::PlatformException:
+                               case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
+                                       error = JSTizenExceptionFactory::makeErrorObject(globalContext,           
+                                                 JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                               default:
+                                       error = JSTizenExceptionFactory::makeErrorObject(globalContext,           
+                                                 JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+                       }
+                 }
+                 
+                 ConverterMessage converter(globalContext);
+                
+                 //remove operation handle
+                 if (event->m_messagingService)
+                 {
+                         LogDebug("Operation ID : " << event->opId);
+                         event->m_messagingService->deleteOpId(event->opId); 
+                 }
+                 if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) 
+                 {
+                         LogDebug(" success size : " << event->m_successRecipients.size());
+                         std::vector<JSValueRef> successRecipentList;
+                         
+                         int cnt = event->m_successRecipients.size();
+                         LogDebug( "success count : " << cnt);
+               
+                         for(int index = 0; index < cnt; index++)
+                         {
+                                 LogDebug( "success recipent : " << event->m_successRecipients[index]);
+                                 successRecipentList.push_back(converter.toJSValueRef(event->m_successRecipients[index]));
+                         }
+                                         
+                         JSObjectRef result = JSObjectMakeArray(globalContext, cnt, successRecipentList.data(), NULL);
+                         callbackManager->callOnSuccess(result);
+                          
+                 } 
+                 else {
+                         //JSValueRef params[] = { error, recipient };
+                         //callbackManager->callOnError( params, sizeof(params) / sizeof(params[0]));
+                         callbackManager->callOnError(error);
+                 }
+               
+       }
        else 
        {
-               callbackManager->callOnError(JSValueMakeUndefined(l_globalContext));
+               callbackManager->callOnError(JSValueMakeUndefined(globalContext));
        }
        
 }
@@ -231,7 +281,7 @@ void MessagingController::OnAnswerReceived(const Api::Messaging::EventSendMessag
     }
                
        ConverterMessage converter(context);
-       JSValueRef recipient = converter.toJSValueRef(event->getRecipient());
+       //JSValueRef recipient = converter.toJSValueRef(event->getRecipient());
 
        //remove operation handle
        if (event->m_messagingService)
index 24452ed..c9c908c 100755 (executable)
@@ -51,10 +51,8 @@ using namespace TizenApis::Api::Messaging;
 using namespace TizenApis::Commons;
 
 
-MessagingListener::MessagingListener(JSContextRef context) :
-    WrtDeviceApis::CommonsJavaScript::PrivateObjectT<void>::Type(context),
+MessagingListener::MessagingListener() :
     EventAddDraftMessageAnswerReceiver(ThreadEnum::NULL_THREAD),
-    EventSendMessageAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventQueryMessagesAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventDeleteMessagesAnswerReceiver(ThreadEnum::NULL_THREAD),
     EventUpdateMessagesAnswerReceiver(ThreadEnum::NULL_THREAD),        
@@ -70,6 +68,9 @@ MessagingListener::MessagingListener(JSContextRef context) :
 {
 }
 
+MessagingListener::~MessagingListener() {
+}
+
 void MessagingListener::OnAnswerReceived(
         const Api::Messaging::EventAddDraftMessagePtr& event)
 {
@@ -78,6 +79,9 @@ void MessagingListener::OnAnswerReceived(
     Assert(NULL != callbackManager);
     LogDebug("thread=" << DPL::Thread::GetCurrentThread());
 
+    JSContextRef context = callbackManager->getContext();
+    Assert(NULL != context);
+
     Try
     {
         if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
@@ -94,73 +98,25 @@ void MessagingListener::OnAnswerReceived(
             }
         }
     }
-
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("platform error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
-
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
-
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("unknown error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
 }
 
 
-void MessagingListener::OnAnswerReceived(
-        const Api::Messaging::EventSendMessagePtr& event)
-{
-    LogDebug("ENTER");
-
-    EventSendMessagePrivateDataPtr privateData =
-        DPL::StaticPointerCast<EventSendMessagePrivateData>(
-            event->getPrivateData());
-    Assert(NULL != privateData);
-
-    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = privateData->getCallbackManager();
-    WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr recipientCallbackManager =
-        privateData->getRecipientCallbackManager();
-
-    if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
-        if (!event->getRecipient().empty() && recipientCallbackManager) {
-            ConverterMessage converter(m_context);
-            JSValueRef recipient = converter.toJSValueRef(event->getRecipient());
-            recipientCallbackManager->callOnSuccess(recipient);
-        } else {
-            callbackManager->callOnSuccess();
-        }
-    } else {
-        JSValueRef error = NULL;
-        switch (event->getExceptionCode()) {
-        case WrtDeviceApis::Commons::ExceptionCodes::PlatformException:
-        case WrtDeviceApis::Commons::ExceptionCodes::ConversionException:
-            error = JSTizenExceptionFactory::makeErrorObject(m_context,                
-                                               JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
-        default:
-            error = JSTizenExceptionFactory::makeErrorObject(m_context,                
-                                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
-        }
-        if (!event->getRecipient().empty() && recipientCallbackManager) {
-            ConverterMessage converter(m_context);
-            JSValueRef recipient = converter.toJSValueRef(event->getRecipient());
-            JSValueRef params[] = { error, recipient };
-            recipientCallbackManager->callOnError(params,
-                                                  sizeof(params) /
-                                                  sizeof(params[0]));
-        } else {
-            callbackManager->callOnError(error);
-        }
-    }
-}
 
 void MessagingListener::OnAnswerReceived(
         const Api::Messaging::EventQueryMessagesPtr& event)
@@ -170,13 +126,16 @@ void MessagingListener::OnAnswerReceived(
     Assert(NULL != callbackManager);
     LogDebug("thread=" << DPL::Thread::GetCurrentThread());
 
+    JSContextRef context = callbackManager->getContext();
+    Assert(NULL != context);
+
     Try
     {
         if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
             std::vector<Api::Messaging::IMessagePtr> msgs = event->msgs;
 
             ConverterMessageFactory::ConverterType converter =
-                ConverterMessageFactory::getConverter(m_context);
+                ConverterMessageFactory::getConverter(context);
 
             callbackManager->callOnSuccess(converter->toJSValueRef(msgs, this));
 
@@ -195,26 +154,26 @@ void MessagingListener::OnAnswerReceived(
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("platform error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
     {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
     }
 
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("unknown error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 }
@@ -227,6 +186,9 @@ void MessagingListener::OnAnswerReceived(
     Assert(NULL != callbackManager);
     LogDebug("thread=" << DPL::Thread::GetCurrentThread());
 
+    JSContextRef context = callbackManager->getContext();
+    Assert(NULL != context);
+
     Try
     {
         if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
@@ -246,19 +208,19 @@ void MessagingListener::OnAnswerReceived(
 
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("platform error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("unknown error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
@@ -272,6 +234,9 @@ void MessagingListener::OnAnswerReceived(
     Assert(NULL != callbackManager);
     LogDebug("thread=" << DPL::Thread::GetCurrentThread());
 
+    JSContextRef context = callbackManager->getContext();
+    Assert(NULL != context);
+
     Try
     {
         if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
@@ -291,19 +256,19 @@ void MessagingListener::OnAnswerReceived(
 
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("platform error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("unknown error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
@@ -317,11 +282,14 @@ void MessagingListener::OnAnswerReceived(
     Assert(NULL != callbackManager);
     LogDebug("thread=" << DPL::Thread::GetCurrentThread());
 
+    JSContextRef context = callbackManager->getContext();
+    Assert(NULL != context);
+
     Try
     {
         if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) {
             ConverterMessageFactory::ConverterType converter =
-                ConverterMessageFactory::getConverter(m_context);
+                ConverterMessageFactory::getConverter(context);
             callbackManager->callOnSuccess(converter->toJSValueRef(event->msg,
                                                                    this));
         } else {
@@ -338,19 +306,19 @@ void MessagingListener::OnAnswerReceived(
 
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("platform error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::ConversionException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 
     Catch(WrtDeviceApis::Commons::UnknownException) {
         LogError("conversion error");
-        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,               
+        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,         
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
     }
 }
@@ -361,12 +329,15 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryConvers
 
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
 
+       JSContextRef context = callbackManager->getContext();
+       Assert(NULL != context);
+
        Try
        {
                if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) 
                {
                        vector<IConversationPtr> convPtr = event->getConversatioins();
-                       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(m_context);
+                       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
 
                        callbackManager->callOnSuccess(converter->toJSValueRef(convPtr));
 
@@ -390,25 +361,25 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryConvers
        Catch(WrtDeviceApis::Commons::PlatformException) 
        {
                LogError("platform error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::ConversionException) 
        {
                LogError("conversion error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::InvalidArgumentException)
        {
                LogError("conversion error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,
                                                JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
        }       
        Catch(WrtDeviceApis::Commons::UnknownException) 
        {
                LogError("unknown error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
 
@@ -418,6 +389,10 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventDeleteConver
 {
        LogDebug("enter");
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
+
+       JSContextRef context = callbackManager->getContext();
+       Assert(NULL != context);
+       
        try 
        {
                if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) 
@@ -441,19 +416,19 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventDeleteConver
        Catch(WrtDeviceApis::Commons::PlatformException) 
        {
                LogError("platform error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::ConversionException) 
        {
                LogError("conversion error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::UnknownException) 
        {
                LogError("unknown error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
 }
@@ -464,6 +439,9 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryFolders
 
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = DPL::StaticPointerCast<JSCallbackManager >(event->getPrivateData());
 
+       JSContextRef context = callbackManager->getContext();
+       Assert(NULL != context);
+
        Try
        {
                if (WrtDeviceApis::Commons::ExceptionCodes::None == event->getExceptionCode()) 
@@ -472,7 +450,7 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryFolders
                        int size = folderPtr.size();
                        LogDebug(size);
                        
-                       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(m_context);
+                       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
                        callbackManager->callOnSuccess(converter->toJSValueRef(folderPtr));
                } 
                else 
@@ -494,25 +472,25 @@ void MessagingListener::OnAnswerReceived(const Api::Messaging::EventQueryFolders
        Catch(WrtDeviceApis::Commons::PlatformException) 
        {
                LogError("platform error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::ConversionException) 
        {
                LogError("conversion error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
        Catch(WrtDeviceApis::Commons::InvalidArgumentException) 
        {
                LogError("conversion error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT));
        }       
        Catch(WrtDeviceApis::Commons::UnknownException) 
        {
                LogError("unknown error");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(m_context,                
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,          
                                                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN));
        }
 
@@ -535,7 +513,11 @@ void MessagingListener::onAnswerReceived(
        EventOnMessagingStorageChangesPrivateDataPtr multiCallbacks = 
                DPL::DynamicPointerCast<EventOnMessagingStorageChangesPrivateData>(event->getPrivateData());
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr defaultCbm = multiCallbacks->getMessagesAdded();
-       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(m_context);
+
+    JSContextRef context = defaultCbm->getContext();
+       ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+
+
 
        switch(multiCallbacks->getFunctionIndex())
        {
@@ -546,18 +528,18 @@ void MessagingListener::onAnswerReceived(
                        if(filter != NULL)
                        {
                                LogDebug("Filter exist");                       
-                               Platform::Messaging::StorageChangesMessageGeneratorPtr queryGenerator(new Platform::Messaging::StorageChangesMessageGenerator(event->getMessage()));
+                               Platform::Messaging::StorageChangesMessageGeneratorPtr queryGenerator(new Platform::Messaging::StorageChangesMessageGenerator(event->getMessage(), event->getConversation()));
                        
                                Api::Tizen::IFilterVisitorPtr filterVisitor = DPL::StaticPointerCast<Api::Tizen::IFilterVisitor>(queryGenerator);
                                filter->travel(filterVisitor, 0);
-                       std::vector<Api::Messaging::IMessagePtr> msgs; // for msg
-                       Api::Messaging::IMessagePtr msg = event->getMessage();
+                               std::vector<Api::Messaging::IMessagePtr> msgs; // for msg
+                               Api::Messaging::IMessagePtr msg = event->getMessage();
                                if(queryGenerator->getCompareResult())
                                {
-                       LogDebug("Message call back");
-                       msgs.push_back(msg);
-                       jsMsg = converter->toJSValueRef(msgs, this);
-               }
+                                       LogDebug("Message call back");
+                                       msgs.push_back(msg);
+                                       jsMsg = converter->toJSValueRef(msgs, this);
+                               }
                                else
                                {
                                        LogDebug("skip");
@@ -725,11 +707,18 @@ long MessagingListener::addIncomingMsgCallback(const WrtDeviceApis::CommonsJavaS
     return handle;
 }
 
-void MessagingListener::removeIncomingMsgCallback(long handle)
+void MessagingListener::removeIncomingMsgCallback(long handle, int type, long index)
 {
     size_t msgRemoved = 0;
     size_t convRemoved = 0;
     size_t folderRemoved = 0;  
+
+    if(!checkMessagingEmitter(handle, type, index))
+    {
+        LogWarning("Try to deregister by unmatched service");
+        Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+    }
+               
     msgRemoved += m_MessageCallbacks.erase(handle);
     convRemoved += m_ConversationCallbacks.erase(handle);      
     folderRemoved += m_FolderCallbacks.erase(handle);
@@ -744,14 +733,41 @@ void MessagingListener::removeIncomingMsgCallback(long handle)
     if (msgRemoved) {
         LogWarning("EmitterMessageReceived registered");
         Api::Messaging::IMessaging::getInstance().removeOnMessageMsgReceived(temp_handle);
+        removeMessagingEmitter(temp_handle);   
+        for(unsigned int i=0; i<m_emiterMsgId.size(); i++)
+        {
+            if(temp_handle == static_cast<long>(m_emiterMsgId[i]))
+            {
+                LogWarning("handle : handle " << temp_handle<< " " << static_cast<long>(m_emiterMsgId[i]) );
+                m_emiterMsgId.erase(m_emiterMsgId.begin()+i);
+            }
+        }
     }
     else if (convRemoved) {
         LogWarning("EmitterConversationReceived registered");
         Api::Messaging::IMessaging::getInstance().removeOnMessageConvReceived(temp_handle);
+        removeMessagingEmitter(temp_handle);
+        for(unsigned int i=0; i<m_emiterConvId.size(); i++)
+        {
+            if(temp_handle == static_cast<long>(m_emiterConvId[i]))
+            {
+                LogWarning("handle : handle " << temp_handle<< " " << static_cast<long>(m_emiterConvId[i]) );
+                m_emiterConvId.erase(m_emiterConvId.begin()+i);
+            }
+        }
     }
     else if (folderRemoved) {
         LogWarning("EmitterFolderReceived registered");
         Api::Messaging::IMessaging::getInstance().removeOnMessageFolderReceived(temp_handle);
+        removeMessagingEmitter(temp_handle);
+        for(unsigned int i=0; i<m_emiterFolderId.size(); i++)
+        {
+            if(temp_handle == static_cast<long>(m_emiterFolderId[i]))
+            {
+                LogWarning("handle : handle " << temp_handle<< " " << static_cast<long>(m_emiterFolderId[i]) );
+                m_emiterFolderId.erase(m_emiterFolderId.begin()+i);
+            }
+        }
     }
        
 }
@@ -759,31 +775,41 @@ void MessagingListener::removeIncomingMsgCallback(long handle)
 void MessagingListener::registerMessageReceivedEmitter(EventOnMessagingStorageChangesPrivateDataPtr privData)
 {
 
-       if(privData->getFunctionIndex() == MESSAGES_MULTI_FUNCTION)
-       {
-
-           Api::Messaging::EmitterMessageReceivedPtr emitter(new Api::Messaging::EmitterMessageReceived());
-           emitter->setListener(this);
-               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterMsgId.push_back(emitter->getId());
-               Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
-       }
-       else if(privData->getFunctionIndex() == CONVERSATIONS_MULTI_FUNCTION)
-       {
-           Api::Messaging::EmitterConversationReceivedPtr emitter(new Api::Messaging::EmitterConversationReceived());
-           emitter->setListener(this);
-               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterConvId.push_back(emitter->getId());
-               Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
-       }
-       else// if(privData->getFunctionIndex() == FOLDERS_MULTI_FUNCTION)
-       {
-           Api::Messaging::EmitterFolderReceivedPtr emitter(new Api::Messaging::EmitterFolderReceived());
-           emitter->setListener(this);
-               emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
-           m_emiterFolderId.push_back(emitter->getId());
-               Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());           
-       }
+    Try
+    {
+        if(privData->getFunctionIndex() == MESSAGES_MULTI_FUNCTION)
+        {
+
+            Api::Messaging::EmitterMessageReceivedPtr emitter(new Api::Messaging::EmitterMessageReceived());
+            emitter->setListener(this);
+            emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
+            m_emiterMsgId.push_back(emitter->getId());
+            Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());              
+            addMessagingEmitter(static_cast<long>(emitter->getId()), privData->getType(), privData->getIndex());               
+        }
+        else if(privData->getFunctionIndex() == CONVERSATIONS_MULTI_FUNCTION)
+        {
+            Api::Messaging::EmitterConversationReceivedPtr emitter(new Api::Messaging::EmitterConversationReceived());
+            emitter->setListener(this);
+            emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
+            m_emiterConvId.push_back(emitter->getId());
+            Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());              
+            addMessagingEmitter(static_cast<long>(emitter->getId()), privData->getType(), privData->getIndex());               
+        }
+        else// if(privData->getFunctionIndex() == FOLDERS_MULTI_FUNCTION)
+        {
+            Api::Messaging::EmitterFolderReceivedPtr emitter(new Api::Messaging::EmitterFolderReceived());
+            emitter->setListener(this);
+            emitter->setEventPrivateData(DPL::StaticPointerCast<WrtDeviceApis::Commons::IEventPrivateData>(privData));// <-registerMessageReceivedEmitter()
+            m_emiterFolderId.push_back(emitter->getId());
+            Api::Messaging::IMessaging::getInstance().addOnMessageReceived(emitter, privData->getFilter(), privData->getFunctionIndex());              
+            addMessagingEmitter(static_cast<long>(emitter->getId()), privData->getType(), privData->getIndex());
+        }
+    }
+    Catch(WrtDeviceApis::Commons::PlatformException){
+        LogDebug("registerMessageReceivedEmitter failed");                             
+        Throw(WrtDeviceApis::Commons::PlatformException);
+    }
        
 }
 
@@ -822,9 +848,50 @@ void MessagingListener::deregisterMessageReceivedEmitter()
                        m_emiterFolderId.pop_back();
                }
        }
-    LogDebug("finish");
+
+       MessagingEmitterRegistersIterator it = m_requests.begin();
+
+       for (; it != m_requests.end(); it++)
+       {
+               removeMessagingEmitter(it->first);
+       }
+        LogDebug("finish");
        return;
 }
 
+bool MessagingListener::checkMessagingEmitter(long handle, int type, long index)
+{
+       int ret = FALSE;
+    MessagingEmitterRegistersIterator it = m_requests.find(handle);
+
+    LogDebug("handle, type, index"<< handle << " " << type << " " << index);
+    LogDebug("it->second.type, it->second.accountId"<< it->second.type << " " << it->second.accountId);
+       
+       if((it->second.type == type) && (it->second.accountId == index))
+       {
+               ret = TRUE;
+       }
+       return ret;     
+}
+
+void MessagingListener::addMessagingEmitter(long handle, int type, long index)
+{
+    LogDebug("handle, type, index"<< handle << " " << type << " " << index);
+       m_requests.insert(std::make_pair(handle, MessagingEmitterData(type, index)));
+}
+
+void MessagingListener::removeMessagingEmitter(long handle)
+{
+    LogDebug("handle"<< handle );
+       m_requests.erase(handle);
+}
+
+
+MessagingListener& MessagingListener::getInstance()
+{
+       static MessagingListener instance;
+       return instance;
+}
+
 }
 }
index 85d96d2..f812577 100755 (executable)
 
 namespace TizenApis {
 namespace Tizen1_0 {
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventAddDraftMessage>
-EventAddDraftMessageAnswerReceiver;    
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventSendMessage>
-EventSendMessageAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryMessages>
-EventQueryMessagesAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventDeleteMessages>
-EventDeleteMessagesAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventUpdateMessages>
-EventUpdateMessagesAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventListener<Api::Messaging::EventMessageReceived>
-EventMessageReceivedListener;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryConversations>
-EventQueryConversationsAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventDeleteConversations>
-EventDeleteConversationsAnswerReceiver;
-typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryFolders>
-EventQueryFoldersAnswerReceiver;
-
-class MessagingListener : public WrtDeviceApis::CommonsJavaScript::PrivateObjectT<void>::Type,
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventAddDraftMessage> EventAddDraftMessageAnswerReceiver;  
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryMessages> EventQueryMessagesAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventDeleteMessages> EventDeleteMessagesAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventUpdateMessages> EventUpdateMessagesAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryConversations> EventQueryConversationsAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventDeleteConversations> EventDeleteConversationsAnswerReceiver;
+typedef WrtDeviceApis::Commons::EventAnswerReceiver<Api::Messaging::EventQueryFolders> EventQueryFoldersAnswerReceiver;
+
+typedef WrtDeviceApis::Commons::EventListener<Api::Messaging::EventMessageReceived> EventMessageReceivedListener;
+
+class MessagingListener;
+typedef DPL::SharedPtr<MessagingListener> MessagingListenerPtr;
+
+class MessagingListener : 
     public EventAddDraftMessageAnswerReceiver,
-    public EventSendMessageAnswerReceiver,
     public EventQueryMessagesAnswerReceiver,
     public EventDeleteMessagesAnswerReceiver,
     public EventUpdateMessagesAnswerReceiver,
@@ -70,26 +63,20 @@ class MessagingListener : public WrtDeviceApis::CommonsJavaScript::PrivateObject
     public EventQueryFoldersAnswerReceiver
 {
   public:
-    explicit MessagingListener(JSContextRef context);
+    explicit MessagingListener();
+    virtual ~MessagingListener();      
 
     long addIncomingMsgCallback(const WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr& cbManager, int funtionIndex);
-    void removeIncomingMsgCallback(long handle);
+    void removeIncomingMsgCallback(long handle, int type, long index);
     void registerMessageReceivedEmitter(EventOnMessagingStorageChangesPrivateDataPtr privData);
     void deregisterMessageReceivedEmitter();
 
   protected:
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventAddDraftMessage> &event);
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventSendMessage> &event);
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventQueryMessages> &event);
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventDeleteMessages> &event);
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventUpdateMessages> &event);
-    virtual void OnAnswerReceived(
-            const DPL::SharedPtr<Api::Messaging::EventUpdateMessage> &event);
+    virtual void OnAnswerReceived(const DPL::SharedPtr<Api::Messaging::EventAddDraftMessage> &event);
+    virtual void OnAnswerReceived(const DPL::SharedPtr<Api::Messaging::EventQueryMessages> &event);
+    virtual void OnAnswerReceived(const DPL::SharedPtr<Api::Messaging::EventDeleteMessages> &event);
+    virtual void OnAnswerReceived(const DPL::SharedPtr<Api::Messaging::EventUpdateMessages> &event);
+    virtual void OnAnswerReceived(const DPL::SharedPtr<Api::Messaging::EventUpdateMessage> &event);
     virtual void OnAnswerReceived(const Api::Messaging::EventQueryConversationsPtr& event);
     virtual void OnAnswerReceived(const Api::Messaging::EventDeleteConversationsPtr& event);
     virtual void OnAnswerReceived(const Api::Messaging::EventQueryFoldersPtr& event);
@@ -104,9 +91,34 @@ class MessagingListener : public WrtDeviceApis::CommonsJavaScript::PrivateObject
     std::vector<Api::Messaging::EmitterMessageReceived::IdType> m_emiterMsgId;
     std::vector<Api::Messaging::EmitterConversationReceived::IdType> m_emiterConvId;
     std::vector<Api::Messaging::EmitterFolderReceived::IdType> m_emiterFolderId;
+
+    struct MessagingEmitterData//SendRequestData
+    {
+        int type;
+        long accountId;
+        explicit MessagingEmitterData(const int type, const long index) :
+        type(type),
+        accountId(index)
+        {
+        }
 };
 
-typedef DPL::SharedPtr<MessagingListener> MessagingListenerPtr;
+    typedef std::map<long, MessagingEmitterData> MessagingEmitterRegisters;
+    typedef MessagingEmitterRegisters::iterator MessagingEmitterRegistersIterator;//SendRequestsIterator;
+       
+    MessagingEmitterRegisters m_requests;      
+
+  public:
+    static MessagingListener& getInstance();
+       
+    bool checkMessagingEmitter(long handle, int type, long index);
+    void addMessagingEmitter(long handle, int type, long index);
+    void removeMessagingEmitter(long handle);  
+//     static MessagingListenerPtr getInstance(JSContextRef context);
+};
+
+typedef DPL::Singleton<MessagingListener> MessagingListenerSingleton;  //for singleton
+
 }
 }
 
index 49f2e97..0e726b9 100755 (executable)
@@ -31,6 +31,8 @@ EventOnMessagingStorageChangesPrivateData::EventOnMessagingStorageChangesPrivate
                        m_messagesUpdated(messagesUpdated), 
                        m_messagesRemoved(messagesRemoved),
                        m_functionIndex(functionIndex),
+                       m_type(-1),
+                       m_index(-1),
                        m_filter(NULL)
 {
 }
index ea721f1..1dfbb38 100755 (executable)
@@ -73,13 +73,30 @@ class EventOnMessagingStorageChangesPrivateData : public WrtDeviceApis::Commons:
                return m_filter;
        }
 
+       void setIndex(long index){
+               m_index = index;
+       }
+       
+       long getIndex(){
+               return m_index;
+       }
+       
+       void setType(int type){
+               m_type = type;
+       }
+       
+       int getType(){
+               return m_type;
+       }       
 
 private:
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_messagesAdded;
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_messagesUpdated;
        WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr m_messagesRemoved;       
        int m_functionIndex;
-       Api::Tizen::FilterPtr m_filter;         
+       int m_type;
+       long m_index;
+       Api::Tizen::FilterPtr m_filter;
 };
 
 typedef DPL::SharedPtr<EventOnMessagingStorageChangesPrivateData> EventOnMessagingStorageChangesPrivateDataPtr;
index 69253ce..8a7104d 100755 (executable)
@@ -15,7 +15,7 @@
         <Object name="messaging">
             <Function name="getMessageServices"/>
         </Object>
-    <Object name="messagingStorage">
+    <Object name="messageStorage">
             <Function name="addDraftMessage"/>    
             <Function name="findMessages"/>
             <Function name="removeMessages"/>
index aa551c9..475281d 100755 (executable)
@@ -142,45 +142,7 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions()
                        getMessagingServiceFunc));
 
       /**  Read  **/
-     AceFunction loadMessageBodyFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_GET_MGR_SERVICE,
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY],
-                       MESSAGING_FEATURES_MESSAGING_READ,
-                       EMPTY_DEVICE_LIST);
-       
-       MessagingFunctions.insert( std::make_pair(
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY],
-                       loadMessageBodyFunc));      
-
-      AceFunction loadMessageAttachmentFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_GET_MGR_SERVICE,
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT],
-                       MESSAGING_FEATURES_MESSAGING_READ,
-                       EMPTY_DEVICE_LIST);
-       
-       MessagingFunctions.insert( std::make_pair(
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT],
-                       loadMessageAttachmentFunc));
-
-      AceFunction syncFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_GET_MGR_SERVICE,
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC],
-                       MESSAGING_FEATURES_MESSAGING_READ,
-                       EMPTY_DEVICE_LIST);
-       
-       MessagingFunctions.insert( std::make_pair(
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC],
-                       syncFunc));
-
-      AceFunction syncFolderFunc = ACE_CREATE_FUNCTION(
-                       FUNCTION_GET_MGR_SERVICE,
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER],
-                       MESSAGING_FEATURES_MESSAGING_READ,
-                       EMPTY_DEVICE_LIST);
-       
-       MessagingFunctions.insert( std::make_pair(
-                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER],
-                       syncFolderFunc));
+    
 
        AceFunction cancelOpFolderFunc = ACE_CREATE_FUNCTION(
                          FUNCTION_GET_MGR_SERVICE,
@@ -286,6 +248,46 @@ static WrtDeviceApis::Commons::FunctionMapping createMessagingFunctions()
                        sendMessageFunc));
        
       /**  Write  **/
+          AceFunction loadMessageBodyFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_GET_MGR_SERVICE,
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY],
+                       MESSAGING_FEATURES_MESSAGING_WRITE,
+                       EMPTY_DEVICE_LIST);
+       
+       MessagingFunctions.insert( std::make_pair(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_BODY],
+                       loadMessageBodyFunc));      
+
+      AceFunction loadMessageAttachmentFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_GET_MGR_SERVICE,
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT],
+                       MESSAGING_FEATURES_MESSAGING_WRITE,
+                       EMPTY_DEVICE_LIST);
+       
+       MessagingFunctions.insert( std::make_pair(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_LOAD_MESSAGE_ATTACHMENT],
+                       loadMessageAttachmentFunc));
+
+      AceFunction syncFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_GET_MGR_SERVICE,
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC],
+                       MESSAGING_FEATURES_MESSAGING_WRITE,
+                       EMPTY_DEVICE_LIST);
+       
+       MessagingFunctions.insert( std::make_pair(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC],
+                       syncFunc));
+
+      AceFunction syncFolderFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_GET_MGR_SERVICE,
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER],
+                       MESSAGING_FEATURES_MESSAGING_WRITE,
+                       EMPTY_DEVICE_LIST);
+       
+       MessagingFunctions.insert( std::make_pair(
+                       MessagingExportedNames[MESSAGING_FUNCTION_API_SYNC_FOLDER],
+                       syncFolderFunc));
+       
      AceFunction addDraftMessageFunc = ACE_CREATE_FUNCTION(
                        FUNCTION_GET_MGR_SERVICE,
                        MessagingExportedNames[MESSAGING_FUNCTION_API_ADD_DRAFT_MESSAGE],
index 87979d5..6bef8ad 100755 (executable)
@@ -49,9 +49,8 @@ extern const char* MessagingExportedNames[];
 
 DECLARE_FUNCTION_GETTER(Messaging);
 
-#define MESSAGING_CHECK_ACCESS(globalContext, functionName)   \
+#define MESSAGING_CHECK_ACCESS(functionName)   \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(        \
-    globalContext,                                                            \
     getMessagingFunctionData,                                              \
     functionName)
 
index 1d88089..14ddd0a 100755 (executable)
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
-* limitations under the License. 
+* limitations under the License.
 */
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include "JSMessagingServiceManager.h"
 #include "JSMessagingStorage.h"
 #include "JSMessage.h"
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 #define OBJECT_MESSAGING ".messaging"
 
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
+void on_widget_start_callback(int widgetId) {
        LogDebug("[Tizen\\MessagingServiceManager] on_widget_start_callback ("<<widgetId<<")");
+    Try {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    } Catch(Commons::Exception) {
+        LogError("WrtAccess initialization failed");
+    }
 }
 
 void on_widget_stop_callback(int widgetId) {
        LogDebug("[Tizen\\MessagingServiceManager] on_widget_stop_callback ("<<widgetId<<")");
+    Try {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    } Catch(Commons::Exception) {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
@@ -42,14 +55,7 @@ PLUGIN_CLASS_MAP_BEGIN
                "messaging",
                TizenApis::Tizen1_0::JSMessagingServiceManager::getClassRef(),
                NULL)
-#if 1
        PLUGIN_CLASS_MAP_ADD_CLASS(
-               WRT_JS_EXTENSION_OBJECT_TIZEN OBJECT_MESSAGING,
-               "messagingStorage",
-               TizenApis::Tizen1_0::JSMessagingStorage::getClassRef(),
-               NULL)
-#endif
-     PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN,
                "Message",
                TizenApis::Tizen1_0::JSMessage::getClassRef(),
index 5b55d00..773dc3b 100755 (executable)
@@ -7,9 +7,8 @@ set(SRCS
   ${SRCS_PLATFORM_API_NFC}
   ${SRCS_PLATFORM_IMPLEMENTATION_NFC}
   JSNFCManager.cpp
+  JSNFCAdapter.cpp
   JSNFCTag.cpp
-  JSNFCTagMifareClassic.cpp
-  JSNFCTagMifareUltra.cpp
        JSNdefMessage.cpp
        JSNdefRecord.cpp
        JSNdefRecordText.cpp
diff --git a/src/standards/Tizen/NFC/JSNFCAdapter.cpp b/src/standards/Tizen/NFC/JSNFCAdapter.cpp
new file mode 100644 (file)
index 0000000..52d718f
--- /dev/null
@@ -0,0 +1,583 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "JSNFCManager.h"
+#include "JSNFCAdapter.h"
+#include "JSNdefMessage.h"
+#include "JSNdefRecord.h"
+#include "NFCConverter.h"
+#include "NFCStaticController.h"
+#include "EventNFCChangedPrivateData.h"
+
+#include <dpl/log/log.h>
+
+#include <string>
+#include <CommonsJavaScript/Validator.h>
+#include <Commons/Exception.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <API/NFC/NFCFactory.h>
+#include <API/NFC/EventNFCChanged.h>
+#include "plugin_config.h"
+
+using namespace std;
+using namespace DPL;
+using namespace TizenApis::Api::NFC;
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+#define TIZEN10_NFCADAPTER_ATTRIBUTENAME "NFCAdapter"
+#define TIZEN10_NFCADAPTER_POWERED "powered"
+#define TIZEN10_NFCADAPTER_POLLING "polling"
+namespace TizenApis {
+namespace Tizen1_0 {
+
+ JSClassDefinition JSNFCAdapter::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       TIZEN10_NFCADAPTER_ATTRIBUTENAME,
+       0,
+       m_property,
+       m_function,
+       initialize,
+       finalize,
+       NULL, //hasProperty,
+       NULL,
+       NULL, //setProperty,
+       NULL, //DeleteProperty,
+       NULL, //GetPropertyNames,
+       NULL, //CallAsFunction,
+       NULL, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL  //ConvertToType
+};
+
+JSStaticValue JSNFCAdapter::m_property[] =
+{
+    //NFCAdapterProperties
+       {TIZEN10_NFCADAPTER_POWERED,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NFCADAPTER_POLLING,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSNFCAdapter::m_function[] = {
+       {"setTagListener",      JSNFCAdapter::setTagListener, kJSPropertyAttributeNone },
+       {"unsetTagListener",       JSNFCAdapter::unsetTagListener, kJSPropertyAttributeNone},
+       {"setPeerListener",      JSNFCAdapter::setPeerListener, kJSPropertyAttributeNone },
+       {"unsetPeerListener",       JSNFCAdapter::unsetPeerListener, kJSPropertyAttributeNone},
+       {"getCachedMessage", JSNFCAdapter::getCachedMessage, kJSPropertyAttributeNone},
+       {"setPowered",      JSNFCAdapter::setPowered, kJSPropertyAttributeNone },
+       {"setPolling",      JSNFCAdapter::setPolling, kJSPropertyAttributeNone },     
+       { 0, 0, 0}
+};
+
+JSClassRef JSNFCAdapter::m_jsClassRef = JSClassCreate(JSNFCAdapter::getClassInfo());
+
+void JSNFCAdapter::initialize(JSContextRef context, JSObjectRef object)
+{
+       LogDebug("entered. Nothing to do");
+}
+
+void JSNFCAdapter::finalize(JSObjectRef object)
+{
+       NFCAdapterPrivObject* priv =
+               static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+JSObjectRef JSNFCAdapter::createJSObject(JSContextRef context, const INFCAdapterPtr &privAdapter) {
+       LogDebug("entered");
+
+       NFCAdapterPrivObject *priv = new NFCAdapterPrivObject(context, privAdapter);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NFCTag object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassRef JSNFCAdapter::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSNFCAdapter::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+JSValueRef JSNFCAdapter::getProperty(JSContextRef context, JSObjectRef object,
+        JSStringRef propertyName, JSValueRef* exception)
+{
+       LogDebug("Enter");
+
+       Try     {
+               Converter convert(context);
+
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NFCADAPTER_POWERED)) {
+                       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(object));
+                       if (!privateObject) {
+                               LogError("private object is null");
+                               ThrowMsg(NullPointerException, "Private object not initialized");
+                       }
+                       INFCAdapterPtr NFCAdapter_ptr(privateObject->getObject() );
+                       return convert.toJSValueRef(NFCAdapter_ptr->getPowerState());
+               }
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NFCADAPTER_POLLING)) {
+                       //Not Support Polling
+                       return convert.toJSValueRef(FALSE);
+               }
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnsupportedException) {
+               LogError("UnsupportedException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNFCAdapter::setTagListener (JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) {
+       LogDebug("JSNFCAdapter::setTagListener Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       NFCConverter nfcConverter(context);
+       Validator validator(context, exception);
+
+       if (argumentCount == 0) {
+               LogError("JSNFCAdapter::setTagListener TypeMismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) ) {
+               /* 1st argument is mandatory. And 1st argument must be Callback. */
+               LogError("JSNFCAdapter::setTagListener TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if (argumentCount > 1) {
+               if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
+                       /* 2nd argument must be Callback. */
+                       LogError("JSNFCAdapter::setTagListener TypeMismatchException!");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
+       }
+
+       JSValueRef onErrorForCbm = NULL;
+       NFCChangedCallback callbacks;
+
+       if (JSValueIsObject(context, arguments[0]) &&
+            !validator.isCallback(arguments[0])) {
+            callbacks = nfcConverter.toNFCChangedCallback(arguments[0]);
+       } else {
+               LogError("DetectedCB must has onattach and ondetach");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       if (argumentCount > 1) {
+               if (validator.isCallback(arguments[1])) {
+                       onErrorForCbm = arguments[1];
+               }
+       }
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       JSContextRef global_context = privateObject->getContext();
+
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onattach, onErrorForCbm, true, true);
+       JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.ondetach, NULL);
+    JSValueProtect(global_context, thisObject);
+    
+       Try {
+               INFCAdapterPtr NFCAdapter_ptr( privateObject->getObject() );
+
+               //process the filter object
+               TagFilterPtr tagFilter;
+               if ((argumentCount > 2) &&  !JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+                       if (JSIsArrayValue(context, arguments[2])) {
+                                       tagFilter = nfcConverter.toNFCTagFilter(arguments[2]);
+
+                       } else
+                               Throw(ConversionException);
+               }
+               else
+               {
+                       TagFilterPtr _filter (new TagFilter());
+                       tagFilter = _filter;
+               }
+
+               EventNFCChangedPrivateDataPtr privateData(
+                   new EventNFCChangedPrivateData(callbackManager,
+                                                   detachedCallbackManager)
+                   );
+               EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter);
+               emitter->setListener(&NFCStaticController::getInstance());
+               emitter->setEventPrivateData(StaticPointerCast<EventNFCChanged::PrivateDataType>(privateData));
+
+               if (NFCAdapter_ptr->setTagListener(emitter, tagFilter, (void *)privateObject) != 0)
+                       Throw(UnknownException);
+
+               return JSValueMakeUndefined(context);
+       } Catch (ConversionException) {
+               LogError("JSNFCAdapter::setTagListener : ConversionException");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (InvalidArgumentException) {
+               LogError("JSNFCAdapter::setTagListener InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
+    } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       }
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNFCAdapter::setPeerListener (JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) {
+       LogDebug("JSNFCAdapter::setPeerListener Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       NFCConverter nfcConverter(context);
+       Validator validator(context, exception);
+
+
+       if (argumentCount == 0) {
+               LogError("JSNFCAdapter::setPeerListener TypeMismatchException");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) ) {
+               /* 1st argument is mandatory. And 1st argument must be Callback. */
+               LogError("JSNFCAdapter::setPeerListener TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if (argumentCount > 1) {
+               if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
+                       /* 2nd argument must be Callback. */
+                       LogError("JSNFCAdapter::setPeerListener TypeMismatchException!");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
+       }
+
+       JSValueRef onErrorForCbm = NULL;
+       NFCChangedCallback callbacks;
+
+       if (JSValueIsObject(context, arguments[0]) &&
+            !validator.isCallback(arguments[0])) {
+            callbacks = nfcConverter.toNFCChangedCallback(arguments[0]);
+       } else {
+               LogError("DetectedCB must has onattach and ondetach");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       if (argumentCount > 1) {
+               if (validator.isCallback(arguments[1])) {
+                       onErrorForCbm = arguments[1];
+               }
+       }
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       JSContextRef global_context = privateObject->getContext();
+
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onattach, onErrorForCbm, true, true);
+       JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.ondetach, NULL);
+    JSValueProtect(global_context, thisObject);    
+
+       Try {
+               INFCAdapterPtr NFCAdapter_ptr( privateObject->getObject() );
+
+               EventNFCChangedPrivateDataPtr privateData(
+                   new EventNFCChangedPrivateData(callbackManager,
+                                                   detachedCallbackManager)
+                   );
+
+               EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter);
+               emitter->setListener(&NFCStaticController::getInstance());
+               emitter->setEventPrivateData(StaticPointerCast<EventNFCChanged::PrivateDataType>(privateData));
+
+               if (NFCAdapter_ptr->setPeerListener(emitter, (void *)privateObject) != 0)
+                       Throw(UnknownException);
+
+               return JSValueMakeUndefined(context);
+       } Catch (ConversionException) {
+               LogError("JSNFCAdapter::setPeerListener : ConversionException");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (InvalidArgumentException) {
+               LogError("JSNFCAdapter::setPeerListener InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       }
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeUndefined(context);
+}
+JSValueRef JSNFCAdapter::unsetTagListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
+       LogDebug("JSNFCAdapter::unsetNFCTagListener Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       Try     {
+               INFCAdapterPtr NFCs( privateObject->getObject() );
+
+               NFCs->unsetTagListener();
+               return JSValueMakeUndefined(context);
+       } Catch (NullPointerException) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSNFCAdapter::unsetPeerListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
+       LogDebug("JSNFCAdapter::unsetPeerListener Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       Try {
+               INFCAdapterPtr NFCs( privateObject->getObject() );
+
+               NFCs->unsetPeerListener();
+               return JSValueMakeUndefined(context);
+       } Catch (NullPointerException) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSNFCAdapter::getCachedMessage (JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) {
+       LogDebug("JSNFCAdapter::getCachedMessage Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       Try {
+               INFCAdapterPtr NFCAdapter_ptr( privateObject->getObject() );
+               void *cachedMessage = NFCAdapter_ptr->getCachedMessage();
+               if (cachedMessage != NULL)
+                       return JSNdefMessage::createJSObject(context, NFCAdapter_ptr->getCachedMessage());
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch(NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSNFCAdapter::setPowered (JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) {
+       LogDebug("Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_P2P_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       Validator validator(context, exception);
+    if(argumentCount == 0) {
+        /* 1st argument is mandatory. */        
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+    }
+       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
+               /* 1st argument is mandatory. And 1st argument must be Callback. */
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2])) {
+               /* 2nd argument must be Callback. */
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
+       if ((argumentCount > 1) && validator.isCallback(arguments[1])) {
+               onSuccessForCbm = arguments[1];
+       }
+       if ((argumentCount > 2) && validator.isCallback(arguments[2])) {
+               onErrorForCbm = arguments[2];
+       }
+
+       NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+       JSContextRef global_context = privateObject->getContext();
+
+       INFCAdapterPtr NFCAdapter_ptr(privateObject->getObject() );
+       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(global_context, thisObject);
+
+       Try {
+               NFCConverter nfcConverter(context);
+               bool state = false;
+               state = nfcConverter.toBool(arguments[0]);
+
+               EventNFCChangedSetPoweredPtr event(new EventNFCChangedSetPowered(state));
+               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
+               event->setForAsynchronousCall(&NFCStaticController::getInstance());
+               NFCAdapter_ptr->setPowered(event);
+               return JSValueMakeUndefined(context);
+       } Catch (ConversionException) {
+               LogError("ConversionException");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       } Catch(NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               return JSValueMakeUndefined(context);
+       }
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSNFCAdapter::setPolling (JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception) {
+       LogDebug("Enter");
+
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_P2P_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       Validator validator(context, exception);
+    if(argumentCount == 0) {
+        /* 1st argument is mandatory. */
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+    }
+       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
+               /* And 2st argument must be Callback. */
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2])) {
+               /* 3nd argument must be Callback. */
+               LogError("TypeMismatchException!");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
+    return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported");
+}
+
+}
+}
old mode 100755 (executable)
new mode 100644 (file)
similarity index 55%
rename from src/standards/Tizen/NFC/JSNFCTagMifareUltra.h
rename to src/standards/Tizen/NFC/JSNFCAdapter.h
index da43d70..b51ecc1
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
 
-#ifndef _JS_TIZEN_NFCTAGMIFAREULTRA_H_
-#define _JS_TIZEN_NFCTAGMIFAREULTRA_H_
+#ifndef _JS_TIZEN_NFCADAPTER_H_
+#define _JS_TIZEN_NFCADAPTER_H_
 
 #include <JavaScriptCore/JavaScript.h>
-#include <API/NFC/INFCTagMifareUltra.h>
+#include <API/NFC/INFCAdapter.h>
 #include <CommonsJavaScript/PrivateObject.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
 
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::NFC::INFCTagMifareUltraPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> NFCTagMifareUltraPrivObject;
-
-class JSNFCTagMifareUltra
+class JSNFCAdapter
 {
 public:
 
@@ -36,11 +34,10 @@ public:
 
     static const JSClassRef getClassRef();
 
-    static JSObjectRef createJSObject(JSContextRef context, void *tagHandle, void* privManager);
-
+    static JSObjectRef createJSObject(JSContextRef context, const Api::NFC::INFCAdapterPtr &privAdapter);
 private:
     /**
-     * This member variable contains the values which has to be passed when 
+     * This member variable contains the values which has to be passed when
      * the this class is embedded into JS Engine.
      */
     static JSClassDefinition m_classInfo;
@@ -51,10 +48,12 @@ private:
     static JSStaticFunction m_function[];
 
     /**
-     * This member variable contains the initialization values for the 
+     * This member variable contains the initialization values for the
      * properties of this class. The values are given according to the
      * data structure JSPropertySpec.
      */
+    static JSStaticValue m_property[];
+
     static JSClassRef m_jsClassRef;
 
     /**
@@ -68,31 +67,47 @@ private:
     static void finalize(JSObjectRef object);
 
     /**
-     * The callback invoked when an object is used as the target of an 'instanceof' expression.
+     * Getters  for properties
      */
-    static bool hasInstance(JSContextRef context,
-            JSObjectRef constructor,
-            JSValueRef possibleInstance,
-            JSValueRef* exception);
+    static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
+            JSStringRef propertyName, JSValueRef* exception);
+
+       static JSValueRef setTagListener(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception);
+
+       static JSValueRef unsetTagListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+       static JSValueRef setPeerListener(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception);
 
-    static JSValueRef readPage(JSContextRef context,
+       static JSValueRef unsetPeerListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
+                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef getCachedMessage(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
                const JSValueRef arguments[],
                JSValueRef* exception);
-       
-    static JSValueRef writePage(JSContextRef context,
+
+    static JSValueRef setPowered(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
                const JSValueRef arguments[],
                JSValueRef* exception);
 
-
+    static JSValueRef setPolling(JSContextRef context,
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception);         
 };
 
 }
 }
 
-#endif /* _JS_TIZEN_NFCTAGMIFAREULTRA_H_ */
+#endif /* _JS_TIZEN_NFCADAPTER_H_ */
index 0e528fd..842bdcc 100755 (executable)
 
 
 #include "JSNFCManager.h"
-#include "JSNdefMessage.h"
-#include "JSNdefRecord.h"
+#include "JSNFCAdapter.h"
 #include "NFCConverter.h"
-#include "NFCStaticController.h"
-#include "EventNFCChangedPrivateData.h"
 
 #include <dpl/log/log.h>
 
-#include <string>
-#include <CommonsJavaScript/Validator.h>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Utils.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/SecurityExceptions.h>
 #include <API/NFC/NFCFactory.h>
-#include <API/NFC/EventNFCChanged.h>
 #include "plugin_config.h"
 
 using namespace std;
@@ -93,15 +84,7 @@ JSStaticValue JSNFCManager::m_property[] =
 };
 
 JSStaticFunction JSNFCManager::m_function[] = {
-       {"setTagListener",      JSNFCManager::setTagListener, kJSPropertyAttributeNone },
-       {"unsetTagListener",       JSNFCManager::unsetTagListener, kJSPropertyAttributeNone},
-       {"setPeerListener",      JSNFCManager::setPeerListener, kJSPropertyAttributeNone },
-       {"unsetPeerListener",       JSNFCManager::unsetPeerListener, kJSPropertyAttributeNone},
-       {"setNDEFListener",      JSNFCManager::setNDEFListener, kJSPropertyAttributeNone },
-       {"unsetNDEFListener",       JSNFCManager::unsetNDEFListener, kJSPropertyAttributeNone},
-       {"setSEEventListener",      JSNFCManager::setSEEventListener, kJSPropertyAttributeNone },
-       {"unsetSEEventListener",       JSNFCManager::unsetSEEventListener, kJSPropertyAttributeNone},
-       {"getCachedMessage", JSNFCManager::getCachedMessage, kJSPropertyAttributeNone},
+       {"getDefaultAdapter",      JSNFCManager::getDefaultAdapter, kJSPropertyAttributeNone },
        { 0, 0, 0}
 };
 
@@ -109,17 +92,22 @@ JSClassRef JSNFCManager::m_jsClassRef = JSClassCreate(JSNFCManager::getClassInfo
 
 void JSNFCManager::initialize(JSContextRef context, JSObjectRef object)
 {
-       NFCManagerPrivObject* priv = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(object));
+       LogDebug( "entered" );
+       NFCAdapterPrivObject* priv = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(object));
        if (!priv) {
                Try {
-                       INFCManagerPtr NFCManager( NFCFactory::getInstance().createNFCManagerObject() );
-                       priv = new NFCManagerPrivObject(context, NFCManager);
+                       INFCAdapterPtr NFCDefaultAdapter( NFCFactory::getInstance().createNFCAdapterObject() );
+                       priv = new NFCAdapterPrivObject(context, NFCDefaultAdapter);
                        if(!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
                                LogError("Object can't store private data.");
                                delete priv;
                        }
                } Catch (UnsupportedException) {
                        LogError("UnsupportedException: " << _rethrown_exception.GetMessage());
+               } Catch (UnknownException) {
+                       LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+               } Catch (PlatformException) {
+                       LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
                } Catch (WrtDeviceApis::Commons::Exception) {
                        LogError("Exception: " << _rethrown_exception.GetMessage());
                }
@@ -129,10 +117,14 @@ void JSNFCManager::initialize(JSContextRef context, JSObjectRef object)
 void JSNFCManager::finalize(JSObjectRef object)
 {
        LogDebug( "entered" );
-       NFCManagerPrivObject *priv = static_cast<NFCManagerPrivObject*>( JSObjectGetPrivate( object ) ) ;
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting NFC Manager object");
-       delete priv;
+       NFCAdapterPrivObject *priv = static_cast<NFCAdapterPrivObject*>( JSObjectGetPrivate( object ) ) ;
+       if (priv) {
+               INFCAdapterPtr NFCAdapter_ptr(priv->getObject());
+               NFCAdapter_ptr->deinitialze();
+               JSObjectSetPrivate(object, NULL);
+               LogDebug("Deleting NFC Manager object");
+               delete priv;
+       }
 }
 
 
@@ -174,6 +166,12 @@ JSValueRef JSNFCManager::getProperty(JSContextRef context, JSObjectRef object,
                }
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnsupportedException) {
+               LogError("UnsupportedException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
@@ -181,512 +179,35 @@ JSValueRef JSNFCManager::getProperty(JSContextRef context, JSObjectRef object,
     return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSNFCManager::setTagListener (JSContextRef context, JSObjectRef object,
+JSValueRef JSNFCManager::getDefaultAdapter (JSContextRef context, JSObjectRef object,
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef* exception) {
-       LogDebug("JSNFCManager::setTagListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       JSContextRef global_context = privateObject->getContext();
-       NFCConverter nfcConverter(context);
-       Validator validator(context, exception);
+       LogDebug("Enter");
 
-       AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_P2P_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if ((argumentCount == 0) || (argumentCount > 3)) {
-               /* Argument count must be 1, 2 or 3. */
-               LogError("JSNFCManager::setTagListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) ) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCManager::setTagListener TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if (argumentCount > 1) {
-               if (!JSValueIsNull(context, arguments[1]) && !validator.isCallback(arguments[1])) {
-                       /* 2nd argument must be Callback. */
-                       LogError("JSNFCManager::setTagListener TypeMismatchException!");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               }
-       }
-
-       JSValueRef onErrorForCbm = NULL;
-       NFCChangedCallback callbacks;
-
-       if (JSValueIsObject(context, arguments[0]) &&
-            !validator.isCallback(arguments[0])) {
-            callbacks = nfcConverter.toNFCChangedCallback(arguments[0]);
-       } else {
-               LogError("DetectedCB must has onAttach and onDetach");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if (argumentCount > 1) {
-               if (validator.isCallback(arguments[1])) {
-                       onErrorForCbm = arguments[1];
-               }
-       }
-
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onAttach, onErrorForCbm, true, true);
-       JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.onDetach, NULL);
-
        Try {
-               INFCManagerPtr NFC_ptr( privateObject->getObject() );
-
-               //process the filter object
-               TagFilterPtr tagFilter;
-               if ((argumentCount > 2) &&  !JSValueIsNull(context, arguments[2])) {
-                       if (!JSValueIsUndefined(context, arguments[2]) &&
-                               JSIsArrayValue(context, arguments[2])) {
-                                       tagFilter = nfcConverter.toNFCTagFilter(arguments[2]);
-
-                       } else
-                               Throw(ConversionException);
+               NFCAdapterPrivObject* privateObject = static_cast<NFCAdapterPrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!privateObject) {
+                       LogError("private object is null");
+                       ThrowMsg(NullPointerException, "private object is null");
                }
-               else
-               {
-                       TagFilterPtr _filter (new TagFilter());
-                       tagFilter = _filter;
-               }
-
-               EventNFCChangedPrivateDataPtr privateData(
-                   new EventNFCChangedPrivateData(callbackManager,
-                                                   detachedCallbackManager)
-                   );
-               EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter);
-               emitter->setListener(&NFCStaticController::getInstance());
-               emitter->setEventPrivateData(StaticPointerCast<EventNFCChanged::PrivateDataType>(privateData));
-
-               if (NFC_ptr->setTagListener(emitter, tagFilter, (void *)privateObject) != 0)
-                       Throw(PlatformException);
-
-               return JSValueMakeNull(context);
+               return JSNFCAdapter::createJSObject(privateObject->getContext(), privateObject->getObject());
        } Catch (ConversionException) {
-               LogError("JSNFCManager::setTagListener : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::setTagListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::setPeerListener (JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) {
-       LogDebug("JSNFCManager::setPeerListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       JSContextRef global_context = privateObject->getContext();
-       NFCConverter nfcConverter(context);
-       Validator validator(context, exception);
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_P2P_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if ((argumentCount == 0) || (argumentCount > 2)) {
-               /* Argument count must be 1 or 2. */
-               LogError("JSNFCManager::setPeerListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) ) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCManager::setPeerListener TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if (argumentCount > 1) {
-               if (!JSValueIsNull(context, arguments[1]) && !validator.isCallback(arguments[1])) {
-                       /* 2nd argument must be Callback. */
-                       LogError("JSNFCManager::setPeerListener TypeMismatchException!");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               }
-       }
-
-       JSValueRef onErrorForCbm = NULL;
-       NFCChangedCallback callbacks;
-
-       if (JSValueIsObject(context, arguments[0]) &&
-            !validator.isCallback(arguments[0])) {
-            callbacks = nfcConverter.toNFCChangedCallback(arguments[0]);
-       } else {
-               LogError("DetectedCB must has onAttach and onDetach");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if (argumentCount > 1) {
-               if (validator.isCallback(arguments[1])) {
-                       onErrorForCbm = arguments[1];
-               }
-       }
-
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, callbacks.onAttach, onErrorForCbm, true, true);
-       JSCallbackManagerPtr detachedCallbackManager = JSCallbackManager::createObject(global_context, callbacks.onDetach, NULL);
-
-       Try {
-               INFCManagerPtr NFC_ptr( privateObject->getObject() );
-
-               EventNFCChangedPrivateDataPtr privateData(
-                   new EventNFCChangedPrivateData(callbackManager,
-                                                   detachedCallbackManager)
-                   );
-
-               EventNFCChangedEmitterPtr emitter(new EventNFCChangedEmitter);
-               emitter->setListener(&NFCStaticController::getInstance());
-               emitter->setEventPrivateData(StaticPointerCast<EventNFCChanged::PrivateDataType>(privateData));
-
-               if (NFC_ptr->setPeerListener(emitter, (void *)privateObject) != 0)
-                       Throw(PlatformException);
-
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::setPeerListener : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::setPeerListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::setNDEFListener (JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) {
-       LogDebug("JSNFCManager::setNDEFListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       JSContextRef global_context = privateObject->getContext();
-       Validator validator(context, exception);
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if ((argumentCount == 0) || (argumentCount > 2)) {
-               /* Argument count must be 1 or 2. */
-               LogError("JSNFCManager::setNDEFListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCManager::setNDEFListener TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if (argumentCount > 1) {
-               if (!JSValueIsNull(context, arguments[1]) && !validator.isCallback(arguments[1])) {
-                       /* 2nd argument must be Callback. */
-                       LogError("JSNFCManager::setNDEFListener TypeMismatchException!");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               }
-       }
-
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[0])) {
-                       onSuccessForCbm = arguments[0];
-       }
-       if (argumentCount > 1) {
-               if (validator.isCallback(arguments[1])) {
-                       onErrorForCbm = arguments[1];
-               }
-       }
-
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, onErrorForCbm, true, true);
-
-       Try {
-               INFCManagerPtr NFC_ptr( privateObject->getObject() );
-
-               EventNFCChangedNdefEmitterPtr emitter(new EventNFCChangedNdefEmitter);
-               emitter->setListener(&NFCStaticController::getInstance());
-               emitter->setEventPrivateData(StaticPointerCast<EventNFCChangedNdef::PrivateDataType>(callbackManager));
-
-               if (NFC_ptr->setNDEFListener(emitter) != 0)
-                       Throw(PlatformException);
-
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::setNDEFListener : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::setNDEFListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::setSEEventListener (JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) {
-       LogDebug("JSNFCManager::setSEEventListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       JSContextRef global_context = privateObject->getContext();
-       Validator validator(context, exception);
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_SE_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       if ((argumentCount == 0) || (argumentCount > 2)) {
-               /* Argument count must be 1 or 2. */
-               LogError("JSNFCManager::setSEEventListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCManager::setSEEventListener TypeMismatchException!");
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if (argumentCount > 1) {
-               if (!JSValueIsNull(context, arguments[1]) && !validator.isCallback(arguments[1])) {
-                       /* 2nd argument must be Callback. */
-                       LogError("JSNFCManager::setSEEventListener TypeMismatchException!");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-               }
-       }
-
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[0])) {
-                       onSuccessForCbm = arguments[0];
-       }
-       if (argumentCount > 1) {
-               if (validator.isCallback(arguments[1])) {
-                       onErrorForCbm = arguments[1];
-               }
-       }
-
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(global_context, onSuccessForCbm, onErrorForCbm, true, true);
-
-       Try {
-               INFCManagerPtr NFC_ptr( privateObject->getObject() );
-
-               EventNFCChangedSeEventEmitterPtr emitter(new EventNFCChangedSeEventEmitter);
-               emitter->setListener(&NFCStaticController::getInstance());
-               emitter->setEventPrivateData(StaticPointerCast<EventNFCChangedSeEvent::PrivateDataType>(callbackManager));
-
-               if (NFC_ptr->setSEEventListener(emitter) != 0)
-                       Throw(PlatformException);
-
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::setSEEventListener : ConversionException");
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::setSEEventListener InvalidArgumentException");
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::unsetTagListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
-       LogDebug("JSNFCManager::unsetNFCTagListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       Try     {
-               if (argumentCount > 0) {
-                       /* Argument count must be 0. */
-                       LogError("JSNFCManager::unsetTagListener argumentCount has to be 0");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               INFCManagerPtr NFCs( privateObject->getObject() );
-
-               NFCs->unsetTagListener();
-               return JSValueMakeNull(context);
-       } Catch (NullPointerException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
-JSValueRef JSNFCManager::unsetPeerListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
-       LogDebug("JSNFCManager::unsetPeerListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_P2P_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       Try     {
-               if (argumentCount > 0) {
-                       /* Argument count must be 0. */
-                       LogError("JSNFCManager::unsetPeerListener argumentCount has to be 0");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               INFCManagerPtr NFCs( privateObject->getObject() );
-
-               NFCs->unsetPeerListener();
-               return JSValueMakeNull(context);
-       } Catch (NullPointerException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
-JSValueRef JSNFCManager::unsetNDEFListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
-       LogDebug("JSNFCManager::unsetNDEFListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       Try     {
-               if (argumentCount > 0) {
-                       /* Argument count must be 0. */
-                       LogError("JSNFCManager::unsetNDEFListener argumentCount has to be 0");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               INFCManagerPtr NFCs( privateObject->getObject() );
-
-               NFCs->unsetNDEFListener();
-               return JSValueMakeNull(context);
-       } Catch (NullPointerException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
-JSValueRef JSNFCManager::unsetSEEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-               size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception) {
-       LogDebug("JSNFCManager::unsetSEEventListener Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_SE_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       Try {
-               if (argumentCount > 0) {
-                       /* Argument count must be 0. */
-                       LogError("JSNFCManager::unsetSEEventListener argumentCount has to be 0");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               INFCManagerPtr NFCs( privateObject->getObject() );
-
-               NFCs->unsetSEEventListener();
-               return JSValueMakeNull(context);
-       } Catch (NullPointerException) {
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-}
-
-JSValueRef JSNFCManager::getCachedMessage (JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception) {
-       LogDebug("JSNFCManager::getCachedMessage Enter");
-       NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       JSContextRef global_context = privateObject->getContext();
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       Try {
-               if (argumentCount > 0) {
-                       /* Argument count must be 0. */
-                       LogError("JSNFCManager::getCachedMessage argumentCount has to be 0");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               INFCManagerPtr NFC_ptr( privateObject->getObject() );
-               void *cachedMessage = NFC_ptr->getCachedMessage();
-               if (cachedMessage != NULL)
-                       return JSNdefMessage::createJSObject(global_context, NFC_ptr->getCachedMessage());
-       } Catch (PlatformException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
index d2dc969..b9be69e 100755 (executable)
 #define _JS_TIZEN_NFCMANAGER_H_
 
 #include <JavaScriptCore/JavaScript.h>
-#include <API/NFC/INFCManager.h>
+#include <API/NFC/INFCAdapter.h>
 #include <CommonsJavaScript/PrivateObject.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
 
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::NFC::INFCManagerPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> NFCManagerPrivObject;
-
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::NFC::INFCAdapterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> NFCAdapterPrivObject;
 class JSNFCManager
 {
 public:
@@ -73,60 +72,11 @@ private:
     static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
             JSStringRef propertyName, JSValueRef* exception);
 
-       /**
-     * register a listener to watch NFC tag.
-     */
-       static JSValueRef setTagListener(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception);
-       /**
-     * deregister the listener which was registered by using setTagListener api.
-     */
-       static JSValueRef unsetTagListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-
-       /**
-     * register a listener to watch NFC tag.
-     */
-       static JSValueRef setPeerListener(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception);
-       /**
-     * deregister the listener which was registered by using setTagListener api.
-     */
-       static JSValueRef unsetPeerListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
-       /**
-     * register a listener to watch NFC tag.
-     */
-       static JSValueRef setNDEFListener(JSContextRef context, JSObjectRef object,
+       static JSValueRef getDefaultAdapter(JSContextRef context, JSObjectRef object,
                JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                JSValueRef* exception);
-       /**
-     * deregister the listener which was registered by using setTagListener api.
-     */
-       static JSValueRef unsetNDEFListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
-       /**
-     * register a listener to watch NFC SE Event.
-     */
-       static JSValueRef setSEEventListener(JSContextRef context, JSObjectRef object,
-               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
-               JSValueRef* exception);
-       /**
-     * deregister the listener which was registered by using setSEEventListener api.
-     */
-       static JSValueRef unsetSEEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
-                       size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
-
-    static JSValueRef getCachedMessage(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
 };
 
 }
old mode 100755 (executable)
new mode 100644 (file)
index 779acfd..f4cb7cd
@@ -105,7 +105,7 @@ JSObjectRef JSNFCTag::createJSObject(JSContextRef context, void *tagHandle, void
        LogDebug("entered");
 
        INFCTagPtr NFCTag = NFCFactory::getInstance().createNFCTagObject(tagHandle);
-       NFCTag->setPrivateNFCManagerPtr(privManager);
+       NFCTag->setPrivateNFCAdapterPtr(privManager);
        
        NFCTagPrivObject *priv = new NFCTagPrivObject(context, NFCTag);
 
@@ -125,7 +125,7 @@ void JSNFCTag::finalize(JSObjectRef object)
        LogDebug( "entered" );
        NFCTagPrivObject *priv = static_cast<NFCTagPrivObject*>( JSObjectGetPrivate( object ) ) ;
        JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting timezone object");
+       LogDebug("Deleting NFCTag object");
        delete priv;
 }
 
@@ -169,18 +169,22 @@ JSValueRef JSNFCTag::getProperty(JSContextRef context, JSObjectRef object,
                        LogDebug("get Properties");
                        return convert.toJSValueRef(NFCTag->getProperties());
                } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NFCTAG_ISCONNECTED)) {
-                       NFCManagerPrivObject* privateNFCManager = static_cast<NFCManagerPrivObject*>(NFCTag->getPrivateNFCManagerPtr());
-                       if (!privateNFCManager) {
+                       NFCAdapterPrivObject* privateNFCAdapter = static_cast<NFCAdapterPrivObject*>(NFCTag->getPrivateNFCAdapterPtr());
+                       if (!privateNFCAdapter) {
                                LogError("NFC Manager Private object is not set.");
                                ThrowMsg(NullPointerException, "Private object not initialized");
                        }
-                       INFCManagerPtr NFCManager(privateNFCManager->getObject());
-                       return convert.toJSValueRef(NFCManager->isValidHandle(NFCTag->getHandle()));
+                       INFCAdapterPtr NFCAdapter(privateNFCAdapter->getObject());
+                       return convert.toJSValueRef(NFCAdapter->isValidHandle(NFCTag->getHandle()));
                }
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
@@ -204,28 +208,21 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        Validator validator(context, exception);
 
-       if ((argumentCount == 0) || (argumentCount > 2)) {
-               LogError("JSNFCTag::readNDEF TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       if (argumentCount == 0) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid Values");
        }
        if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
                LogError("JSNFCTag::readNDEF TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1])) {
-               if (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])) {
+       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
+               if (!validator.isCallback(arguments[1])) {
                        /* 2nd argument must be Callback. */
                        LogError("JSNFCTag::readNDEF TypeMismatchException!");
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -242,8 +239,16 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
                }
        }
 
+       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
+    
        Try {
                EventTagActionReadPtr event(new EventTagActionRead());
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
@@ -251,25 +256,30 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
 
                NFCTag->readNdef(event);
 
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::readNDEF : ConversionException");
+               LogError("readNDEF : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::readNDEF InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("readNDEF InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
@@ -281,72 +291,77 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 3)) {
-               LogError("JSNFCTag::writeNdef TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       if (argumentCount == 0) {
+        /* 1st argument is mandatory. */
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 1) && (!JSValueIsNull(context, arguments[1]) && (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
+       if ((argumentCount > 1) && (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1]))) {
+               /* And 2nd argument must be Callback. */
                LogError("JSNFCTag::writeNdef TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])))) {
-               /* 2nd argument must be Callback. */
+       if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2]))) {
+               /* 3rd argument must be Callback. */
                LogError("JSNFCTag::writeNdef TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 1) && (validator.isCallback(arguments[1]))) {
+       if ((argumentCount > 1) && validator.isCallback(arguments[1])) {
                onSuccessForCbm = arguments[1];
        }
 
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
+       if ((argumentCount > 2) && validator.isCallback(arguments[2])) {
                onErrorForCbm = arguments[2];
        }
 
-       void *messageHandle = convert.getMessageHandle(arguments[0]);
-       
+       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
        Try {
                EventTagActionWritePtr event(new EventTagActionWrite());
+               void *messageHandle = convert.getMessageHandle(arguments[0]);
                event->writeNdef(messageHandle);
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
                NFCTag->writeNdef(event);
                
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::writeNDEF : ConversionException");
+               LogError("writeNDEF : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::writeNDEF InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("writeNDEF InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSNFCTag::transceive(JSContextRef context,
@@ -358,79 +373,78 @@ JSValueRef JSNFCTag::transceive(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if ((argumentCount < 2) || (argumentCount > 3)) {
-               LogError("JSNFCTag::transceive TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTag::transceive TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       if (argumentCount < 2) {
+        /* 1st argument is mandatory. */
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Invalid Values");
        }
 
        if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
+               /* 2nd argument must be Callback. */
                LogError("JSNFCTag::transceive TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])))) {
-               /* 2nd argument must be Callback. */
+       if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2]))) {
+               /* 3rd argument must be Callback. */
                LogError("JSNFCTag::transceive TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       
-       std::vector<unsigned char> data = convert.toVectorOfUChars(arguments[0]);
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
        if (validator.isCallback(arguments[1])) {
                onSuccessForCbm = arguments[1];
        }
 
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
+       if ((argumentCount > 2) && validator.isCallback(arguments[2])) {
                onErrorForCbm = arguments[2];
        }
 
+       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
        Try {
                EventTagActionTransceivePtr event(new EventTagActionTransceive());
+               std::vector<unsigned char> data = convert.toVectorOfUChars(arguments[0]);
                event->transceive(data);
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
                NFCTag->transceive(event);
                
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::transceive : ConversionException");
+               LogError("transceive : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::transceive InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("transceive InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
@@ -442,28 +456,18 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount > 3) {
-               LogError("JSNFCTag::formatNDEF TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-       if ((argumentCount > 0) && !JSValueIsNull(context, arguments[0]) && (JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0]))) {
+       if ((argumentCount > 0) && !JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0]) && !validator.isCallback(arguments[0])) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
                LogError("JSNFCTag::formatNDEF TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1]))) {
+       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1])) {
                /* 2nd argument must be Callback. */
                LogError("JSNFCTag::formatNDEF TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -479,17 +483,24 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
        }
 
        std::vector<unsigned char> key;
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2])){
-               if (JSValueIsUndefined(context, arguments[2]) || !JSIsArrayValue(context, arguments[2])) {
+       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])){
+               if (!JSIsArrayValue(context, arguments[2])) {
                        /* 2nd argument must be Callback. */
                        LogError("JSNFCTag::formatNDEF TypeMismatchException!");
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
                key = convert.toVectorOfUChars(arguments[2]);
        }
+
+       NFCTagPrivObject* privateObject = static_cast<NFCTagPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
        
        INFCTagPtr NFCTag(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
        Try {
                EventTagActionFormatPtr event(new EventTagActionFormat());
                event->format(key);
@@ -497,25 +508,30 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
                NFCTag->format(event);
                
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::formatNDEF : ConversionException");
+               LogError("formatNDEF : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::formatNDEF InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("formatNDEF InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 }
diff --git a/src/standards/Tizen/NFC/JSNFCTagMifareClassic.cpp b/src/standards/Tizen/NFC/JSNFCTagMifareClassic.cpp
deleted file mode 100755 (executable)
index a72bef0..0000000
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "JSNFCTagMifareClassic.h"
-#include "NFCConverter.h"
-#include "ResponseDispatcher.h"
-#include "JSNFCTag.h"
-#include <dpl/log/log.h>
-
-#include <CommonsJavaScript/Validator.h>
-#include <Commons/Exception.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Utils.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/SecurityExceptions.h>
-#include <API/NFC/NFCFactory.h>
-#include <API/NFC/EventTagMifareClassicAction.h>
-
-#include "plugin_config.h"
-
-
-using namespace TizenApis::Api::NFC;
-using namespace TizenApis::Commons;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace DPL;
-
-#define TIZEN10_NFCTTAGMIFARECLASSIC_ATTRIBUTENAME "NFCTagMifareClassic"
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
- JSClassDefinition JSNFCTagMifareClassic::m_classInfo =
-{
-    0,
-    kJSClassAttributeNone,
-    TIZEN10_NFCTTAGMIFARECLASSIC_ATTRIBUTENAME,
-    JSNFCTag::getClassRef(),
-    NULL,
-    m_function,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL,
-    NULL, //setProperty,
-    NULL, //DeleteProperty,
-    NULL, //GetPropertyNames,
-    NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    hasInstance, //HasInstance,
-    NULL  //ConvertToType
-};
-
-JSStaticFunction JSNFCTagMifareClassic::m_function[] = {
-    {"authenticateWithKeyA", JSNFCTagMifareClassic::authenticateWithKeyA, kJSPropertyAttributeNone},
-    {"authenticateWithKeyB", JSNFCTagMifareClassic::authenticateWithKeyB, kJSPropertyAttributeNone},
-    {"readBlock", JSNFCTagMifareClassic::readBlock, kJSPropertyAttributeNone},
-    {"writeBlock", JSNFCTagMifareClassic::writeBlock, kJSPropertyAttributeNone},
-    {"incrementBlockValue", JSNFCTagMifareClassic::incrementBlockValue, kJSPropertyAttributeNone},
-    {"decrementBlockValue", JSNFCTagMifareClassic::decrementBlockValue, kJSPropertyAttributeNone},
-    {"transfer", JSNFCTagMifareClassic::transfer, kJSPropertyAttributeNone},
-    {"restore", JSNFCTagMifareClassic::restore, kJSPropertyAttributeNone},
-    { 0, 0, 0}
-};
-
-JSClassRef JSNFCTagMifareClassic::m_jsClassRef = JSClassCreate(JSNFCTagMifareClassic::getClassInfo());
-
-JSObjectRef JSNFCTagMifareClassic::createJSObject(JSContextRef context, void *tagHandle, void* privManager) {
-       LogDebug("entered");
-
-       INFCTagMifareClassicPtr NFCTagMifareClassic = NFCFactory::getInstance().createNFCTagMifareClassicObject(tagHandle);
-       NFCTagMifareClassic->setPrivateNFCManagerPtr(privManager);
-       
-       NFCTagMifareClassicPrivObject *priv = new NFCTagMifareClassicPrivObject(context, NFCTagMifareClassic);
-
-       if (!priv) {
-               ThrowMsg(NullPointerException, "Can not new a NFCTagMifareClassic object");
-       }
-       
-       return JSObjectMake(context, getClassRef(), priv);
-}
-
-void JSNFCTagMifareClassic::initialize(JSContextRef context, JSObjectRef object)
-{
-}
-
-void JSNFCTagMifareClassic::finalize(JSObjectRef object)
-{
-       LogDebug( "entered" );
-       NFCTagMifareClassicPrivObject *priv = static_cast<NFCTagMifareClassicPrivObject*>( JSObjectGetPrivate( object ) ) ;
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting timezone object");
-       delete priv;
-}
-
-
-const JSClassRef JSNFCTagMifareClassic::getClassRef()
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSNFCTagMifareClassic::getClassInfo()
-{
-       return &m_classInfo;
-}
-
-bool JSNFCTagMifareClassic::hasInstance(JSContextRef context,
-        JSObjectRef constructor,
-        JSValueRef possibleInstance,
-        JSValueRef* exception)
-{
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSValueRef JSNFCTagMifareClassic::authenticateWithKeyA(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyA arguemtcount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1]))){
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyA key or sectorIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyA SuccessCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyA ErrorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicAuthenticateWithKeyAPtr event(new EventTagMifareClassicAuthenticateWithKeyA(convert.toVectorOfUChars(arguments[0]), convert.toInt(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->authenticateWithKeyA(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::authenticateWithKeyA : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::authenticateWithKeyA InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::authenticateWithKeyB(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyB argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1]))){
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyB key or sectorIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyB SuccessCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))){
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyB ErrorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && validator.isCallback(arguments[3])) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicAuthenticateWithKeyBPtr event(new EventTagMifareClassicAuthenticateWithKeyB(convert.toVectorOfUChars(arguments[0]), convert.toInt(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->authenticateWithKeyB(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::authenticateWithKeyB : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::authenticateWithKeyB InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::readBlock(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 3)) {
-               LogError("JSNFCTagMifareClassic::readBlock argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-               LogError("JSNFCTagMifareClassic::readBlock blockIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::readBlock NFCDataReadCB TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::readBlock errorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[1])) {
-               onSuccessForCbm = arguments[1];
-       }
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onErrorForCbm = arguments[2];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicReadBlockPtr event(new EventTagMifareClassicReadBlock(convert.toInt(arguments[0])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->readBlock(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::readBlock : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::readBlock InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::writeBlock(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareClassic::writeBlock argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSIsArrayValue(context, arguments[1]))){
-               LogError("JSNFCTagMifareClassic::writeBlock blockIndex or block TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::writeBlock successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::writeBlock errorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicWriteBlockPtr event(new EventTagMifareClassicWriteBlock(convert.toInt(arguments[0]), convert.toVectorOfUChars(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->writeBlock(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::writeBlock : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR,"Invalid Parameter"));
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::writeBlock InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::incrementBlockValue(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-  
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareClassic::incrementBlockValue argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1]))){
-               LogError("JSNFCTagMifareClassic::incrementBlockValue index or value TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::incrementBlockValue successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::incrementBlockValue errorCallbackTypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicIncrementBlockValuePtr event(new EventTagMifareClassicIncrementBlockValue(convert.toInt(arguments[0]), convert.toInt(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->incrementBlockValue(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::incrementBlockValue : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::incrementBlockValue InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::decrementBlockValue(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareClassic::decrementBlockValue argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1]))){
-               LogError("JSNFCTagMifareClassic::decrementBlockValue index or value TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::decrementBlockValue successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::decrementBlockValue errorCallbackTypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicDecrementBlockValuePtr event(new EventTagMifareClassicDecrementBlockValue(convert.toInt(arguments[0]), convert.toInt(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->decrementBlockValue(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::decrementBlockValue : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::decrementBlockValue InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::transfer(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 1) || (argumentCount > 3)) {
-               LogError("JSNFCTagMifareClassic::transfer argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-               LogError("JSNFCTagMifareClassic::transfer blockIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::transfer successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::transfer errorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 1) && (validator.isCallback(arguments[1]))) {
-               onSuccessForCbm = arguments[1];
-       }
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onErrorForCbm = arguments[2];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicTransferPtr event(new EventTagMifareClassicTransfer(convert.toInt(arguments[0])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->transfer(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::transfer : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::transfer InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareClassic::restore(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-       NFCTagMifareClassicPrivObject* privateObject = static_cast<NFCTagMifareClassicPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 1) || (argumentCount > 3)) {
-               LogError("JSNFCTagMifareClassic::restore argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-               LogError("JSNFCTagMifareClassic::restore blockIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]) && (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::restore successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::restore errorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 1) && (validator.isCallback(arguments[1]))) {
-               onSuccessForCbm = arguments[1];
-       }
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onErrorForCbm = arguments[2];
-       }
-
-       
-       INFCTagMifareClassicPtr NFCTagMifareClassic(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareClassicRestorePtr event(new EventTagMifareClassicRestore(convert.toInt(arguments[0])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareClassic->restore(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::restore : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::restore InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-}
-}
diff --git a/src/standards/Tizen/NFC/JSNFCTagMifareClassic.h b/src/standards/Tizen/NFC/JSNFCTagMifareClassic.h
deleted file mode 100755 (executable)
index 303f22c..0000000
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-
-#ifndef _JS_TIZEN_NFCTAGMIFARECLASSIC_H_
-#define _JS_TIZEN_NFCTAGMIFARECLASSIC_H_
-
-#include <JavaScriptCore/JavaScript.h>
-#include <API/NFC/INFCTagMifareClassic.h>
-#include <CommonsJavaScript/PrivateObject.h>
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::NFC::INFCTagMifareClassicPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> NFCTagMifareClassicPrivObject;
-
-class JSNFCTagMifareClassic
-{
-public:
-
-    static const JSClassDefinition* getClassInfo();
-
-    static const JSClassRef getClassRef();
-
-    static JSObjectRef createJSObject(JSContextRef context, void *tagHandle, void* privManager);
-
-private:
-    /**
-     * This member variable contains the values which has to be passed when 
-     * the this class is embedded into JS Engine.
-     */
-    static JSClassDefinition m_classInfo;
-
-    /**
-     * This structure describes a statically declared function property.
-     */
-    static JSStaticFunction m_function[];
-
-    /**
-     * This member variable contains the initialization values for the 
-     * properties of this class. The values are given according to the
-     * data structure JSPropertySpec.
-     */
-
-    static JSClassRef m_jsClassRef;
-
-    /**
-     * The callback invoked when an object is first created.
-     */
-    static void initialize(JSContextRef context, JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is finalized.
-     */
-    static void finalize(JSObjectRef object);
-
-    /**
-     * The callback invoked when an object is used as the target of an 'instanceof' expression.
-     */
-    static bool hasInstance(JSContextRef context,
-            JSObjectRef constructor,
-            JSValueRef possibleInstance,
-            JSValueRef* exception);
-
-    static JSValueRef authenticateWithKeyA(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-       
-    static JSValueRef authenticateWithKeyB(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-       
-    static JSValueRef readBlock(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-    static JSValueRef writeBlock(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-       
-    static JSValueRef incrementBlockValue(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-       
-    static JSValueRef decrementBlockValue(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-    static JSValueRef transfer(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-       
-    static JSValueRef restore(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-};
-
-}
-}
-
-#endif /* _JS_TIZEN_NFCTAGMIFARECLASSIC_H_ */
diff --git a/src/standards/Tizen/NFC/JSNFCTagMifareUltra.cpp b/src/standards/Tizen/NFC/JSNFCTagMifareUltra.cpp
deleted file mode 100755 (executable)
index f0bb6f4..0000000
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-
-
-#include "JSNFCTagMifareUltra.h"
-#include "NFCConverter.h"
-#include "ResponseDispatcher.h"
-#include "JSNFCTag.h"
-#include <dpl/log/log.h>
-
-#include <CommonsJavaScript/Validator.h>
-#include <Commons/Exception.h>
-#include <CommonsJavaScript/PrivateObject.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Utils.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
-#include <Tizen/Common/JSTizenException.h>
-#include <Tizen/Common/SecurityExceptions.h>
-#include <API/NFC/NFCFactory.h>
-#include <API/NFC/EventTagMifareUltraAction.h>
-
-#include "plugin_config.h"
-
-
-using namespace TizenApis::Api::NFC;
-using namespace TizenApis::Commons;
-using namespace WrtDeviceApis::Commons;
-using namespace WrtDeviceApis::CommonsJavaScript;
-using namespace DPL;
-
-#define TIZEN10_NFCTTAGMIFAREULTRA_ATTRIBUTENAME "NFCTagMifareUltra"
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
- JSClassDefinition JSNFCTagMifareUltra::m_classInfo =
-{
-    0,
-    kJSClassAttributeNone,
-    TIZEN10_NFCTTAGMIFAREULTRA_ATTRIBUTENAME,
-    JSNFCTag::getClassRef(),
-    NULL,
-    m_function,
-    initialize,
-    finalize,
-    NULL, //hasProperty,
-    NULL,
-    NULL, //setProperty,
-    NULL, //DeleteProperty,
-    NULL, //GetPropertyNames,
-    NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    hasInstance, //HasInstance,
-    NULL  //ConvertToType
-};
-
-
-JSStaticFunction JSNFCTagMifareUltra::m_function[] = {
-    {"readPage", JSNFCTagMifareUltra::readPage, kJSPropertyAttributeNone},
-    {"writePage", JSNFCTagMifareUltra::writePage, kJSPropertyAttributeNone},
-    { 0, 0, 0}
-};
-
-JSClassRef JSNFCTagMifareUltra::m_jsClassRef = JSClassCreate(JSNFCTagMifareUltra::getClassInfo());
-
-JSObjectRef JSNFCTagMifareUltra::createJSObject(JSContextRef context, void *tagHandle, void* privManager) {
-       LogDebug("entered");
-
-       INFCTagMifareUltraPtr NFCTagMifareUltra = NFCFactory::getInstance().createNFCTagMifareUltraObject(tagHandle);
-       NFCTagMifareUltra->setPrivateNFCManagerPtr(privManager);
-       
-       NFCTagMifareUltraPrivObject *priv = new NFCTagMifareUltraPrivObject(context, NFCTagMifareUltra);
-
-       if (!priv) {
-               ThrowMsg(NullPointerException, "Can not new a NFCTagMifareUltra object");
-       }
-       
-       return JSObjectMake(context, getClassRef(), priv);
-}
-
-void JSNFCTagMifareUltra::initialize(JSContextRef context, JSObjectRef object)
-{
-}
-
-void JSNFCTagMifareUltra::finalize(JSObjectRef object)
-{
-       LogDebug( "entered" );
-       NFCTagMifareUltraPrivObject *priv = static_cast<NFCTagMifareUltraPrivObject*>( JSObjectGetPrivate( object ) ) ;
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting timezone object");
-       delete priv;
-}
-
-
-const JSClassRef JSNFCTagMifareUltra::getClassRef()
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_classInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSNFCTagMifareUltra::getClassInfo()
-{
-       return &m_classInfo;
-}
-
-bool JSNFCTagMifareUltra::hasInstance(JSContextRef context,
-        JSObjectRef constructor,
-        JSValueRef possibleInstance,
-        JSValueRef* exception)
-{
-    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
-}
-
-JSValueRef JSNFCTagMifareUltra::readPage(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareUltraPrivObject* privateObject = static_cast<NFCTagMifareUltraPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 3)) {
-               LogError("JSNFCTagMifareUltra::readPage argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-               LogError("JSNFCTagMifareUltra::readPage pageIndex TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareUltra::readPage NFCDataReadCB TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareUltra::readPage errorCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[1])) {
-               onSuccessForCbm = arguments[1];
-       }
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onErrorForCbm = arguments[2];
-       }
-
-       
-       INFCTagMifareUltraPtr NFCTagMifareUltra(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareUltraReadPagePtr event(new EventTagMifareUltraReadPage(convert.toInt(arguments[0])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareUltra->readPage(event);
-               
-               return JSValueMakeNull(context);;
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::readPage : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::readPage InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCTagMifareUltra::writePage(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-
-       NFCTagMifareUltraPrivObject* privateObject = static_cast<NFCTagMifareUltraPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-       NFCConverter convert(context);
-       Validator validator(context, exception);
-
-       if ((argumentCount < 2) || (argumentCount > 4)) {
-               LogError("JSNFCTagMifareUltra::writePage argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) 
-               || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSIsArrayValue(context, arguments[1]))){
-               LogError("JSNFCTagMifareUltra::writePage pageIndex or page TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-
-       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTagMifareUltra::writePage successCallback TypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       if ((argumentCount > 3) && !JSValueIsNull(context, arguments[3]) && (JSValueIsUndefined(context, arguments[3]) || !validator.isCallback(arguments[3]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareUltra::writePage errorCallbackTypeMismatchException!");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       }
-       
-       JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
-               onSuccessForCbm = arguments[2];
-       }
-       if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
-               onErrorForCbm = arguments[3];
-       }
-
-       
-       INFCTagMifareUltraPtr NFCTagMifareUltra(privateObject->getObject());
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
-       Try {
-               EventTagMifareUltraWritePagePtr event(new EventTagMifareUltraWritePage(convert.toInt(arguments[0]), convert.toVectorOfUChars(arguments[1])));
-               event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
-               event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
-               NFCTagMifareUltra->writePage(event);
-               
-               return JSValueMakeNull(context);
-       } Catch (ConversionException) {
-               LogError("JSNFCManager::writePage : ConversionException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
-       } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::writePage InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
-       }
-
-       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
-}
-
-}
-}
old mode 100755 (executable)
new mode 100644 (file)
index 84633be..a51be4f
@@ -17,6 +17,7 @@
 
 #include "JSNFCTarget.h"
 #include "JSNFCManager.h"
+#include "JSNdefMessage.h"
 #include "NFCConverter.h"
 #include "ResponseDispatcher.h"
 #include <dpl/log/log.h>
@@ -91,7 +92,7 @@ JSObjectRef JSNFCTarget::createJSObject(JSContextRef context, void *tagHandle, v
        LogDebug("entered");
 
        INFCTargetPtr NFCTarget = NFCFactory::getInstance().createNFCTargetObject(tagHandle);
-       NFCTarget->setPrivateNFCManagerPtr(privManager);
+       NFCTarget->setPrivateNFCAdapterPtr(privManager);
 
        NFCTargetPrivObject *priv = new NFCTargetPrivObject(context, NFCTarget);
 
@@ -145,18 +146,22 @@ JSValueRef JSNFCTarget::getProperty(JSContextRef context, JSObjectRef object,
                NFCConverter convert(context);
 
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NFCTARGET_ISCONNECTED)) {
-                       NFCManagerPrivObject* privateNFCManager = static_cast<NFCManagerPrivObject*>(NFCTarget->getPrivateNFCManagerPtr());
-                       if (!privateNFCManager) {
+                       NFCAdapterPrivObject* privateNFCAdapter = static_cast<NFCAdapterPrivObject*>(NFCTarget->getPrivateNFCAdapterPtr());
+                       if (!privateNFCAdapter) {
                                LogError("NFC Manager Private object is not set.");
                                ThrowMsg(NullPointerException, "Private object not initialized");
                        }
-                       INFCManagerPtr NFCManager(privateNFCManager->getObject());
-                       return convert.toJSValueRef(NFCManager->isValidHandle(NFCTarget->getHandle()));
+                       INFCAdapterPtr NFCAdapter(privateNFCAdapter->getObject());
+                       return convert.toJSValueRef(NFCAdapter->isValidHandle(NFCTarget->getHandle()));
                }
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
@@ -180,29 +185,19 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_P2P_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 2)) {
-               LogError("JSNFCTarget::setReceiveNDEFListener argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
+       if ((argumentCount == 0) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !validator.isCallback(arguments[0])) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
                LogError("JSNFCTarget::setReceiveNDEFListener NDEFMessageReadCB TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 1)  && !JSValueIsNull(context, arguments[1])){
-               if (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1])) {
+       if ((argumentCount > 1)  && !JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])){
+               if (!validator.isCallback(arguments[1])) {
                        /* 2nd argument must be Callback. */
                        LogError("JSNFCTarget::setReceiveNDEFListener errorCallback TypeMismatchException!");
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -219,33 +214,45 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
                }
        }
 
+       NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+       
        INFCTargetPtr NFCTarget(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
        Try {
 
                EventTargetActionReceiveEmitterPtr emitter(new EventTargetActionReceiveEmitter);
                emitter->setListener(&NFCResponseDispatcher::getInstance());
                emitter->setEventPrivateData(StaticPointerCast<EventTargetActionReceive::PrivateDataType>(callbackManager));
                NFCTarget->setReceiveNDEFListener(emitter);
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::setReceiveNDEFListener : ConversionException");
+               LogError("setReceiveNDEFListener : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::setReceiveNDEFListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("setReceiveNDEFListener InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSNFCTarget::unsetReceiveNDEFListener(JSContextRef context,
@@ -257,30 +264,28 @@ JSValueRef JSNFCTarget::unsetReceiveNDEFListener(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
-               if (argumentCount != 0) {
-                       LogError("JSNFCTarget::unsetReceiveNDEFListener argumentCount error");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
-               AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                INFCTargetPtr NFCTarget(privateObject->getObject());
                NFCTarget->unsetReceiveNDEFListener();
 
-               return JSValueMakeNull(context);
-       } Catch (PlatformException) {
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -298,71 +303,76 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context,
 {
        LogDebug("Entered ");
 
-       NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_P2P_FUNCS);
+       AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_P2P_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
 
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if ((argumentCount < 1) || (argumentCount > 3)) {
-               LogError("JSNFCTarget::sendNDEF argumentCount error");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       if (argumentCount == 0) {
+        /* 1st argument is mandatory. */
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 1 ) && !JSValueIsNull(context, arguments[1]) && (JSValueIsUndefined(context, arguments[1]) || !validator.isCallback(arguments[1]))) {
-               /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTarget::sendNDEF successCallback TypeMismatchException!");
+       if ((argumentCount > 1) && (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !validator.isCallback(arguments[1]))) {
+               /* And 2nd argument must be Callback. */
+               LogError("JSNFCTag::writeNdef TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
-       if ((argumentCount > 2 ) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
-               /* 2nd argument must be Callback. */
-               LogError("JSNFCTarget::sendNDEF errorCallbackType MismatchException!");
+       if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !validator.isCallback(arguments[2]))) {
+               /* 3rd argument must be Callback. */
+               LogError("JSNFCTag::writeNdef TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       void *messageHandle = convert.getMessageHandle(arguments[0]);
-
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[1])) {
+       if ((argumentCount > 1) && validator.isCallback(arguments[1])) {
                onSuccessForCbm = arguments[1];
        }
 
-       if ((argumentCount > 2 ) && (validator.isCallback(arguments[2]))) {
+       if ((argumentCount > 2) && validator.isCallback(arguments[2])) {
                onErrorForCbm = arguments[2];
        }
 
+       NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (NULL == privateObject) {
+               LogError("private object is null");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
+
        INFCTargetPtr NFCTarget(privateObject->getObject());
        JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(privateObject->getContext(), onSuccessForCbm, onErrorForCbm, true, true);
+    JSValueProtect(privateObject->getContext(), thisObject);
        Try {
+               void *messageHandle = convert.getMessageHandle(arguments[0]);
                EventTargetActionSendPtr event(new EventTargetActionSend(messageHandle));
                event->setPrivateData( StaticPointerCast<IEventPrivateData>(callbackManager) );
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
                NFCTarget->sendNDEF(event);
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (ConversionException) {
-               LogError("JSNFCManager::sendNDEF : ConversionException");
+               LogError("sendNDEF : ConversionException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("JSNFCManager::sendNDEF InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               LogError("sendNDEF InvalidArgumentException");
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values"));
+               return JSValueMakeUndefined(context);
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available"));
+               return JSValueMakeUndefined(context);
+       } Catch (UnknownException) {
+               LogError("UnknownException: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-               return JSValueMakeNull(context);
+               return JSValueMakeUndefined(context);
        }
 
        callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       return JSValueMakeNull(context);
+       return JSValueMakeUndefined(context);
 }
 
 }
index db7e698..308c2fa 100755 (executable)
@@ -193,40 +193,42 @@ JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor
        LogDebug("entered");
 
        NdefMessagePrivObject* mainPriv = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(constructor));
-       JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
+
        Try {
-               if (argumentCount == 0)
-                       return createJSObject(global_context);
-               else if (argumentCount == 1) {
-                       if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !(JSIsArrayValue(ctx, arguments[0]) || JSNdefRecordArray::isObjectOfClass(ctx, arguments[0])))
+               if ((argumentCount == 0) || JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]))
+                       return createJSObject(ctx);
+               else {
+                       if (!(JSIsArrayValue(ctx, arguments[0]) || JSNdefRecordArray::isObjectOfClass(ctx, arguments[0])))
                                ThrowMsg(ConversionException, "Parameter's type is not matched");
 
                        NFCConverter convert(ctx);
 
                        if (JSNdefRecordArray::isObjectOfClass(ctx, arguments[0])) {
-                               return createJSObject(global_context, JSNdefRecordArray::getNdefRecordArray(ctx, arguments[0]));
+                               return createJSObject(ctx, JSNdefRecordArray::getNdefRecordArray(ctx, arguments[0]));
                        }
 
                        JSObjectRef objArg = convert.toJSObjectRef(arguments[0]);
                        if (JSGetArrayLength(ctx, objArg) > 0) {
-                               JSValueRef element;
+                               bool isRecordArray = false;
+                               bool isByteArray = false;
                                for (std::size_t i = 0; i < JSGetArrayLength(ctx, objArg); ++i) {
-                                       element = JSGetArrayElement(ctx, objArg, i);
-                                       if (!JSValueIsNull(ctx, element))
+                                       JSValueRef element = JSGetArrayElement(ctx, objArg, i);
+                                       if (convert.isNdefRecord(element))
+                                               isRecordArray = true;
+                                       else
+                                               isByteArray = true;
+                                       if (isRecordArray && isByteArray)
                                                break;
                                }
-                               if (JSValueIsNull(ctx, element))
-                                       return createJSObject(global_context);
-                               else if (convert.isNdefRecord(element))
-                                       return createJSObject(global_context, convert.toVectorOfRecordHandles(arguments[0]));
+                               if (isRecordArray && isByteArray)
+                                       ThrowMsg(ConversionException, "Parameter's type is not matched");
+                               else if (isRecordArray)
+                                       return createJSObject(ctx, convert.toVectorOfRecordHandles(arguments[0]));
                                else
-                                       return createJSObject(global_context, convert.toVectorOfUChars(arguments[0]));
+                                       return createJSObject(ctx, convert.toVectorOfUChars(arguments[0]));
                        } else
-                               return createJSObject(global_context);
+                               return createJSObject(ctx);
                }
-               else
-                       ThrowMsg(InvalidArgumentException, "ArgumentCount is not correct");
-
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -237,6 +239,10 @@ JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor
                return NULL;
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+               return NULL;
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
                return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -267,12 +273,16 @@ JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFMESSAGE_RECORDCOUNT)) {
                        return convert.toJSValueRefLong(NdefMessage->getRecordCount());
                } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFMESSAGE_RECORDS)) {
-                       return JSNdefRecordArray::createArray(privateObject->getContext(), NdefMessage);
+                       return JSNdefRecordArray::createArray(context, NdefMessage);
                }
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
@@ -292,7 +302,6 @@ bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
                                ThrowMsg(NullPointerException, "Private object not initialized");
                        }
 
-                       INdefMessagePtr NdefMessage(privateObject->getObject());
                        NFCConverter convert(context);
 
                        if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value) || !(JSIsArrayValue(context, value) || JSNdefRecordArray::isObjectOfClass(context, value))) {
@@ -316,13 +325,19 @@ bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
                 }
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -348,30 +363,28 @@ JSValueRef JSNdefMessage::toByte(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
-               if (argumentCount != 0) {
-                       LogError("JSNdefMessage::toByte TypeMismatchException");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
+               AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_P2P_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       
                NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
-               AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                INdefMessagePtr NdefMessage(privateObject->getObject());
                NFCConverter convert(context);
 
                return convert.toJSValueRef(NdefMessage->toByte());
-       } Catch (PlatformException) {
+       } Catch (UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
index d489bca..67fac31 100755 (executable)
@@ -39,7 +39,7 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::NFC;
 
 #define TIZEN10_NDEFRECORD_TNF "tnf"
-#define TIZEN10_NDEFRECORD_TYPENAME "typeName"
+#define TIZEN10_NDEFRECORD_TYPE "type"
 #define TIZEN10_NDEFRECORD_ID "id"
 #define TIZEN10_NDEFRECORD_PAYLOAD "payload"
 
@@ -50,7 +50,7 @@ JSClassDefinition JSNdefRecord::m_classInfo =
        "NDEFRecord",
        0,
        m_property,
-       NULL,
+       m_function,
        initialize,
        finalize,
        NULL, //HasProperty,
@@ -67,12 +67,17 @@ JSClassDefinition JSNdefRecord::m_classInfo =
 JSStaticValue JSNdefRecord::m_property[] =
 {
        {TIZEN10_NDEFRECORD_TNF,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_TYPENAME,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_TYPE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        {TIZEN10_NDEFRECORD_ID,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        {TIZEN10_NDEFRECORD_PAYLOAD,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        { 0, 0, 0, 0 }
 };
 
+JSStaticFunction JSNdefRecord::m_function[] = {
+    {"toByte", JSNdefRecord::toByte, kJSPropertyAttributeNone},
+    { 0, 0, 0}
+};
+
 const JSClassRef JSNdefRecord::getClassRef() {
        if (!m_jsClassRef) {
                m_jsClassRef = JSClassCreate(&m_classInfo);
@@ -103,6 +108,18 @@ JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, const NdefRecordP
        return JSObjectMake(context, getClassRef(), priv);
 }
 
+JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, std::vector<unsigned char> rawdata) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(rawdata);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
 void JSNdefRecord::initialize(JSContextRef context, JSObjectRef object) {
        LogDebug("entered");
 
@@ -129,28 +146,36 @@ JSObjectRef JSNdefRecord::constructor(JSContextRef ctx, JSObjectRef constructor,
        LogDebug("entered");
 
        NdefRecordPrivObject* mainPriv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(constructor));
-       JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
+
        Try {
-               if ((argumentCount < 3) || (argumentCount > 4)) {
-                       ThrowMsg(InvalidArgumentException, "parameter count is wrong.");
-               } else if ((JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsNumber(ctx, arguments[0]))
-                       || (JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSIsArrayValue(ctx, arguments[1]))
-                       || (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2]) || !JSIsArrayValue(ctx, arguments[2]))) {
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
+               if (argumentCount < 1) {
+                       ThrowMsg(ConversionException, "parameter count is wrong.");
+               } else if (argumentCount < 3) {
+                       if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSIsArrayValue(ctx, arguments[0]))
+                               ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
+               } else {
+                       if (JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSIsArrayValue(ctx, arguments[1]))
+                               ThrowMsg(ConversionException, "2nd parameter is Not array");
+                       else if (JSValueIsNull(ctx, arguments[2]) || JSValueIsUndefined(ctx, arguments[2]) || !JSIsArrayValue(ctx, arguments[2]))
+                               ThrowMsg(ConversionException, "3rd parameter is Not array");
                }
+
                NFCConverter convert(ctx);
 
+               if (argumentCount < 3)
+                       return createJSObject(ctx, convert.toVectorOfUChars(arguments[0]));
+
                NdefRecordProperties prop;
-               prop.tnf = static_cast<nfcTNF>(convert.toLong(arguments[0]));
+               prop.tnf = convert.toNfcTNF(arguments[0]);
 
                prop.typeName = convert.toVectorOfUChars(arguments[1]);
-               if ((argumentCount == 4) && !JSValueIsNull(ctx, arguments[3])) {
-                       if ( JSValueIsUndefined(ctx, arguments[3]) || !JSIsArrayValue(ctx, arguments[3]))
-                               ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
+               if ((argumentCount > 3) && !JSValueIsNull(ctx, arguments[3]) && !JSValueIsUndefined(ctx, arguments[3])) {
+                       if (!JSIsArrayValue(ctx, arguments[3]))
+                               ThrowMsg(ConversionException, "4th parameter is Not array");
                        prop.id = convert.toVectorOfUChars(arguments[3]);
                }
 
-               return createJSObject(global_context, prop, convert.toVectorOfUChars(arguments[2]));
+               return createJSObject(ctx, prop, convert.toVectorOfUChars(arguments[2]));
 
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
@@ -162,6 +187,10 @@ JSObjectRef JSNdefRecord::constructor(JSContextRef ctx, JSObjectRef constructor,
                return NULL;
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+               return NULL;
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
                return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -188,7 +217,7 @@ JSValueRef JSNdefRecord::getProperty(JSContextRef context, JSObjectRef object,
                LogDebug("propertyName : " << convert.toString(propertyName));
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TNF))
                        return convert.toJSValueRef(NdefRecord->getTNF());
-               else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TYPENAME))
+               else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TYPE))
                        return convert.toJSValueRef(NdefRecord->getTypeName());
                else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_ID))
                        return convert.toJSValueRef(NdefRecord->getID());
@@ -196,8 +225,10 @@ JSValueRef JSNdefRecord::getProperty(JSContextRef context, JSObjectRef object,
                        return convert.toJSValueRef(NdefRecord->getPayload());
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -214,6 +245,45 @@ bool JSNdefRecord::hasInstance(JSContextRef context,
     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
+JSValueRef JSNdefRecord::toByte(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+       LogDebug("Entered ");
+       Try {
+               AceSecurityStatus status = NFC_CHECK_ACCESS(NFC_FUNCTION_API_TAG_P2P_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               NdefRecordPrivObject* privateObject = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(thisObject));
+               if (NULL == privateObject) {
+                       LogError("private object is null");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
+
+               INdefRecordPtr NdefRecord(privateObject->getObject());
+               NFCConverter convert(context);
+
+               return convert.toJSValueRef(NdefRecord->toByte());
+       } Catch (UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch(NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       }
+
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
 } //Tizen1_0
 } //TizenApis
 
index 68231d3..79f4c7f 100755 (executable)
@@ -39,6 +39,8 @@ public:
                const Api::NFC::NdefRecordData &ndefRecordData);
        static JSObjectRef createJSObject(JSContextRef context, 
                const Api::NFC::NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
+       static JSObjectRef createJSObject(JSContextRef context, 
+               std::vector<unsigned char> rawdata);
 private:
        /**
      * The callback invoked when an object is first created.
@@ -70,6 +72,9 @@ private:
      * This structure contains properties and callbacks that define a type of object.
      */
        static JSClassDefinition m_classInfo;
+
+       static JSStaticFunction m_function[];
+       
        /**
      * This structure describes a statically declared value property.
      */
@@ -77,7 +82,7 @@ private:
 
        static JSClassRef m_jsClassRef;
 
-       static JSValueRef getPayload(JSContextRef context,
+    static JSValueRef toByte(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
index 857a405..fb0f98e 100755 (executable)
@@ -216,7 +216,7 @@ JSValueRef JSNdefRecordArray::getProperty(JSContextRef context,
                        Throw(NullPointerException);
                }
 
-               NFCConverter converter(priv->getContext());
+               NFCConverter converter(context);
                size_t index = converter.toSizeT(propertyName);
 
                INdefMessagePtr privateDatas = priv->getObject();
@@ -264,13 +264,19 @@ bool JSNdefRecordArray::setProperty(JSContextRef context,
                return true;
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch(WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -301,20 +307,20 @@ JSValueRef JSNdefRecordArray::concat(JSContextRef context,
                INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(myMessage->toByte());
 
                if (argumentCount == 0)
-                       return createArray(priv->getContext(), NdefMessage);
+                       return createArray(context, NdefMessage);
 
                NFCConverter converter(context);
-               for (int i = 0; i < argumentCount; i++) {
+               for (size_t i = 0; i < argumentCount; i++) {
                        if (JSIsArrayValue(context, arguments[i])) {
                                std::vector<void *> records = converter.toVectorOfRecordHandles(arguments[i]);
-                               for (int j = 0; j < records.size(); j++)
+                               for (size_t j = 0; j < records.size(); j++)
                                        NdefMessage->appendNDEFRecord(records[j]);
                        } else if (isObjectOfClass(context, arguments[i])) {
                                NdefMessagePrivObject* argPriv =
                                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(converter.toJSObjectRef(arguments[i])));
                                if (!argPriv) {
                                        LogError(i << "record's private object is not set.");
-                                       ThrowMsg(InvalidArgumentException, "Record's private object not initialized");
+                                       ThrowMsg(ConversionException, "Record's private object not initialized");
                                }
                                INdefMessagePtr argMessage = argPriv->getObject();
                                for (long j = 0 ; j < argMessage->getRecordCount(); j++)
@@ -323,10 +329,16 @@ JSValueRef JSNdefRecordArray::concat(JSContextRef context,
                                ThrowMsg(ConversionException, "No Array");
                }
                
-               return createArray(priv->getContext(), NdefMessage);;
+               return createArray(context, NdefMessage);
+       } Catch (UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch(NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -356,11 +368,15 @@ JSValueRef JSNdefRecordArray::join(JSContextRef context,
                NFCConverter converter(context);
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
-               if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
+               if (argumentCount > 0) {
                        separator = converter.toString(arguments[0]);
                }
-               for (size_t i = 0; i < myMessage->getRecordCount(); i++) {
+               for (long i = 0; i < myMessage->getRecordCount(); i++) {
                        if (i != 0) {
                                result += separator;
                        }
@@ -387,9 +403,13 @@ JSValueRef JSNdefRecordArray::pop(JSContextRef context,
        {
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
 
-               NFCConverter converter(priv->getContext());
+               NFCConverter converter(context);
                long recordCount = myMessage->getRecordCount();
                if (recordCount > 0) {
                        NdefRecordData result = myMessage->getNDEFRecord(recordCount - 1);
@@ -397,9 +417,15 @@ JSValueRef JSNdefRecordArray::pop(JSContextRef context,
                        return converter.toJSValueRef(result);
                }
                return JSCreateArrayObject(context, 0, NULL);
+       } Catch (UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch(NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -426,6 +452,10 @@ JSValueRef JSNdefRecordArray::push(JSContextRef context,
                NFCConverter converter(context);
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
 
                for (size_t i = 0; i < argumentCount; ++i) {
@@ -454,6 +484,10 @@ JSValueRef JSNdefRecordArray::reverse(JSContextRef context,
                NFCConverter converter(context);
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
 
                long recordCounts = myMessage->getRecordCount();
@@ -485,9 +519,13 @@ JSValueRef JSNdefRecordArray::shift(JSContextRef context,
        {
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
 
-               NFCConverter converter(priv->getContext());
+               NFCConverter converter(context);
                long recordCount = myMessage->getRecordCount();
                if (recordCount > 0) {
                        NdefRecordData result = myMessage->getNDEFRecord(0);
@@ -519,19 +557,20 @@ JSValueRef JSNdefRecordArray::slice(JSContextRef context,
 
                NdefMessagePrivObject* priv =
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
                INdefMessagePtr myMessage = priv->getObject();
 
-               NFCConverter converter(priv->getContext());
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0]))
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not number");
-
-               if ((argumentCount > 1) && (!JSValueIsNull(context, arguments[1]) && (JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1]))))
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not number");
+               NFCConverter converter(context);
                
                long recordCount = myMessage->getRecordCount();
-               long start = converter.toLong(arguments[0]);
-               long end = recordCount;
-               if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]))
+               long start = 0, end = recordCount;
+               if (argumentCount > 0)
+                       start = converter.toLong(arguments[0]);
+
+               if (argumentCount > 1)
                        end = converter.toLong(arguments[1]) < recordCount ? converter.toLong(arguments[1]) : recordCount;
 
                if (start < 0)
@@ -539,7 +578,7 @@ JSValueRef JSNdefRecordArray::slice(JSContextRef context,
 
                if (start > end) {
                        INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject();
-                       return createArray(priv->getContext(), NdefMessage);
+                       return createArray(context, NdefMessage);
                }
 
                std::vector<void *> sliceRecords;
@@ -548,7 +587,7 @@ JSValueRef JSNdefRecordArray::slice(JSContextRef context,
                        sliceRecords.push_back(record);
                }
                INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(sliceRecords);
-               return createArray(priv->getContext(), NdefMessage);
+               return createArray(context, NdefMessage);
 }
        Catch(WrtDeviceApis::Commons::Exception)
        {
@@ -585,15 +624,13 @@ JSValueRef JSNdefRecordArray::splice(JSContextRef context,
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
                INdefMessagePtr myMessage = priv->getObject();
 
-               NFCConverter converter(priv->getContext());
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0]))
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not number");
-
-               if ( (argumentCount > 1) && (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsNumber(context, arguments[1])))
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not number");
+               NFCConverter converter(context);
                
                long recordCount = myMessage->getRecordCount();
-               long start = converter.toLong(arguments[0]);
+               long start = 0;
+
+               if (argumentCount > 0)
+                       start = converter.toLong(arguments[0]);
                long howmany = 0;
                if (argumentCount > 1)
                        howmany= converter.toLong(arguments[1]);
@@ -613,12 +650,16 @@ JSValueRef JSNdefRecordArray::splice(JSContextRef context,
                        }
                        INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(spliceRecords);
 
-                       result = createArray(priv->getContext(), NdefMessage);
+                       result = createArray(context, NdefMessage);
+
+                       for (long i = 0; i < howmany; i++) {
+                               myMessage->removeNDEFRecord(i);
+                       }                       
                } else
                        result = JSCreateArrayObject(context, 0, NULL);
 
                if (argumentCount > 2) {
-                       for (long j = 2; j < argumentCount; j++) {
+                       for (size_t j = 2; j < argumentCount; j++) {
                                void *record = converter.getRecordHandle(arguments[j]);
                                if (start < recordCount)
                                        myMessage->appendNDEFRecord(record);
@@ -627,9 +668,15 @@ JSValueRef JSNdefRecordArray::splice(JSContextRef context,
                        }
                }
                return result;
+       } Catch (UnknownException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
        } Catch(NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -667,15 +714,15 @@ JSValueRef JSNdefRecordArray::unshift(JSContextRef context,
                        static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
                INdefMessagePtr myMessage = priv->getObject();
        
-               NFCConverter converter(priv->getContext());
+               NFCConverter converter(context);
 
                if (argumentCount > 0) {
-                       for (int i = 0; i < argumentCount; i++) {
+                       for (size_t i = 0; i < argumentCount; i++) {
                                if (converter.isNdefRecord(arguments[i]) == false)
                                        ThrowMsg(ConversionException, "parameter is Not record");
                        }
 
-                       for (long i = 0 ; i < argumentCount; i++) {
+                       for (size_t i = 0 ; i < argumentCount; i++) {
                                void *record = converter.getRecordHandle(arguments[i]);
                                myMessage->insertNDEFRecord(i, record);                 
                        }
index 8469c96..f36dc85 100755 (executable)
@@ -127,17 +127,16 @@ JSObjectRef JSNdefRecordMedia::constructor(JSContextRef ctx, JSObjectRef constru
        LogDebug("entered");
 
        NdefRecordPrivObject* mainPriv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(constructor));
-       JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
+
        Try {
-               if (argumentCount != 2) {
-                       ThrowMsg(InvalidArgumentException, "parameter count is wrong.");
-               } else if ((JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsString(ctx, arguments[0]))
-                       || (JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSIsArrayValue(ctx, arguments[1]))) {
+               if (argumentCount < 2) {
+                       ThrowMsg(ConversionException, "parameter count is wrong.");
+               } else if (JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSIsArrayValue(ctx, arguments[1])) {
                        ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
                }
 
                Converter convert(ctx);
-               return createJSObject(global_context, convert.toString(arguments[0]), convert.toVectorOfUChars(arguments[1]));
+               return createJSObject(ctx, convert.toString(arguments[0]), convert.toVectorOfUChars(arguments[1]));
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -148,6 +147,10 @@ JSObjectRef JSNdefRecordMedia::constructor(JSContextRef ctx, JSObjectRef constru
                return NULL;
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+               return NULL;
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
                return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -184,8 +187,10 @@ JSValueRef JSNdefRecordMedia::getProperty(JSContextRef context, JSObjectRef obje
 
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
index a7c1afd..14a8f9e 100755 (executable)
@@ -38,8 +38,8 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::NFC;
 
 #define TIZEN10_NDEFRECORD_TEXT_TEXT "text"
-#define TIZEN10_NDEFRECORD_TEXT_LANGCODE "langCode"
-#define TIZEN10_NDEFRECORD_TEXT_ENCODETYPE "encodeType"
+#define TIZEN10_NDEFRECORD_TEXT_LANGCODE "languageCode"
+#define TIZEN10_NDEFRECORD_TEXT_ENCODING "encoding"
 
 JSClassDefinition JSNdefRecordText::m_classInfo =
 {
@@ -66,7 +66,7 @@ JSStaticValue JSNdefRecordText::m_property[] =
 {
        {TIZEN10_NDEFRECORD_TEXT_TEXT,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        {TIZEN10_NDEFRECORD_TEXT_LANGCODE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_TEXT_ENCODETYPE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_TEXT_ENCODING,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        { 0, 0, 0, 0 }
 };
 
@@ -133,25 +133,25 @@ JSObjectRef JSNdefRecordText::constructor(JSContextRef ctx, JSObjectRef construc
        LogDebug("entered");
 
        NdefRecordPrivObject* mainPriv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(constructor));
-       JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
-       Try {
-               if ((argumentCount < 2) || (argumentCount > 3)) {
-                       ThrowMsg(InvalidArgumentException, "parameter count is wrong.");
-               } else if ((JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsString(ctx, arguments[0]))
-                       || (JSValueIsNull(ctx, arguments[1]) || JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1]))) {
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
-               }
 
+       Try {
                NFCConverter convert(ctx);
                short encodeType = NFC_TEXT_ENCODE_UTF_8;
-
-               if ((argumentCount == 3) && (!JSValueIsNull(ctx, arguments[2]))) {
-                       if (JSValueIsUndefined(ctx, arguments[2]) || !JSValueIsString(ctx, arguments[2]))
-                               Throw(ConversionException);
+               std::string text, languageCode;
+               if (argumentCount > 0)
+                       text = convert.toString(arguments[0]);
+               else
+                       text = convert.toString(JSValueMakeUndefined(ctx));
+               if (argumentCount > 1)
+                       languageCode = convert.toString(arguments[1]);
+               else
+                       languageCode = convert.toString(JSValueMakeUndefined(ctx));
+
+               if ((argumentCount > 2) && (!JSValueIsNull(ctx, arguments[2])) && (!JSValueIsUndefined(ctx, arguments[2]))) {
                        encodeType = convert.toNfcTextEncodeUTF(convert.toString(arguments[2]));
                }
 
-               return createJSObject(global_context, convert.toString(arguments[0]), convert.toString(arguments[1]), encodeType);
+               return createJSObject(ctx, text, languageCode, encodeType);
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -162,6 +162,10 @@ JSObjectRef JSNdefRecordText::constructor(JSContextRef ctx, JSObjectRef construc
                return NULL;
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+               return NULL;
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
                return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -203,7 +207,7 @@ JSValueRef JSNdefRecordText::getProperty(JSContextRef context, JSObjectRef objec
                                return convert.toJSValueRef(result);
                        }
                        LogDebug("This record is not Text Type");
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_ENCODETYPE)) {
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_ENCODING)) {
                        nfcTextEncodeUTF encodeType = NFC_TEXT_ENCODE_UTF_16;
                        if (NdefRecord->getEncodeType(&encodeType)) {
                                LogDebug("encodeType : " << encodeType);
@@ -214,8 +218,10 @@ JSValueRef JSNdefRecordText::getProperty(JSContextRef context, JSObjectRef objec
 
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
-               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               LogError("PlatformExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
index ba04b38..032aa96 100755 (executable)
@@ -129,17 +129,14 @@ JSObjectRef JSNdefRecordURI::constructor(JSContextRef ctx, JSObjectRef construct
        LogDebug("entered");
 
        NdefRecordPrivObject* mainPriv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(constructor));
-       JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
-       Try {
-               if (argumentCount != 1) {
-                       ThrowMsg(InvalidArgumentException, "parameter count is wrong.");
-               } else if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsString(ctx, arguments[0])) {
-                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
-               }
 
+       Try {
                Converter convert(ctx);
 
-               return createJSObject(global_context, convert.toString(arguments[0]));
+               if (argumentCount > 0)
+                       return createJSObject(ctx, convert.toString(arguments[0]));
+               else
+                       return createJSObject(ctx, convert.toString(JSValueMakeUndefined(ctx)));
        } Catch(ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -150,6 +147,10 @@ JSObjectRef JSNdefRecordURI::constructor(JSContextRef ctx, JSObjectRef construct
                return NULL;
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::SERVICE_NOT_AVAILABLE, "Service Not Available");
+               return NULL;
+       } Catch (UnknownException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
                return NULL;
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -184,6 +185,8 @@ JSValueRef JSNdefRecordURI::getProperty(JSContextRef context, JSObjectRef object
                }
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownExceptionException: " << _rethrown_exception.GetMessage());
        } Catch (PlatformException) {
                LogError("PlatformException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
index da73f2e..7bb2290 100755 (executable)
@@ -23,12 +23,12 @@ namespace TizenApis {
 namespace Tizen1_0 {
 struct NFCChangedCallback
 {
-    JSValueRef onAttach;
-    JSValueRef onDetach;
+    JSValueRef onattach;
+    JSValueRef ondetach;
 
     NFCChangedCallback() :
-        onAttach(NULL),
-        onDetach(NULL)
+        onattach(NULL),
+        ondetach(NULL)
     {
     }
 };
index 327c069..d8d1ce1 100755 (executable)
@@ -36,8 +36,8 @@ using namespace WrtDeviceApis;
 
 #define NFC_FILTER_ATTRIBUTE_TAG_TYPES "tagTypes"
 
-#define NFC_CHANGED_CALLBACK_ONATTATCH "onAttach"
-#define NFC_CHANGED_CALLBACK_ONDETACH "onDetach"
+#define NFC_CHANGED_CALLBACK_ONATTATCH "onattach"
+#define NFC_CHANGED_CALLBACK_ONDETACH "ondetach"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -85,7 +85,9 @@ TagFilterPtr NFCConverter::toNFCTagFilter(JSValueRef jsValue)
 
 
 nfcTagType NFCConverter::toNfcTagType(std::string typeString) {
-       if (typeString == "ISO14443_A")
+       if (typeString == "GENERIC_TARGET")
+               return NFC_TAGTYPE_GENERIC_PICC;
+       else if (typeString == "ISO14443_A")
                return NFC_TAGTYPE_ISO14443_A_PICC;
        else if (typeString == "ISO14443_4A")
                return NFC_TAGTYPE_ISO14443_4A_PICC;
@@ -113,8 +115,10 @@ nfcTagType NFCConverter::toNfcTagType(std::string typeString) {
                return NFC_TAGTYPE_JEWEL_PICC;
        else if (typeString == "ISO15693")
                return NFC_TAGTYPE_ISO15693_PICC;
+       else if (typeString == "UNKNOWN_TARGET")
+               return NFC_TAGTYPE_UNKNOWN_TARGET;
        else
-               ThrowMsg(Commons::InvalidArgumentException, "No Match Tag Type");
+               ThrowMsg(Commons::ConversionException, "No Match Tag Type");
 }
 
 std::string NFCConverter::toNfcTagTypeString(nfcTagType type) {
@@ -172,26 +176,38 @@ std::string NFCConverter::toNfcTagTypeString(nfcTagType type) {
 }
 
 nfcTextEncodeUTF NFCConverter::toNfcTextEncodeUTF(std::string encodeString) {
-       if (encodeString == "UTF-8")
+       if (encodeString == "UTF8")
                return NFC_TEXT_ENCODE_UTF_8;
-       else if (encodeString == "UTF-16")
+       else if (encodeString == "UTF16")
                return NFC_TEXT_ENCODE_UTF_16;
        else
-               Throw(InvalidArgumentException);
+               Throw(ConversionException);
 }
 
 std::string NFCConverter::toNfcTextEncodeUTFString(nfcTextEncodeUTF encode) {
        switch(encode) {
                case NFC_TEXT_ENCODE_UTF_8:
-                       return "UTF-8";
+                       return "UTF8";
                        break;
                case NFC_TEXT_ENCODE_UTF_16:
-                       return "UTF-16";
+                       return "UTF16";
                        break;
                default:
                        Throw(ConversionException);
        }
 }
+
+nfcTNF NFCConverter::toNfcTNF(const JSValueRef& arg) {
+       long value = toLong(arg);
+       LogDebug("toNfcTNF,  value == " << value);
+
+       if ((value < NFC_TNF_EMPTY) || (value > NFC_TNF_UNCHAGNED)) {
+               ThrowMsg(InvalidArgumentException, "It is not a correct tnf value");
+       }
+
+       return static_cast<nfcTNF>(value);
+}
+
 bool NFCConverter::initializeAllowedProperties()
 {
     LogDebug("entered");
@@ -221,10 +237,12 @@ JSValueRef NFCConverter::toJSValueRef(NdefRecordData arg) {
        if (arg.properties.tnf == NFC_TNF_MIME_MEDIA)
                return JSNdefRecordMedia::createJSObject(m_context, arg.properties, arg.payload);
        if (arg.properties.tnf == NFC_TNF_WELL_KNOWN) {
-               if (arg.properties.typeName[0] == 0x54)
-                       return JSNdefRecordText::createJSObject(m_context, arg.properties, arg.payload);
-               if (arg.properties.typeName[0] == 0x55)
-                       return JSNdefRecordURI::createJSObject(m_context, arg.properties, arg.payload);
+               if (arg.properties.typeName.size() > 0) {
+                       if (arg.properties.typeName[0] == 0x54)
+                               return JSNdefRecordText::createJSObject(m_context, arg.properties, arg.payload);
+                       if (arg.properties.typeName[0] == 0x55)
+                               return JSNdefRecordURI::createJSObject(m_context, arg.properties, arg.payload);
+               }
        }
        return JSNdefRecord::createJSObject(m_context, arg.properties, arg.payload);
 }
@@ -287,10 +305,12 @@ std::string NFCConverter::toRecordClassName(NdefRecordData arg) {
        if (arg.properties.tnf == NFC_TNF_MIME_MEDIA)
                return JSNdefRecordMedia::getClassInfo()->className;
        if (arg.properties.tnf == NFC_TNF_WELL_KNOWN) {
-               if (arg.properties.typeName[0] == 0x54)
-                       return JSNdefRecordText::getClassInfo()->className;
-               if (arg.properties.typeName[0] == 0x55)
-                       return JSNdefRecordURI::getClassInfo()->className;
+               if (arg.properties.typeName.size() > 0) {
+                       if (arg.properties.typeName[0] == 0x54)
+                               return JSNdefRecordText::getClassInfo()->className;
+                       if (arg.properties.typeName[0] == 0x55)
+                               return JSNdefRecordURI::getClassInfo()->className;
+               }
        }
        return JSNdefRecord::getClassInfo()->className;
 }
@@ -348,22 +368,25 @@ NFCChangedCallback NFCConverter::toNFCChangedCallback(const JSValueRef& arg) {
     NFCChangedCallback result;
     Validator validator(m_context);
 
-    result.onAttach= JSUtils::getJSPropertyOrUndefined(
+    result.onattach= JSUtils::getJSPropertyOrUndefined(
             m_context, object, NFC_CHANGED_CALLBACK_ONATTATCH
             );
-    if (!validator.isNullOrUndefined(result.onAttach) &&
-        !validator.isCallback(result.onAttach)) {
+    if (!validator.isNullOrUndefined(result.onattach) &&
+        !validator.isCallback(result.onattach)) {
         ThrowMsg(Commons::ConversionException, "Not a valid callback.");
     }
 
-    result.onDetach= JSUtils::getJSPropertyOrUndefined(
+    result.ondetach= JSUtils::getJSPropertyOrUndefined(
             m_context, object, NFC_CHANGED_CALLBACK_ONDETACH
             );
-    if (!validator.isNullOrUndefined(result.onDetach) &&
-        !validator.isCallback(result.onDetach)) {
+    if (!validator.isNullOrUndefined(result.ondetach) &&
+        !validator.isCallback(result.ondetach)) {
         ThrowMsg(Commons::ConversionException, "Not a valid callback.");
     }
 
+    if (validator.isNullOrUndefined(result.onattach) && validator.isNullOrUndefined(result.ondetach))
+        ThrowMsg(Commons::ConversionException, "Not a valid callback.");
+
     return result;
 }
 
index f520620..0932183 100755 (executable)
@@ -47,6 +47,7 @@ class NFCConverter : public WrtDeviceApis::CommonsJavaScript::Converter
        std::string toNfcTagTypeString(nfcTagType type);
        nfcTextEncodeUTF toNfcTextEncodeUTF(std::string encodeString);
        std::string toNfcTextEncodeUTFString(nfcTextEncodeUTF encode);
+       nfcTNF toNfcTNF(const JSValueRef& arg);
        JSValueRef toJSValueRef(const std::vector<unsigned char>& arg);
        JSValueRef toJSValueRef(std::vector<NFCTagProperties> props);
        JSValueRef toJSValueRef(NdefRecordData arg);
index 6974827..0e4611e 100755 (executable)
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
-#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <Commons/IEvent.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
 
 #include "NFCStaticController.h"
 #include "EventNFCChangedPrivateData.h"
 #include "JSNFCTag.h"
-#include "JSNFCTagMifareClassic.h"
-#include "JSNFCTagMifareUltra.h"
 #include "JSNFCTarget.h"
 #include "JSNdefMessage.h"
+#include "NFCConverter.h"
 
 using namespace TizenApis::Api::NFC;
+using namespace TizenApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace WrtDeviceApis::Commons;
 
@@ -46,8 +48,7 @@ NFCStaticController& NFCStaticController::getInstance() {
 
 NFCStaticController::NFCStaticController() :
        EventNFCChangedListener(ThreadEnum::NULL_THREAD), 
-       EventNFCChangedNdefListener(ThreadEnum::NULL_THREAD),
-       EventNFCChangedSeEventListener(ThreadEnum::NULL_THREAD){
+       setPoweredAnswerReceiver(ThreadEnum::NULL_THREAD) {
 }
 
 void NFCStaticController::onAnswerReceived(const EventNFCChangedPtr& event) {
@@ -68,13 +69,9 @@ void NFCStaticController::onAnswerReceived(const EventNFCChangedPtr& event) {
                        JSContextRef context = callbackManager->getContext();
                        
                        if (event->getNFCType() == NFC_TAG_TYPE)
-                               nfcObj = JSNFCTag::createJSObject(context, nfcProp, event->getPrivateNFCManagerPtr());
-                       else if (event->getNFCType() == NFC_TAG_MIFARE_CLASSIC_TYPE)
-                               nfcObj = JSNFCTagMifareClassic::createJSObject(context, nfcProp, event->getPrivateNFCManagerPtr());
-                       else if (event->getNFCType() == NFC_TAG_MIFARE_ULTRA_TYPE)
-                               nfcObj = JSNFCTagMifareUltra::createJSObject(context, nfcProp, event->getPrivateNFCManagerPtr());
+                               nfcObj = JSNFCTag::createJSObject(context, nfcProp, event->getPrivateNFCAdapterPtr());
                        else
-                               nfcObj = JSNFCTarget::createJSObject(context, nfcProp, event->getPrivateNFCManagerPtr());
+                               nfcObj = JSNFCTarget::createJSObject(context, nfcProp, event->getPrivateNFCAdapterPtr());
                        LogDebug("callOnSuccess");
                        callbackManager->callOnSuccess(static_cast<JSValueRef>(nfcObj));
                } else {
@@ -84,67 +81,55 @@ void NFCStaticController::onAnswerReceived(const EventNFCChangedPtr& event) {
                }
        } Catch (ConversionException) {
                LogError("Conversion exception while processing EventNFCChanged");
-       }
-}
-
-void NFCStaticController::onAnswerReceived(const EventNFCChangedNdefPtr& event) {
-       LogDebug("onAnswerReceived Enter");
-
-       Try {   
-               JSCallbackManagerPtr cbm =
-                       DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-               if (!cbm) {
-                       LogDebug("no callback manager");
-                       return;
-               }
-               
-               cbm->callOnSuccess(JSNdefMessage::createJSObject(cbm->getContext(), event->getReadNdefResult()));
        } Catch (PlatformException) {
-               LogError("Platform can't create NdefMessage"  << _rethrown_exception.GetMessage());
-       } Catch (Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
+               LogError("PlatformException:Platform can't create NFCTag"  << _rethrown_exception.GetMessage());
+       } Catch (UnknownException) {
+               LogError("UnknownException:Platform can't create NFCTag"  << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointer exception while processing EventNFCChanged");
        }
+
 }
 
-void NFCStaticController::onAnswerReceived(const EventNFCChangedSeEventPtr& event) {
-       LogDebug("onAnswerReceived Enter");
-       
-       Try {   
-               JSCallbackManagerPtr cbm =
-                       DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+void NFCStaticController::OnAnswerReceived(const EventNFCChangedSetPoweredPtr &event)
+{
+       JSCallbackManagerPtr cbm =
+           DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
 
+       Try {
                if (!cbm) {
                        LogDebug("no callback manager");
                        return;
                }
-
-               Converter convert(cbm->getContext());
-               std::string seEventString;
-               switch (event->getSeEvent()) {
-                       case NFC_SE_EVENTTYPE_START_TRANSACTION:
-                               seEventString = "BEGIN_TRANSACTION";
-                               break;
-                       case NFC_SE_EVENTTYPE_END_TRANSACTION:
-                               seEventString = "END_TRANSACTION";
-                               break;
-                       case NFC_SE_EVENTTYPE_CONNECTIVITY:
-                               seEventString = "CONNECT";
-                               break;
-                       case NFC_SE_EVENTTYPE_FIELD_ON:
-                               seEventString = "FIELD_ON";
-                               break;
-                       case NFC_SE_EVENTTYPE_FIELD_OFF:
-                               seEventString = "FIELD_OFF";
-                               break;
-                       default:
-                               ThrowMsg(ConversionException, "No Match SE EVENT");
+               if (event->getResult()) {
+                       LogDebug("result success");
+                       cbm->callOnSuccess();
+                       return;
                }
-               cbm->callOnSuccess(convert.toJSValueRef(seEventString));
-       } Catch (ConversionException) {
-               LogError("Conversion exception while processing EventNFCChangedSeEventPtr"  << _rethrown_exception.GetMessage());
+               LogDebug("result fail");
+               std::string error = event->getError();
+               std::string errorMessage = event->getErrorMessage();
+               JSValueRef errorObject;
+               if (error != "") {
+                       if (errorMessage != "")
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+                       else
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+               } else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+               cbm->callOnError(errorObject);
+       } Catch (PlatformException) {
+               LogError("PlatformException"  << _rethrown_exception.GetMessage());
+               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::SERVICE_NOT_AVAILABLE,"Service Not Available");
+               cbm->callOnError(errorObject);
+       } Catch (UnknownException) {
+               LogError("UnknownException"  << _rethrown_exception.GetMessage());
+               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+               cbm->callOnError(errorObject);          
        } Catch (Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
+               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+               cbm->callOnError(errorObject);  
        }
 }
 
index af660a0..8ed2a01 100755 (executable)
@@ -19,6 +19,7 @@
 #define WRTPLUGINS_TIZEN_NFC_STATIC_CONTROLLER_H_
 
 #include <Commons/EventListener.h>
+#include <Commons/EventReceiver.h>
 #include <API/NFC/EventNFCChanged.h>
 
 namespace TizenApis {
@@ -26,21 +27,17 @@ namespace Tizen1_0 {
 using namespace WrtDeviceApis::Commons;
 using namespace Api::NFC;
 typedef EventListener< EventNFCChanged > EventNFCChangedListener;
-typedef EventListener< EventNFCChangedNdef > EventNFCChangedNdefListener;
-typedef EventListener< EventNFCChangedSeEvent > EventNFCChangedSeEventListener;
+typedef EventAnswerReceiver< EventNFCChangedSetPowered > setPoweredAnswerReceiver;
 
 class NFCStaticController :
        public EventNFCChangedListener,
-       public EventNFCChangedNdefListener,
-       public EventNFCChangedSeEventListener
+       public setPoweredAnswerReceiver
 {
 public:
        static NFCStaticController& getInstance();
 
        void onAnswerReceived(const EventNFCChangedPtr& event);
-       void onAnswerReceived(const EventNFCChangedNdefPtr& event);
-       void onAnswerReceived(const EventNFCChangedSeEventPtr& event);
-
+       void OnAnswerReceived(const EventNFCChangedSetPoweredPtr &event);
 protected:
        NFCStaticController();
 };
index 0627aaf..f6643c4 100755 (executable)
@@ -42,16 +42,6 @@ NFCResponseDispatcher::NFCResponseDispatcher() :
      writeNDEFAnswerReceiver(ThreadEnum::NULL_THREAD),
      transceiveAnswerReceiver(ThreadEnum::NULL_THREAD),
      formatAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicAuthenticateWithKeyAAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicAuthenticateWithKeyBAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicReadBlockAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicWriteBlockAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicIncrementBlockValueAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicDecrementBlockValueAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicTransferAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareClassicRestoreAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareUltraReadPageAnswerReceiver(ThreadEnum::NULL_THREAD),
-     mifareUltraWritePageAnswerReceiver(ThreadEnum::NULL_THREAD),
      TargetSendNdefAnswerReceiver(ThreadEnum::NULL_THREAD),
      TargetReceiveNdefListener(ThreadEnum::NULL_THREAD)
 {
@@ -79,7 +69,18 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionReadPtr &event)
                        return;
                }
                LogDebug("result fail");
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+
+               std::string error = event->getError();
+               std::string errorMessage = event->getErrorMessage();
+               JSValueRef errorObject;
+               if (error != "") {
+                       if (errorMessage != "")
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+                       else
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+               } else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+
                cbm->callOnError(errorObject);
        } Catch (PlatformException) {
                LogError("Platform can't create NdefMessage"  << _rethrown_exception.GetMessage());
@@ -102,8 +103,6 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionWritePtr &event
                return;
        }
 
-       JSContextRef context = cbm->getContext();
-
        if (event->getResult()) {
                LogDebug("result success");
                cbm->callOnSuccess();
@@ -111,8 +110,18 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionWritePtr &event
        }
        LogDebug("result fail");
 
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       std::string error = event->getError();
+       std::string errorMessage = event->getErrorMessage();
+       JSValueRef errorObject;
+       if (error != "") {
+               if (errorMessage != "")
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+               else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+       } else
+               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
 
+       cbm->callOnError(errorObject);
 }
 
 void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionTransceivePtr &event)
@@ -136,7 +145,18 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionTransceivePtr &
                }
                LogDebug("result fail");
 
-               cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+               std::string error = event->getError();
+               std::string errorMessage = event->getErrorMessage();
+               JSValueRef errorObject;
+               if (error != "") {
+                       if (errorMessage != "")
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+                       else
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+               } else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
+
+               cbm->callOnError(errorObject);
        } Catch (ConversionException) {
                LogError("Conversion exception while processing EventTagActionTransceive");
                JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
@@ -158,8 +178,6 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionFormatPtr &even
                return;
        }
 
-       JSContextRef context = cbm->getContext();
-
        if (event->getResult()) {
                LogDebug("result success");
                cbm->callOnSuccess();
@@ -167,126 +185,21 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionFormatPtr &even
        }
        LogDebug("result fail");
 
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicAuthenticateWithKeyAPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-       cbm->callOnError(errorObject);
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicAuthenticateWithKeyBPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-
-       JSContextRef context = cbm->getContext();
-
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicReadBlockPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       Try {
-               if (!cbm) {
-                       LogDebug("no callback manager");
-                       return;
-               }
-
-               JSContextRef context = cbm->getContext();
-
-               if (event->getResult()) {
-                       NFCConverter convert(context);
-                       LogDebug("result success");
-                       cbm->callOnSuccess(convert.toJSValueRef(event->getBlockData()));
-                       return;
-               }
-               LogDebug("result fail");
+       std::string error = event->getError();
+       std::string errorMessage = event->getErrorMessage();
+       JSValueRef errorObject;
+       if (error != "") {
+               if (errorMessage != "")
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+               else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+       } else
+               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
 
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-       } Catch (ConversionException) {
-               LogError("Conversion exception while processing EventTagMifareClassicReadBlock");
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-               cbm->callOnError(errorObject);          
-       } Catch (Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-               cbm->callOnError(errorObject);  
-       }
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicWriteBlockPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
        cbm->callOnError(errorObject);
 }
 
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicIncrementBlockValuePtr &event)
-{
-       JSCallbackManagerPtr cbm =
-       DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-
-       JSContextRef context = cbm->getContext();
-
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicDecrementBlockValuePtr &event)
+void NFCResponseDispatcher::OnAnswerReceived(const EventTargetActionSendPtr &event)
 {
        JSCallbackManagerPtr cbm =
                DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
@@ -296,8 +209,6 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicDecremen
                return;
        }
 
-       JSContextRef context = cbm->getContext();
-
        if (event->getResult()) {
                LogDebug("result success");
                cbm->callOnSuccess();
@@ -305,126 +216,20 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicDecremen
        }
        LogDebug("result fail");
 
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicTransferPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+       std::string error = event->getError();
+       std::string errorMessage = event->getErrorMessage();
+       JSValueRef errorObject;
+       if (error != "") {
+               if (errorMessage != "")
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, errorMessage);
+               else
+                       errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), error, error);
+       } else
+               errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
 
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
        cbm->callOnError(errorObject);
 }
 
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareClassicRestorePtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-
-       JSContextRef context = cbm->getContext();
-
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareUltraReadPagePtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       Try {
-               if (!cbm) {
-                       LogDebug("no callback manager");
-                       return;
-               }
-
-               JSContextRef context = cbm->getContext();
-               if (event->getResult()) {
-                       NFCConverter convert(context);
-                       LogDebug("result success");
-                       cbm->callOnSuccess(convert.toJSValueRef(event->getReadPageResult()));
-                       return;
-               }
-               LogDebug("result fail");
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-               cbm->callOnError(errorObject);
-       } Catch (ConversionException) {
-               LogError("Conversion exception while processing EventTagMifareUltraReadPage");
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-               cbm->callOnError(errorObject);          
-       } Catch (Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error");
-               cbm->callOnError(errorObject);  
-       }
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTagMifareUltraWritePagePtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-
-       JSContextRef context = cbm->getContext();
-
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
-void NFCResponseDispatcher::OnAnswerReceived(const EventTargetActionSendPtr &event)
-{
-       JSCallbackManagerPtr cbm =
-               DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
-
-       if (!cbm) {
-               LogDebug("no callback manager");
-               return;
-       }
-
-       JSContextRef context = cbm->getContext();
-
-       if (event->getResult()) {
-               LogDebug("result success");
-               cbm->callOnSuccess();
-               return;
-       }
-       LogDebug("result fail");
-
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
-}
-
 void NFCResponseDispatcher::onAnswerReceived(const EventTargetActionReceivePtr &event)
 {
        LogDebug("onAnswerReceived Enter");
index 0a482e9..604e0a4 100755 (executable)
@@ -20,8 +20,6 @@
 #include <Commons/EventReceiver.h>
 #include <Commons/EventListener.h>
 #include <API/NFC/EventTagAction.h>
-#include <API/NFC/EventTagMifareClassicAction.h>
-#include <API/NFC/EventTagMifareUltraAction.h>
 #include <API/NFC/EventTargetAction.h>
 
 using namespace TizenApis::Api::NFC;
@@ -33,19 +31,6 @@ typedef EventAnswerReceiver< EventTagActionRead > readNDEFAnswerReceiver;
 typedef EventAnswerReceiver< EventTagActionWrite > writeNDEFAnswerReceiver;
 typedef EventAnswerReceiver< EventTagActionTransceive > transceiveAnswerReceiver;
 typedef EventAnswerReceiver< EventTagActionFormat > formatAnswerReceiver;
-
-typedef EventAnswerReceiver< EventTagMifareClassicAuthenticateWithKeyA > mifareClassicAuthenticateWithKeyAAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicAuthenticateWithKeyB > mifareClassicAuthenticateWithKeyBAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicReadBlock > mifareClassicReadBlockAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicWriteBlock > mifareClassicWriteBlockAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicIncrementBlockValue > mifareClassicIncrementBlockValueAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicDecrementBlockValue > mifareClassicDecrementBlockValueAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicTransfer > mifareClassicTransferAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareClassicRestore > mifareClassicRestoreAnswerReceiver;
-
-typedef EventAnswerReceiver< EventTagMifareUltraReadPage > mifareUltraReadPageAnswerReceiver;
-typedef EventAnswerReceiver< EventTagMifareUltraWritePage > mifareUltraWritePageAnswerReceiver;
-
 typedef EventAnswerReceiver< EventTargetActionSend > TargetSendNdefAnswerReceiver;
 typedef EventListener< EventTargetActionReceive > TargetReceiveNdefListener;
 
@@ -54,16 +39,6 @@ class NFCResponseDispatcher :
     public writeNDEFAnswerReceiver,
     public transceiveAnswerReceiver,
     public formatAnswerReceiver,
-    public mifareClassicAuthenticateWithKeyAAnswerReceiver,
-    public mifareClassicAuthenticateWithKeyBAnswerReceiver,
-    public mifareClassicReadBlockAnswerReceiver,
-    public mifareClassicWriteBlockAnswerReceiver,
-    public mifareClassicIncrementBlockValueAnswerReceiver,
-    public mifareClassicDecrementBlockValueAnswerReceiver,
-    public mifareClassicTransferAnswerReceiver,
-    public mifareClassicRestoreAnswerReceiver,
-    public mifareUltraReadPageAnswerReceiver,
-    public mifareUltraWritePageAnswerReceiver, 
     public TargetSendNdefAnswerReceiver,
     public TargetReceiveNdefListener
     
@@ -78,19 +53,6 @@ protected:
     void OnAnswerReceived(const EventTagActionWritePtr &event);
     void OnAnswerReceived(const EventTagActionTransceivePtr &event);
     void OnAnswerReceived(const EventTagActionFormatPtr &event);
-
-    void OnAnswerReceived(const EventTagMifareClassicAuthenticateWithKeyAPtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicAuthenticateWithKeyBPtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicReadBlockPtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicWriteBlockPtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicIncrementBlockValuePtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicDecrementBlockValuePtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicTransferPtr &event);
-    void OnAnswerReceived(const EventTagMifareClassicRestorePtr &event);
-
-    void OnAnswerReceived(const EventTagMifareUltraReadPagePtr &event);
-    void OnAnswerReceived(const EventTagMifareUltraWritePagePtr &event);
-
     void OnAnswerReceived(const EventTargetActionSendPtr &event);
     void onAnswerReceived(const EventTargetActionReceivePtr &event);
 };
index cb20a27..13ee2c8 100755 (executable)
 #define NFC_FEATURE_API "http://tizen.org/api/nfc"
 #define NFC_FEATURE_API_TAG "http://tizen.org/api/nfc.tag"
 #define NFC_FEATURE_API_P2P "http://tizen.org/api/nfc.p2p"
-#define NFC_FEATURE_API_SE "http://tizen.org/api/nfc.se"
 
 #define NFC_DEVICE_CAP_TAG "nfc.tag"
 #define NFC_DEVICE_CAP_P2P "nfc.p2p"
-#define NFC_DEVICE_CAP_SE "nfc.se"
 
 namespace TizenApis {
 namespace Tizen1_0 {
 
 const char* NFC_FUNCTION_API_TAG_FUNCS = "NFCTagFunctions";
 const char* NFC_FUNCTION_API_P2P_FUNCS = "NFCP2PFunctions";
-const char* NFC_FUNCTION_API_SE_FUNCS = "NFCSEFunctions";
 const char* NFC_FUNCTION_API_TAG_P2P_FUNCS = "NFCTagP2PFunctions";
 
 static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions();
@@ -56,7 +53,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
      */
     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_NFC_TAG, NFC_DEVICE_CAP_TAG);
     ACE_CREATE_DEVICE_CAP(DEVICE_CAP_NFC_P2P, NFC_DEVICE_CAP_P2P);
-    ACE_CREATE_DEVICE_CAP(DEVICE_CAP_NFC_SE, NFC_DEVICE_CAP_SE);
 
     ACE_CREATE_DEVICE_CAPS_LIST(EMPTY_DEVICE_LIST);
 
@@ -66,8 +62,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
     ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_NFC_P2P);
     ACE_ADD_DEVICE_CAP(DEVICE_LIST_NFC_P2P, DEVICE_CAP_NFC_P2P);
 
-       ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_NFC_SE);
-    ACE_ADD_DEVICE_CAP(DEVICE_LIST_NFC_SE, DEVICE_CAP_NFC_SE);
 
        ACE_CREATE_DEVICE_CAPS_LIST(DEVICE_LIST_NFC_TAG_P2P);
     ACE_ADD_DEVICE_CAP(DEVICE_LIST_NFC_TAG_P2P, DEVICE_CAP_NFC_TAG);
@@ -79,7 +73,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
     ACE_CREATE_FEATURE(FEATURE_NFC, NFC_FEATURE_API);
     ACE_CREATE_FEATURE(FEATURE_TAG, NFC_FEATURE_API_TAG);
     ACE_CREATE_FEATURE(FEATURE_P2P, NFC_FEATURE_API_P2P);
-    ACE_CREATE_FEATURE(FEATURE_SE, NFC_FEATURE_API_SE);
 
     ACE_CREATE_FEATURE_LIST(NFC_FEATURES_NFC);
     ACE_ADD_API_FEATURE(NFC_FEATURES_NFC, FEATURE_NFC);
@@ -92,10 +85,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
     ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_P2P, FEATURE_P2P);
        ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_P2P, FEATURE_NFC);
 
-    ACE_CREATE_FEATURE_LIST(NFC_FEATURES_NFC_SE);
-    ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_SE, FEATURE_SE);
-       ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_SE, FEATURE_NFC);
-
    ACE_CREATE_FEATURE_LIST(NFC_FEATURES_NFC_TAG_P2P);
    ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_TAG_P2P, FEATURE_TAG);
    ACE_ADD_API_FEATURE(NFC_FEATURES_NFC_TAG_P2P, FEATURE_P2P);
@@ -125,17 +114,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
     NFCFunctions.insert(std::make_pair(
                                NFC_FUNCTION_API_P2P_FUNCS,
                                nfcP2PFuncs));
-
-       AceFunction nfcSEFuncs = ACE_CREATE_FUNCTION(
-            FUNCTION_NFC_SE_FUNCTIONS,
-            NFC_FUNCTION_API_SE_FUNCS,
-            NFC_FEATURES_NFC_SE,
-            DEVICE_LIST_NFC_SE);
-
-    NFCFunctions.insert(std::make_pair(
-                               NFC_FUNCTION_API_SE_FUNCS,
-                               nfcSEFuncs));
-
        AceFunction nfcTagP2PFuncs = ACE_CREATE_FUNCTION(
             FUNCTION_NFC_TAG_P2P_FUNCTIONS,
             NFC_FUNCTION_API_TAG_P2P_FUNCS,
@@ -155,8 +133,6 @@ static WrtDeviceApis::Commons::FunctionMapping createNFCFunctions()
 #undef NFC_FEATURE_API
 #undef NFC_FEATURE_API_TAG
 #undef NFC_FEATURE_API_P2P
-#undef NFC_FEATURE_API_SE
 #undef NFC_DEVICE_CAP_TAG
 #undef NFC_DEVICE_CAP_P2P
-#undef NFC_DEVICE_CAP_SE
 
index d250700..c295c2f 100755 (executable)
@@ -25,17 +25,15 @@ namespace Tizen1_0 {
 
 extern const char* NFC_FUNCTION_API_TAG_FUNCS;
 extern const char* NFC_FUNCTION_API_P2P_FUNCS;
-extern const char* NFC_FUNCTION_API_SE_FUNCS;
 extern const char* NFC_FUNCTION_API_TAG_P2P_FUNCS;
 
 DECLARE_FUNCTION_GETTER(NFC);
 
-#define NFC_CHECK_ACCESS(globalContext, functionName)                       \
+#define NFC_CHECK_ACCESS(functionName)                       \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getNFCFunctionData,             \
         functionName)
 }
 }
 
-#endif //  _NFC_PLUGIN_CONFIG_H_
\ No newline at end of file
+#endif //  _NFC_PLUGIN_CONFIG_H_
index 871a19e..a154b65 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include "JSNFCManager.h"
 #include "JSNdefMessage.h"
 #include "JSNdefRecord.h"
 #include "JSNdefRecordURI.h"
 #include "JSNdefRecordMedia.h"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[TIZEN1.0\\NFC ] on_widget_start_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess initialization failed");
+    }
 }
 
 void on_widget_stop_callback(int widgetId)
 {
     LogDebug("[TIZEN1.0\\NFC ] on_widget_stop_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
diff --git a/src/standards/Tizen/POI/CMakeLists.txt b/src/standards/Tizen/POI/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..59e4c49
--- /dev/null
@@ -0,0 +1,62 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-poi")
+set(DESTINATION_NAME "tizen-1.0-poi")
+set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-poi-impl")
+
+
+pkg_search_module(poi REQUIRED capi-location-poi capi-location-manager)
+
+include_directories(
+       ${poi_INCLUDE_DIRS}
+       ../LBS
+       ../Tizen
+)
+
+
+set(CMAKE_INSTALL_RPATH
+  ${CMAKE_INSTALL_RPATH}
+  ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-lbs  
+)
+
+set(SRCS_IMPL
+  JSGeoRectBounds.cpp
+  JSGeoCircleBounds.cpp
+  JSGeoPolyBounds.cpp
+  JSGeometryFilter.cpp
+  JSPOI.cpp
+  JSPOIFilter.cpp
+  JSPOIGeometry.cpp
+  JSPOIProvider.cpp
+  JSPOIServiceManager.cpp
+  GeoBounds.cpp
+  GeometryFilter.cpp
+  POI.cpp
+  POIFilter.cpp
+  POIGeometry.cpp
+  POIProvider.cpp
+  RequestOptions.cpp
+  DefaultPOIProvider.cpp
+  POIAce.cpp
+)
+
+add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL})
+target_link_libraries(${TARGET_IMPL_NAME}
+  wrt-plugins-tizen-1.0-tizen-impl
+  wrt-plugins-tizen-1.0-lbs-impl  
+  ${LIBS_COMMON}
+  ${poi_LIBRARIES}  
+)
+
+
+set(SRCS
+  plugin_initializer.cpp
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  ${TARGET_IMPL_NAME}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
diff --git a/src/standards/Tizen/POI/DefaultPOIProvider.cpp b/src/standards/Tizen/POI/DefaultPOIProvider.cpp
new file mode 100755 (executable)
index 0000000..cfa38c8
--- /dev/null
@@ -0,0 +1,681 @@
+#include <dlog.h>
+#include "DefaultPOIProvider.h"
+#include <location_preference.h>
+#include <location_bounds.h>
+#include <glib.h>
+#include "GeoAddress.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_DEFAULT_POI"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+typedef struct {
+       int ret;
+       void *user_data;
+       setOptionCb callback;
+}callback_data;
+
+typedef struct {
+       void *user_data;
+       POIArrayCallback callback;
+       RequestOptions option;  
+       std::vector<POI*> list;
+       std::string providerName;
+}poi_search_callback_data;
+
+/////////////////////////////////////////////////////////////////////////////////////
+// callbacks
+bool DefaultPOIProvider::preference_init_cb(const char *property, void *user_data)
+{
+       int ret;
+       DefaultPOIProvider *obj = (DefaultPOIProvider *)user_data;
+       string key(property);
+       char* value_str = NULL;
+       ret = location_preference_get(obj->nativeHandle, property, &value_str);
+       if( ret == 0 && value_str != NULL ){
+               string value(value_str);
+               obj->metadata.push_back(make_pair(key,value));
+       }
+       obj->supportedOptions.push_back(key);
+       return true;    
+}
+
+int DefaultPOIProvider::setOption_cb(void* user_data)
+{
+       callback_data *data = (callback_data*)user_data;
+       if( data == NULL)
+               return false;
+       data->callback( data->ret , data->user_data);
+       if( data != NULL)
+               delete data;
+       return false;
+}
+
+DefaultPOIProvider::~DefaultPOIProvider(){
+       poi_service_destroy(nativeHandle);
+}
+
+DefaultPOIProvider::DefaultPOIProvider():POIProvider("default"), nativeHandle(NULL){
+       
+       int ret = poi_service_create(&nativeHandle);
+       if( ret != 0 ){
+               LOGE("Error create POI service");
+               return;
+       }
+
+       char *provider_name = NULL;
+       ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(nativeHandle) , &provider_name);
+       if( ret == 0 && provider_name != NULL){
+               string providerName(provider_name);
+               setName(providerName);  
+               free(provider_name);
+       }
+       
+
+       metadata.clear();
+       supportedOptions.clear();
+       location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(nativeHandle) , preference_init_cb,this);
+       
+       
+       
+}
+
+vector<string> DefaultPOIProvider::getSupportedOptions()
+{
+       return supportedOptions;
+}
+
+
+vector<pair<string, string>> DefaultPOIProvider::getMetadata()
+{
+       return metadata;
+}
+
+int DefaultPOIProvider::setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)
+{
+       std::vector<std::pair<std::string, std::string>>::iterator pos;
+       for( pos = options.begin() ; pos != options.end() ; ++pos){
+               vector<string>::iterator check;
+               bool isvalid = false;
+               for ( check = supportedOptions.begin() ; check != supportedOptions.end() ; ++check ){
+                       if( *check == pos->first )
+                               isvalid = true;
+               }
+               if( isvalid == false )
+                       return -1;
+       }
+
+       for( pos = options.begin() ; pos != options.end() ; ++pos){
+               std::vector<std::pair<std::string, std::string>>::iterator target;
+               int find = false;
+               for( target = metadata.begin() ; target != metadata.end() ; ++target){
+                       if ( target->first == pos->first ){
+                               find = true;
+                               target->second = pos->second;
+                       }
+               }
+               if( !find ){
+                       metadata.push_back(*pos);
+               }
+       }
+
+       vector<pair<string, string>>::iterator key;
+       vector<pair<string, string>> newMetadata;
+       for( key = metadata.begin(); key != metadata.end() ; ++key){
+               if( 0 == location_preference_set(nativeHandle, key->first.c_str() , key->second.c_str()))
+                       newMetadata.push_back(*key);
+       }
+       metadata = newMetadata;
+
+       callback_data *data = new callback_data();
+       data->user_data = user_data;
+       data->callback = callback;
+       data->ret = 0;
+       g_idle_add_full(G_PRIORITY_HIGH_IDLE, setOption_cb, data, NULL);
+       return 0;
+}
+
+
+string DefaultPOIProvider::getConnectivity()
+{
+       return string("HYBRID");
+}
+
+bool DefaultPOIProvider::isUsedExternalNetwork()
+{
+       return true;
+}
+
+vector<string> DefaultPOIProvider::getSupportedFilterTypes()
+{
+       vector<string> supported;
+       supported.push_back(string("POIFilter"));
+       return supported;
+}
+
+static bool __poi_filter_available_key_cb(const char *key , void *user_data)
+{
+       vector<string> *supported = (vector<string>*)user_data;
+       if( strcmp( key , "CATEGORY" ) != 0 )
+               supported->push_back(string(key));
+       return true;
+}
+
+static bool __poi_filter_category_cb(const char *value , void *user_data)
+{
+       vector<string> *supported = (vector<string>*)user_data;
+       supported->push_back(string(value));
+       return true;
+
+}
+
+static bool __cancel_operation(int id, void *user_data)
+{
+       bool ret = false;
+       DefaultPOIProvider * obj = reinterpret_cast<DefaultPOIProvider*>(user_data);
+       if( obj )
+               ret = obj->cancel(id);
+       return ret;
+}
+
+
+
+vector<string> DefaultPOIProvider::getSupportedPOIFilterAttributes()
+{
+       vector<string> supported;
+       poi_filter_foreach_available_keys( nativeHandle, __poi_filter_available_key_cb , &supported);
+       return supported;
+}
+
+vector<string> DefaultPOIProvider::getSupportedCategories()
+{
+       vector<string> supported;
+       poi_filter_foreach_available_values( nativeHandle, "CATEGORY" , __poi_filter_category_cb , &supported);
+       return supported;
+}
+
+
+
+bool DefaultPOIProvider::isSupportRemove()
+{
+       return false;
+}
+
+bool DefaultPOIProvider::isSupportUpdate()
+{
+       return false;
+}
+
+bool DefaultPOIProvider::isSupportAdd()
+{
+       return false;
+}
+
+
+static bool _urls_cb(const char *url , const char *description, void *user_data)
+{
+       std::vector<std::string> *urls = (std::vector<std::string>*)user_data;
+       if( urls == NULL)
+               return false;
+       if( url )
+               urls->push_back(string(url));
+       return true;
+}
+
+static bool _categories_cb(const char *category, void *user_data)
+{
+       std::vector<std::string> *categories = (std::vector<std::string>*)user_data;
+       if( categories == NULL)
+               return false;
+       if( category )
+               categories->push_back(string(category));
+       return true;
+
+}
+
+static bool _poi_tags_cb(const char *key, const char* value, void *user_data)
+{
+       std::vector<std::pair<std::string, std::string>> *tags = (std::vector<std::pair<std::string, std::string>>*)user_data;
+       if( tags == NULL)
+               return false;
+       if( key != NULL && value != NULL )
+               tags->push_back(make_pair(string(key), string(value)));
+       return true;
+}
+
+
+bool DefaultPOIProvider::service_search_cb(poi_error_e error, int request_id , int index, int length , poi_h poi , void * user_data)
+{
+       LOGD("%s - start", __func__);
+
+       poi_search_callback_data *calldata = (poi_search_callback_data*)user_data;
+       if( calldata == NULL )
+               return false;
+
+       if( error != 0 ){
+               int result = 0;
+               if( error == POI_ERROR_RESULT_NOT_FOUND )
+                       result = POIProvider::POIERROR::NOT_FOUND;
+               else if( error == POI_ERROR_SERVICE_NOT_AVAILABLE )
+                       result = POIProvider::POIERROR::SERVICE_NOT_AVAILABLE;
+               else if( error == POI_ERROR_NETWORK_FAILED )
+                       result = POIProvider::POIERROR::NETWORK_FAILED;
+               calldata->callback( result, calldata->list,  calldata->user_data );
+               return false;
+       }
+
+       char strBuffer[255] = {0,};
+       POI *item = new POI();
+       int id;
+       poi_get_id(poi, &id);
+       snprintf(strBuffer, 255, "%d",id);
+       item->id = string(strBuffer);
+
+       item->providerName = calldata->providerName;
+
+       char *name = NULL;
+       poi_get_name(poi, &name);
+       item->name = string(name);
+       free(name);
+
+
+       char *building_number = NULL;
+       char *postal_code = NULL;
+       char *street = NULL;
+       char *city = NULL;
+       char *district = NULL;
+       char *state = NULL;
+       char *country_code = NULL;
+
+       poi_get_address(poi, &building_number, &postal_code, &street, &city, &district, &state, &country_code);
+
+       item->addressType = calldata->option.addressType == RequestOptions::AddressType::STRUCTURED ? POI::AddressType::StructAddress : POI::AddressType::SimpleAddress;
+
+       if( country_code )
+               item->structedAddress.country = string(country_code);
+       if( state )
+               item->structedAddress.region = string(state);
+       if( district )
+               item->structedAddress.county = string(district);
+       if( city )
+               item->structedAddress.city = string(city);
+       if( street )
+               item->structedAddress.street = string(street);
+       //item->structedAddress.streetNumber = 
+       if( building_number )
+               item->structedAddress.premises = string(building_number);
+       if( postal_code )
+               item->structedAddress.postalCode = string(postal_code);
+       
+       if( item->addressType ==  POI::AddressType::SimpleAddress ){
+               item->simpleAddress = item->structedAddress.toSimpleAddress();
+       }
+
+       free(building_number);
+       free(postal_code);
+       free(street);
+       free(city);
+       free(district);
+       free(state);
+       free(country_code);
+
+       char *phone_number = NULL;
+       poi_get_phone_number(poi, &phone_number);
+       if( phone_number ){
+               item->phoneNumbers.push_back(string(phone_number));
+               free(phone_number);
+       }
+       
+       poi_foreach_urls(poi, _urls_cb, &item->urls);
+
+       location_coords_s pos;
+       if( 0 == poi_get_position(poi, &pos) ){
+               item->geometry.position[0] = pos.latitude;
+               item->geometry.position[1] = pos.longitude;     
+       }
+
+
+       location_coords_s top_left;
+       location_coords_s bottom_right;
+       if( 0 == poi_get_bounding_rect(poi, &top_left  , &bottom_right) ){
+               item->geometry.viewport.type = GeoBounds::BoundType::RECT;
+               //south
+               item->geometry.viewport.coords.push_back(bottom_right.latitude);
+               //west
+               item->geometry.viewport.coords.push_back(top_left.longitude);
+
+               //north
+               item->geometry.viewport.coords.push_back(top_left.latitude);
+               //east
+               item->geometry.viewport.coords.push_back(bottom_right.longitude);
+       }
+
+       poi_foreach_categories(poi, _categories_cb, &item->categories);
+       poi_foreach_properties(poi,     _poi_tags_cb, &item->tags);
+
+
+       calldata->list.push_back(item);
+
+       if( length == index+1 ){
+               calldata->callback(0 , calldata->list,  calldata->user_data);
+               std::vector<POI*>::iterator pos;
+               for( pos = calldata->list.begin() ; pos != calldata->list.end() ; ++pos)
+                       delete *pos;
+
+               delete calldata;
+       }       
+       return true;
+}
+
+
+int DefaultPOIProvider::find( GeoBounds bound  , RequestOptions& option ,  POIArrayCallback callback, void * user_data, LBSPending **pending)
+{
+       LOGD("%s - search by GeoBound", __func__);
+       int retval = 0;
+       int ret = 0;
+       int reqid = 0;
+       location_bounds_h native_bound = NULL;
+       poi_filter_h filter = NULL;
+       poi_preference_h preference = NULL;
+       poi_search_callback_data * calldata = NULL;     
+       
+       if( bound.type == GeoBounds::BoundType::RECT ){
+               LOGD("%s - It is a rect", __func__);
+               double north , east, south, west;
+               south = bound.coords[0];
+               west = bound.coords[1];
+               north = bound.coords[2];
+               east = bound.coords[3];
+               //it is web style
+               //location_coords_s north_east = {north , east };
+               //location_coords_s south_west = { south , west};
+
+               //it is native style
+               location_coords_s top_left = {north , west};
+               location_coords_s bottom_right = { south , east};               
+               ret = location_bounds_create_rect(top_left, bottom_right, &native_bound);
+
+       }else if( bound.type == GeoBounds::BoundType::CIRCLE ){
+               LOGD("%s - It is circlet", __func__);
+               location_coords_s center = { bound.coords[0] , bound.coords[1] };
+               ret = location_bounds_create_circle(center, bound.coords[2] , &native_bound);
+       }else if( bound.type == GeoBounds::BoundType::POLY ){
+               LOGD("%s - It is poly", __func__);
+               location_coords_s *list = NULL;
+               int length = bound.coords.size()/2;
+               list = (location_coords_s *)malloc( length*sizeof(location_coords_s));
+               if( list == NULL )
+                       return POIERROR::OUT_OF_MEMORY;
+               for(int i =0 ; i< length ; i++){
+                       list[i] = { bound.coords[i*2] , bound.coords[i*2+1] };
+               }
+               ret = location_bounds_create_polygon(list, length, &native_bound);
+               free( list );   
+       }
+       if( ret != 0 ){
+               retval = POIERROR::INVALID_PARAMETER;
+               goto destroy;
+       }
+
+       if( option.filterType == RequestOptions::FilterType::GEO ){
+               retval = POIERROR::INVALID_PARAMETER;
+               goto destroy;
+       }
+
+       if( 0 != poi_filter_create(&filter)){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+       if( 0 != poi_service_get_preference(nativeHandle, &preference) ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       LOGD("%s - check filter type", __func__);
+       if( option.filterType == RequestOptions::FilterType::POI ){
+               LOGD("%s - filter is POIFilter", __func__);
+               if( 0 != poi_filter_set(filter, option.poiFilter.attributeName.c_str(), option.poiFilter.strValue.c_str()) ){
+                       retval = POIERROR::INVALID_PARAMETER;
+                       goto destroy;
+               }
+       }
+
+       if( option.categories.size() > 0 ){
+               poi_filter_set(filter, "CATEGORY", option.categories[0].c_str());
+       }
+
+
+       if( option.maxResult != 0 )
+               poi_preference_set_max_result(preference, option.maxResult);
+
+       if( option.sortAttributeName != "" ){
+               poi_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? POI_SORTORDER_ASC : POI_SORTORDER_DESC);
+       }
+
+
+       calldata = new poi_search_callback_data();
+       if( calldata == NULL ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+       calldata->providerName = this->getName();
+
+       poi_service_set_preference(nativeHandle, preference);
+       ret = poi_service_search_by_area(nativeHandle, native_bound , filter,  service_search_cb , calldata, &reqid);
+
+       if( ret == 0 ){
+               //should not be deleted
+               calldata = NULL;
+               if( pending )
+                       *pending = new LBSPending(__cancel_operation, reqid, this);
+       }
+       else if( ret == POI_ERROR_OUT_OF_MEMORY )
+               retval = POIERROR::OUT_OF_MEMORY;
+       else if( ret == POI_ERROR_INVALID_PARAMETER )
+               retval = POIERROR::INVALID_PARAMETER;
+       else if( ret == POI_ERROR_SERVICE_NOT_AVAILABLE )
+               retval = POIERROR::SERVICE_NOT_AVAILABLE;
+       else if( ret == POI_ERROR_NETWORK_FAILED )
+               retval = POIERROR::NETWORK_FAILED;
+       else
+               retval = POIERROR::SERVICE_NOT_AVAILABLE;
+
+destroy:       
+       poi_filter_destroy(filter);     
+       location_bounds_destroy(native_bound);
+       poi_preference_destroy(preference);
+       if( calldata)
+               delete calldata;        
+       return retval;
+
+}
+
+
+int DefaultPOIProvider::find( std::string& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending)
+{
+       int retval = 0;
+       int ret = 0;
+       int reqid = 0;
+       poi_filter_h filter = NULL;
+       poi_preference_h preference = NULL;
+       poi_search_callback_data * calldata = NULL;     
+       
+       if( option.filterType == RequestOptions::FilterType::GEO ){
+               retval = POIERROR::INVALID_PARAMETER;
+               goto destroy;
+       }
+
+       if( 0 != poi_filter_create(&filter)){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+       if( 0 != poi_service_get_preference(nativeHandle, &preference) ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+
+       if( option.filterType == RequestOptions::FilterType::POI ){
+               if( 0 != poi_filter_set(filter, option.poiFilter.attributeName.c_str(), option.poiFilter.strValue.c_str()) ){
+                       retval = POIERROR::INVALID_PARAMETER;
+                       goto destroy;
+               }
+       }
+
+       if( option.categories.size() > 0 ){
+               poi_filter_set(filter, "CATEGORY", option.categories[0].c_str());
+       }
+
+
+       if( option.maxResult != 0 )
+               poi_preference_set_max_result(preference, option.maxResult);
+
+       if( option.sortAttributeName != "" ){
+               poi_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? POI_SORTORDER_ASC : POI_SORTORDER_DESC);
+       }
+
+
+       calldata = new poi_search_callback_data();
+       if( calldata == NULL ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+               
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+       calldata->providerName = this->getName();
+
+       poi_service_set_preference(nativeHandle, preference);
+       ret = poi_service_search_by_address(nativeHandle, address.c_str(), 0 , filter,  service_search_cb , calldata, NULL);
+
+       if( ret == 0 ){
+               //should not be deleted
+               calldata = NULL;
+               if( pending )
+                       *pending = new LBSPending(__cancel_operation, reqid, this);
+       }       
+       else if( ret == POI_ERROR_OUT_OF_MEMORY )
+               retval = POIERROR::OUT_OF_MEMORY;
+       else if( ret == POI_ERROR_INVALID_PARAMETER )
+               retval = POIERROR::INVALID_PARAMETER;
+       else if( ret == POI_ERROR_SERVICE_NOT_AVAILABLE )
+               retval = POIERROR::SERVICE_NOT_AVAILABLE;       
+
+destroy:       
+       poi_filter_destroy(filter);
+       poi_preference_destroy(preference);
+       if( calldata)
+               delete calldata;
+       return retval;
+}
+
+int DefaultPOIProvider::find( GeoAddress& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending)
+{
+       int retval = 0;
+       int ret = 0;
+       int reqid = 0;
+       poi_filter_h filter = NULL;
+       poi_preference_h preference = NULL;
+       poi_search_callback_data * calldata = NULL;
+       
+       if( option.filterType == RequestOptions::FilterType::GEO ){
+               retval = POIERROR::INVALID_PARAMETER;
+               goto destroy;
+       }
+
+       if( 0 != poi_filter_create(&filter)){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+       if( 0 != poi_service_get_preference(nativeHandle, &preference) ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+
+       if( option.filterType == RequestOptions::FilterType::POI ){
+               if( 0 != poi_filter_set(filter, option.poiFilter.attributeName.c_str(), option.poiFilter.strValue.c_str()) ){
+                       retval = POIERROR::INVALID_PARAMETER;
+                       goto destroy;
+               }
+       }
+       if( option.categories.size() > 0 ){
+               poi_filter_set(filter, "CATEGORY", option.categories[0].c_str());
+       }
+
+
+       if( option.maxResult != 0 )
+               poi_preference_set_max_result(preference, option.maxResult);
+
+       if( option.sortAttributeName != "" ){
+               poi_preference_set_sort(preference , option.sortAttributeName.c_str(), option.sortOrder == RequestOptions::SortOrder::ASC ? POI_SORTORDER_ASC : POI_SORTORDER_DESC);
+       }
+
+
+       calldata = new poi_search_callback_data();
+       if( calldata == NULL ){
+               retval = POIERROR::OUT_OF_MEMORY;
+               goto destroy;
+       }
+
+       calldata->user_data = user_data;
+       calldata->callback = callback;
+       calldata->option = option;
+       calldata->providerName = this->getName();
+
+       poi_service_set_preference(nativeHandle, preference);
+       ret = poi_service_search_by_address(nativeHandle, address.toSimpleAddress().c_str(), 0 , filter,  service_search_cb , calldata, NULL);
+
+       if( ret == 0 ){
+               calldata = NULL;
+               if( pending )
+                       *pending = new LBSPending(__cancel_operation, reqid, this);
+       }
+       else if( ret == POI_ERROR_OUT_OF_MEMORY )
+               retval = POIERROR::OUT_OF_MEMORY;
+       else if( ret == POI_ERROR_INVALID_PARAMETER )
+               retval = POIERROR::INVALID_PARAMETER;
+       else if( ret == POI_ERROR_SERVICE_NOT_AVAILABLE )
+               retval = POIERROR::SERVICE_NOT_AVAILABLE;       
+
+destroy:       
+       poi_filter_destroy(filter);     
+       poi_preference_destroy(preference);
+       if( calldata)
+               delete calldata;        
+       return retval;  
+}
+
+int DefaultPOIProvider::update( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending)
+{
+       return POIERROR::SERVICE_NOT_AVAILABLE;
+}
+int DefaultPOIProvider::add( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending)
+{
+       return POIERROR::SERVICE_NOT_AVAILABLE;
+}
+int DefaultPOIProvider::remove( POI* poi , POIResultCallback callback, void *user_data, LBSPending **pending )
+{
+       return POIERROR::SERVICE_NOT_AVAILABLE;
+}
+
+bool DefaultPOIProvider::cancel(int reqid)
+{
+       return poi_service_cancel(nativeHandle, reqid);
+}
+
+
+} //LBS
+} //Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/POI/DefaultPOIProvider.h b/src/standards/Tizen/POI/DefaultPOIProvider.h
new file mode 100755 (executable)
index 0000000..be3da7b
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_
+#define _WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <poi.h>
+#include "POIProvider.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class DefaultPOIProvider :public POIProvider{
+       private:
+               poi_service_h nativeHandle;
+               std::vector<std::pair<std::string, std::string>> metadata;
+               std::vector<std::string> supportedOptions;
+
+               static bool preference_init_cb(const char *property, void *user_data);
+               static int setOption_cb(void* user_data);
+               static bool service_search_cb(poi_error_e error, int request_id , int index, int length , poi_h poi , void * user_data);
+
+       public:
+
+               DefaultPOIProvider();
+               virtual ~DefaultPOIProvider();
+               virtual std::vector<std::pair<std::string, std::string>> getMetadata();
+               virtual std::vector<std::string> getSupportedOptions();
+               virtual std::string getConnectivity();
+               virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending);
+               virtual bool isUsedExternalNetwork();
+
+
+               virtual std::vector<std::string> getSupportedFilterTypes();
+               virtual std::vector<std::string> getSupportedPOIFilterAttributes();
+               virtual std::vector<std::string> getSupportedCategories();
+
+               virtual bool isSupportRemove();
+               virtual bool isSupportUpdate();
+               virtual bool isSupportAdd();
+
+               virtual int find( GeoBounds bound  , RequestOptions& option ,  POIArrayCallback callback, void * user_data, LBSPending **pending);
+               virtual int find( std::string& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending);
+               virtual int find( GeoAddress& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending);
+
+               virtual int update( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending);
+               virtual int add( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending);
+               virtual int remove( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending);
+
+               virtual bool cancel(int request);
+
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_
+
+
diff --git a/src/standards/Tizen/POI/GeoBounds.cpp b/src/standards/Tizen/POI/GeoBounds.cpp
new file mode 100755 (executable)
index 0000000..95b055e
--- /dev/null
@@ -0,0 +1,164 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "GeoBounds.h"
+#include "JSGeoRectBounds.h"
+#include "JSGeoPolyBounds.h"
+#include "JSGeoCircleBounds.h"
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+#include "LBSConverter.h"
+#include "JSSimpleCoordinates.h"
+
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+JSObjectRef GeoBounds::toJSObject(JSContextRef context)
+{
+       LBSConverter convert(context);
+       JSObjectRef obj; 
+       switch( type ){
+               case RECT:
+               {
+                       obj = JSObjectMake(context, JSGeoRectBounds::getClassRef(), NULL);
+                       JSObjectRef southWest = JSObjectMake(context, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+                       JSObjectRef northEast = JSObjectMake(context, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+                       if( coords.size() >= 4 ){
+                               LBSUtil::setProperty(context, southWest, "latitude", coords[0] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, southWest, "longitude", coords[1] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, northEast, "latitude", coords[2] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, northEast, "longitude", coords[3] , kJSPropertyAttributeReadOnly);
+                       }else{
+                               LBSUtil::setProperty(context, southWest, "latitude", 0.0 , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, southWest, "longitude", 0.0 , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, northEast, "latitude", 0.0 , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, northEast, "longitude", 0.0 , kJSPropertyAttributeReadOnly);
+                       }
+
+                       LBSUtil::setProperty(context, obj, "southWest", southWest , kJSPropertyAttributeReadOnly);
+                       LBSUtil::setProperty(context, obj, "northEast", northEast , kJSPropertyAttributeReadOnly);                      
+                       break;
+               }
+               case CIRCLE :
+               {
+                       obj = JSObjectMake(context, JSGeoCircleBounds::getClassRef(), NULL);    
+                       JSObjectRef center = JSObjectMake(context, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+                       if( coords.size() >= 3 ){
+                               LBSUtil::setProperty(context, center, "latitude", coords[0] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, center, "longitude", coords[1] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, obj, "radius", coords[2] , kJSPropertyAttributeReadOnly);
+                       }else{
+                               LBSUtil::setProperty(context, center, "latitude", 0.0 , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, center, "longitude", 0.0 , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, obj, "radius", 0.0 , kJSPropertyAttributeReadOnly);
+                       }
+                       LBSUtil::setProperty(context, obj, "center", center , kJSPropertyAttributeReadOnly);
+                       break;
+               }
+               default:
+               {
+                       obj = JSObjectMake(context, JSGeoPolyBounds::getClassRef(), NULL);
+                       int length = coords.size()/2;
+                       JSValueRef* pointsArray = NULL;
+                       pointsArray = new JSValueRef[length];
+                       
+                       for(int i = 0; i < length ; i++){
+                               JSObjectRef pos = JSObjectMake(context, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+                               LBSUtil::setProperty(context, pos, "latitude", coords[0] , kJSPropertyAttributeReadOnly);
+                               LBSUtil::setProperty(context, pos, "longitude", coords[1] , kJSPropertyAttributeReadOnly);
+                               pointsArray[i] = pos;
+                               JSValueProtect(context, pointsArray[i]);
+                       }
+                       JSObjectRef pointsObj = JSObjectMakeArray(context, length, pointsArray, NULL);
+                       LBSUtil::setProperty(context, obj, "points", pointsObj , kJSPropertyAttributeReadOnly);
+                       delete [] pointsArray;
+                       break;
+               }
+       }
+
+       return obj;
+}
+
+
+GeoBounds GeoBounds::convert(JSContextRef ctx, JSObjectRef object)
+{
+       GeoBounds bound;
+       convert(ctx, object, &bound);
+       return bound;
+}
+
+void GeoBounds::convert(JSContextRef ctx, JSObjectRef object, GeoBounds *bound){
+       if(bound == NULL)
+               return;
+
+       LBSConverter convert(ctx);
+       bound->coords.clear();
+       bound->type = BoundType::POLY;
+
+       // Rect
+       if( JSValueIsObjectOfClass(ctx, object, JSGeoRectBounds::getClassRef()) ){
+               bound->type = BoundType::RECT;
+               double south, west, north, east;
+               JSObjectRef southWest = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "southWest") , NULL);
+               JSObjectRef northEast = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "northEast") , NULL);
+               south = LBSUtil::getPropertyToDouble(ctx, southWest, "latitude");
+               west = LBSUtil::getPropertyToDouble(ctx, southWest, "longitude");
+               north = LBSUtil::getPropertyToDouble(ctx, northEast, "latitude");
+               east = LBSUtil::getPropertyToDouble(ctx, northEast, "longitude");
+               bound->coords.push_back(south);
+               bound->coords.push_back(west);          
+               bound->coords.push_back(north);
+               bound->coords.push_back(east);          
+       }
+       // Circle
+       else if( JSValueIsObjectOfClass(ctx, object, JSGeoCircleBounds::getClassRef()) ){
+               bound->type = BoundType::CIRCLE;
+               double lat, lng, radius;
+               JSObjectRef center = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "center") , NULL);
+               lat = LBSUtil::getPropertyToDouble(ctx, center, "latitude");
+               lng = LBSUtil::getPropertyToDouble(ctx, center, "longitude");
+               radius = LBSUtil::getPropertyToDouble(ctx, object, "radius");
+               bound->coords.push_back(lat);
+               bound->coords.push_back(lng);
+               bound->coords.push_back(radius);        
+       }
+       //POLY
+       else if( JSValueIsObjectOfClass(ctx, object, JSGeoPolyBounds::getClassRef()) ){
+               bound->type = BoundType::POLY;
+               JSObjectRef points = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "points"), NULL);
+               int count = JSGetArrayLength(ctx, points );
+               for( int i =0 ; i<count ; i++){
+                       JSObjectRef coord = JSValueToObject(ctx, JSGetArrayElement(ctx, points, i), NULL);
+                       double lat, lng;
+                       lat = LBSUtil::getPropertyToDouble(ctx, coord, "latitude");
+                       lng = LBSUtil::getPropertyToDouble(ctx, coord, "longitude");
+                       bound->coords.push_back(lat);
+                       bound->coords.push_back(lng);
+               }
+       }
+}
+
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
+
diff --git a/src/standards/Tizen/POI/GeoBounds.h b/src/standards/Tizen/POI/GeoBounds.h
new file mode 100755 (executable)
index 0000000..3341ebb
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#ifndef _WRTPLUGINS_TIZEN_GEOBOUNDS_
+#define _WRTPLUGINS_TIZEN_GEOBOUNDS_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+/**
+ * This object is used only data passing platform <-> JS Layer
+ * Not for private object
+ */
+class GeoBounds : public ConvertibleJSObject{
+public:
+       enum BoundType{ RECT , CIRCLE , POLY };
+       BoundType type;
+       std::vector<double> coords;
+
+       virtual JSObjectRef toJSObject(JSContextRef context);
+       static GeoBounds convert(JSContextRef ctx, JSObjectRef object);
+       static void convert(JSContextRef ctx, JSObjectRef object, GeoBounds *bound);    
+
+};
+       
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_GEOBOUNDS_
+
similarity index 50%
rename from src/platform/API/Call/CallServiceObject.cpp
rename to src/standards/Tizen/POI/GeometryFilter.cpp
index cd806a8..d256f57 100755 (executable)
  * limitations under the License. 
  */
 
-#include "CallServiceObject.h"
+#include "GeometryFilter.h"
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
 
-namespace TizenApis {
-namespace Api {
-namespace Call {
-
-using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
 
 
-CallServiceObject::CallServiceObject(const Api::Account::AccountServices &accountServices, ICallServicePtr iCallServicePtr) :
-       Api::Account::AccountServices(accountServices),
-       m_ICallServicePtr(iCallServicePtr)
-{
-}
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
 
-CallServiceObject::~CallServiceObject()
+GeometryFilter GeometryFilter::convert(JSContextRef ctx, JSObjectRef object)
 {
+       GeometryFilter filter;
+       convert(ctx, object, &filter);
+       return filter;
 }
 
-ICallServicePtr CallServiceObject::getICallService()
+void GeometryFilter::convert(JSContextRef ctx, JSObjectRef object, GeometryFilter* filter)
 {
-       return m_ICallServicePtr;
+       if( filter == NULL )
+               return;
+       filter->criteria = LBSUtil::getPropertyToString(ctx, object, "criteria");
+       filter->geometry = LBSUtil::getPropertyToString(ctx, object, "geometry");
 }
 
 }
 }
 }
+
+
old mode 100644 (file)
new mode 100755 (executable)
similarity index 59%
rename from src/platform/API/Geocoder/GeocoderFactory.cpp
rename to src/standards/Tizen/POI/GeometryFilter.h
index dbc6bf1..60d8ae3
  * limitations under the License. 
  */
 
+#ifndef _WRTPLUGINS_TIZEN_GEOMETRYFILTER_
+#define _WRTPLUGINS_TIZEN_GEOMETRYFILTER_
 
-
-
-
-/*
- * @author
- */
-
-#include "GeocoderFactory.h"
-#include <Geocoder/Geocoder.h>
-
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
 namespace TizenApis {
-namespace Tizen1_0{
-namespace Api {
-namespace Geocoder {
+namespace Tizen1_0 {
+namespace LBS{
 
-IGeocoderPtr GeocoderFactory::getGeocoder() {
-       return IGeocoderPtr(new Platform::Geocoder::Geocoder());
-}
-
-GeocoderFactory& GeocoderFactory::getInstance() {
-       static GeocoderFactory theInstance;
-       return theInstance;
-}
 
-GeocoderFactory::GeocoderFactory() {
-}
+class GeometryFilter{
+public:
+       std::string criteria;
+       std::string geometry;
+static GeometryFilter convert(JSContextRef ctx, JSObjectRef object);
+static void convert(JSContextRef ctx, JSObjectRef object, GeometryFilter* filter);
+};
 
 }
 }
 }
-}
+
+#endif //_WRTPLUGINS_TIZEN_GEOMETRYFILTER_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSGeoCircleBounds.cpp b/src/standards/Tizen/POI/JSGeoCircleBounds.cpp
new file mode 100755 (executable)
index 0000000..ef743d1
--- /dev/null
@@ -0,0 +1,122 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSSimpleCoordinates.h"
+#include "JSGeoCircleBounds.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSGeoCircleBounds::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeoCircleBounds::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "GeoRectBounds",                                                                                                                // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSGeoCircleBounds::initialize,                  // initialize
+       JSGeoCircleBounds::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSGeoCircleBounds::constructor, // constructor
+       JSGeoCircleBounds::hasInstance,
+       NULL
+};
+
+
+
+const JSClassRef JSGeoCircleBounds::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeoCircleBounds::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSGeoCircleBounds::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[2];
+       for( unsigned int i = 0 ; i < 2; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+
+       if( !JSValueIsObjectOfClass(ctx, convertedArguments[0], TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef()) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "First argument is not SimpleCoordinates");
+               return NULL;
+       }
+
+       if( JSValueIsUndefined(ctx , convertedArguments[1] ) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::INVALID_VALUES_ERROR, "Second argument is not number");
+               return NULL;
+       }
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);       
+
+       LBSUtil::setProperty(ctx , obj ,"center" ,convertedArguments[0], kJSPropertyAttributeReadOnly );
+       LBSUtil::setProperty(ctx , obj ,"radius" ,convertedArguments[1], kJSPropertyAttributeReadOnly );        
+       return obj;
+}
+
+
+void JSGeoCircleBounds::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSGeoCircleBounds::finalize(JSObjectRef object) 
+{
+}
+
+bool JSGeoCircleBounds::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
+
diff --git a/src/standards/Tizen/POI/JSGeoCircleBounds.h b/src/standards/Tizen/POI/JSGeoCircleBounds.h
new file mode 100755 (executable)
index 0000000..17bc264
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_GEOCIRCLEBOUNDS_
+#define _WRTPLUGINS_TIZEN_JS_GEOCIRCLEBOUNDS_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeoCircleBounds{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_GEOCIRCLEBOUNDS_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSGeoPolyBounds.cpp b/src/standards/Tizen/POI/JSGeoPolyBounds.cpp
new file mode 100755 (executable)
index 0000000..ad89b5b
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSSimpleCoordinates.h"
+#include "JSGeoPolyBounds.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSGeoPolyBounds::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeoPolyBounds::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "GeoRectBounds",                                                                                                                // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSGeoPolyBounds::initialize,                    // initialize
+       JSGeoPolyBounds::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSGeoPolyBounds::constructor, // constructor
+       JSGeoPolyBounds::hasInstance,
+       NULL
+};
+
+
+
+const JSClassRef JSGeoPolyBounds::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeoPolyBounds::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSGeoPolyBounds::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[1];
+       for( unsigned int i = 0 ; i < 1; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+
+       if( !JSIsArrayValue(ctx , convertedArguments[0]) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Argument are not array");
+               return NULL;
+       }
+
+       JSObjectRef array = JSValueToObject(ctx, convertedArguments[0], NULL);
+       int arrayLength = JSGetArrayLength(ctx, array);
+       for( int i = 0 ; i < arrayLength ; i++){
+               JSValueRef item = JSGetArrayElement(ctx, array, i);
+               if( !JSValueIsObjectOfClass(ctx, item ,TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef() )){
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Arguments are not SimpleCoordinates");
+                       return NULL;
+               }
+       }
+       
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);       
+       LBSUtil::setProperty(ctx , obj ,"points" ,convertedArguments[0], kJSPropertyAttributeReadOnly );
+       
+       return obj;
+}
+
+
+void JSGeoPolyBounds::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSGeoPolyBounds::finalize(JSObjectRef object) 
+{
+}
+
+bool JSGeoPolyBounds::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
+
diff --git a/src/standards/Tizen/POI/JSGeoPolyBounds.h b/src/standards/Tizen/POI/JSGeoPolyBounds.h
new file mode 100755 (executable)
index 0000000..d9ce40e
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_GEOPOLYBOUNDS_
+#define _WRTPLUGINS_TIZEN_JS_GEOPOLYBOUNDS_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeoPolyBounds{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_GEOPOLYBOUNDS_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSGeoRectBounds.cpp b/src/standards/Tizen/POI/JSGeoRectBounds.cpp
new file mode 100755 (executable)
index 0000000..64432bc
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSSimpleCoordinates.h"
+#include "JSGeoRectBounds.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSGeoRectBounds::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeoRectBounds::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "GeoRectBounds",                                                                                                                // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSGeoRectBounds::initialize,                    // initialize
+       JSGeoRectBounds::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSGeoRectBounds::constructor, // constructor
+       JSGeoRectBounds::hasInstance,
+       NULL
+};
+
+
+
+const JSClassRef JSGeoRectBounds::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeoRectBounds::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSGeoRectBounds::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[2];
+       for( unsigned int i = 0 ; i < 2; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+
+       if( !JSValueIsObjectOfClass(ctx, convertedArguments[0],TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef() ) || !JSValueIsObjectOfClass(ctx, convertedArguments[1],TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef() ) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Arguments are not SimpleCoordinates");
+               return NULL;
+       }
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);       
+
+       LBSUtil::setProperty(ctx , obj ,"northEast" ,convertedArguments[0], kJSPropertyAttributeReadOnly );
+       LBSUtil::setProperty(ctx , obj ,"southWest" ,convertedArguments[1], kJSPropertyAttributeReadOnly );
+
+       return obj;
+}
+
+
+void JSGeoRectBounds::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSGeoRectBounds::finalize(JSObjectRef object) 
+{
+}
+
+bool JSGeoRectBounds::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
+
diff --git a/src/standards/Tizen/POI/JSGeoRectBounds.h b/src/standards/Tizen/POI/JSGeoRectBounds.h
new file mode 100755 (executable)
index 0000000..1a961a1
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_GEORECTBOUNDS_
+#define _WRTPLUGINS_TIZEN_JS_GEORECTBOUNDS_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeoRectBounds{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       
+
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_GEORECTBOUNDS_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSGeometryFilter.cpp b/src/standards/Tizen/POI/JSGeometryFilter.cpp
new file mode 100755 (executable)
index 0000000..9856688
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSGeometryFilter.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSGeometryFilter::m_jsClassRef = NULL;
+
+JSClassDefinition JSGeometryFilter::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "GeometryFilter",                                                                                                               // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSGeometryFilter::initialize,                   // initialize
+       JSGeometryFilter::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSGeometryFilter::constructor, // constructor
+       JSGeometryFilter::hasInstance,
+       NULL
+};
+
+
+
+const JSClassRef JSGeometryFilter::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSGeometryFilter::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSGeometryFilter::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[2];
+       for( unsigned int i = 0 ; i < 2; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+       JSStringRef validate = JSValueToStringCopy(ctx, convertedArguments[0], NULL);
+       if( validate == NULL ||( !JSStringIsEqualToUTF8CString(validate, "EQUAL") && 
+                !JSStringIsEqualToUTF8CString(validate, "DISJOINT") && 
+                !JSStringIsEqualToUTF8CString(validate, "TOUCHES") && 
+                !JSStringIsEqualToUTF8CString(validate, "WITHIN") &&
+                !JSStringIsEqualToUTF8CString(validate, "OVERLAPS") &&
+                !JSStringIsEqualToUTF8CString(validate, "CONTAINS") &&
+                !JSStringIsEqualToUTF8CString(validate, "INTERSECTS")) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument should be 'EQUAL', 'DISJOINT', 'TOUCHES', 'WITHIN', 'OVERLAPS', 'INTERSECTS', 'CONTAINS'");
+               if( validate != NULL)
+                       JSStringRelease(validate);
+               return NULL;
+       }else
+               JSStringRelease(validate);      
+
+       validate = JSValueToStringCopy(ctx, convertedArguments[1], NULL);
+       if( validate == NULL ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument should be string");
+               return NULL;
+       }else
+               JSStringRelease(validate);      
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);       
+
+       LBSUtil::setProperty(ctx , obj ,"criteria" ,convertedArguments[0], kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"geometry" ,convertedArguments[1], kJSPropertyAttributeNone );
+       return obj;
+}
+
+
+void JSGeometryFilter::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSGeometryFilter::finalize(JSObjectRef object) 
+{
+}
+
+bool JSGeometryFilter::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/POI/JSGeometryFilter.h b/src/standards/Tizen/POI/JSGeometryFilter.h
new file mode 100755 (executable)
index 0000000..c9dda83
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_GEOMETRYFILTER_
+#define _WRTPLUGINS_TIZEN_JS_GEOMETRYFILTER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSGeometryFilter{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_GEOMETRYFILTER_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSPOI.cpp b/src/standards/Tizen/POI/JSPOI.cpp
new file mode 100755 (executable)
index 0000000..d51d6d7
--- /dev/null
@@ -0,0 +1,232 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSPOI.h"
+#include "LBSUtil.h"
+#include "JSPOIGeometry.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSPOI::m_jsClassRef = NULL;
+
+JSClassDefinition JSPOI::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "POI",                                                                                                          // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       JSPOI::m_function,              // static functions
+       JSPOI::initialize,                      // initialize
+       JSPOI::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSPOI::constructor, // constructor
+       JSPOI::hasInstance,
+       NULL
+};
+
+
+JSStaticFunction JSPOI::m_function[] = {
+        { "toGeoJSON",JSPOI::toGeoJSON,kJSPropertyAttributeNone },
+               { 0, 0, 0 }
+};
+
+
+const JSClassRef JSPOI::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSPOI::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSPOI::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+
+       JSValueRef name = NULL;
+       JSValueRef categories= NULL;
+       JSValueRef address = NULL;
+       JSValueRef phoneNumbers = NULL;
+       JSValueRef geometry = NULL;     
+       JSValueRef urls = NULL;
+       JSValueRef rating = NULL;
+       JSValueRef tags = NULL;
+       bool onError = false;
+       
+       if( argumentCount > 0 && JSValueIsObject(ctx, arguments[0])){
+               JSObjectRef arg = JSValueToObject(ctx, arguments[0], NULL);
+               name = LBSUtil::getPropertyToValueRef(ctx, arg, "name") ;
+               categories = LBSUtil::getPropertyToValueRef(ctx, arg, "categories");
+               address = LBSUtil::getPropertyToValueRef(ctx, arg, "address");
+               phoneNumbers = LBSUtil::getPropertyToValueRef(ctx, arg, "phoneNumbers");
+               geometry = LBSUtil::getPropertyToValueRef(ctx, arg, "geometry");
+               urls = LBSUtil::getPropertyToValueRef(ctx, arg, "urls");
+               rating = LBSUtil::getPropertyToValueRef(ctx, arg, "rating");
+               tags = LBSUtil::getPropertyToValueRef(ctx, arg, "tags");                
+       }
+
+       if( name == NULL || JSValueIsUndefined(ctx, name))
+               name = JSValueMakeNull(ctx);    
+       else if( !JSValueIsString(ctx, name) ){
+               JSStringRef jsStr = JSValueToStringCopy(ctx, name, NULL);
+               if( jsStr == NULL ){
+                       onError = true;
+                       goto catchError;
+               }                       
+               name = JSValueMakeString(ctx, jsStr);
+               JSStringRelease(jsStr);
+       }
+       
+       if( categories == NULL || JSValueIsUndefined(ctx, categories)){
+               categories = JSObjectMakeArray(ctx, 0, NULL, NULL);
+       }else if( !JSIsArrayValue(ctx, categories ) ){
+               onError = true;
+               goto catchError;        
+       }
+       
+       if( address == NULL || JSValueIsUndefined(ctx, address))
+               address = JSValueMakeNull(ctx); 
+       else if ( !JSValueIsString(ctx, address) && !JSValueIsObject(ctx, address) ){
+               JSStringRef jsStr = JSValueToStringCopy(ctx, address, NULL);
+               if( jsStr == NULL ){
+                       onError = true;
+                       goto catchError;
+               }                       
+               address = JSValueMakeString(ctx, jsStr);
+               JSStringRelease(jsStr);
+       }
+       
+       if( phoneNumbers == NULL || JSValueIsUndefined(ctx, phoneNumbers)){
+               phoneNumbers = JSObjectMakeArray(ctx, 0, NULL, NULL);
+       }else if( !JSIsArrayValue(ctx, phoneNumbers)){
+               onError = true;
+               goto catchError;
+       }
+       
+       if( urls == NULL || JSValueIsUndefined(ctx, urls)){
+               urls = JSObjectMakeArray(ctx, 0, NULL, NULL);
+       }else if( !JSIsArrayValue(ctx, urls)){
+               onError = true;
+               goto catchError;
+       }
+       
+       if( geometry == NULL || JSValueIsUndefined(ctx, geometry))
+               geometry = JSValueMakeNull(ctx);        
+       else if( !JSValueIsObjectOfClass(ctx, address, JSPOIGeometry::getClassRef())){
+               onError = true;
+               goto catchError;
+       }
+       
+       if( rating == NULL || JSValueIsUndefined(ctx, rating))
+               rating = JSValueMakeNumber(ctx, 0.0);           
+       else if( !JSValueIsNumber(ctx, rating)){
+               double v = JSValueToNumber(ctx, rating, NULL);
+               rating = JSValueMakeNumber(ctx, v);
+       }
+       
+       if( tags == NULL || JSValueIsUndefined(ctx, tags))
+               tags = JSValueMakeNull(ctx);
+       else if(  !JSValueIsObject(ctx, tags)){
+               onError = true;
+               goto catchError;                
+       }
+
+catchError:
+       if( onError ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+               return NULL;
+       }
+
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);
+       LBSUtil::setProperty(ctx , obj ,"id" ,JSValueMakeNull(ctx),  kJSPropertyAttributeReadOnly );
+       LBSUtil::setProperty(ctx , obj ,"providerName" ,JSValueMakeNull(ctx),  kJSPropertyAttributeReadOnly );  
+       LBSUtil::setProperty(ctx , obj ,"name" ,name, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"categories" ,categories, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"address" ,address, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"phoneNumbers" ,phoneNumbers, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"geometry" ,geometry, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"urls" ,urls, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"rating" ,rating, kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"tags" ,tags, kJSPropertyAttributeNone );
+       
+       return obj;
+}
+
+
+void JSPOI::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSPOI::finalize(JSObjectRef object) 
+{
+}
+
+bool JSPOI::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSPOI::toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       double lat = 0.0;
+       double lng = 0.0;
+       char geojson_str[1024];
+       Converter convert(context);
+
+       JSObjectRef geometry = JSValueToObject(context, LBSUtil::getPropertyToValueRef(context, thisObject, "geometry"), NULL);
+       if( geometry != NULL ){
+               JSObjectRef position = JSValueToObject(context, LBSUtil::getPropertyToValueRef(context, geometry, "position"), NULL);
+               if( position != NULL ) {
+                       lat = LBSUtil::getPropertyToDouble(context, position, "latitude");
+                       lng = LBSUtil::getPropertyToDouble(context, position, "longitude");
+               }
+       }
+
+       snprintf(geojson_str, 1024, "{ \"type\": \"Point\", \"coordinates\": [%g, %g] }", lat, lng);
+
+       return convert.toJSValueRef(string(geojson_str));
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/POI/JSPOI.h b/src/standards/Tizen/POI/JSPOI.h
new file mode 100755 (executable)
index 0000000..f4c06a2
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_POI_
+#define _WRTPLUGINS_TIZEN_JS_POI_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSPOI{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+       
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+    static JSValueRef toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_POI_
diff --git a/src/standards/Tizen/POI/JSPOIFilter.cpp b/src/standards/Tizen/POI/JSPOIFilter.cpp
new file mode 100755 (executable)
index 0000000..849032b
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSPOIFilter.h"
+#include "LBSUtil.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+
+JSClassRef JSPOIFilter::m_jsClassRef = NULL;
+
+JSClassDefinition JSPOIFilter::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "POIFilter",                                                                                                            // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSPOIFilter::initialize,                        // initialize
+       JSPOIFilter::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSPOIFilter::constructor, // constructor
+       JSPOIFilter::hasInstance,
+       NULL
+};
+
+const JSClassRef JSPOIFilter::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSPOIFilter::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSPOIFilter::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[2];
+       for( unsigned int i = 0 ; i < 2; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);
+       LBSUtil::setProperty(ctx , obj ,"attributeName" ,convertedArguments[0], kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"value" ,convertedArguments[1], kJSPropertyAttributeNone );
+
+       return obj;
+}
+
+
+void JSPOIFilter::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSPOIFilter::finalize(JSObjectRef object) 
+{
+}
+
+bool JSPOIFilter::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/POI/JSPOIFilter.h b/src/standards/Tizen/POI/JSPOIFilter.h
new file mode 100755 (executable)
index 0000000..5ee77d1
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#ifndef _WRTPLUGINS_TIZEN_JS_POIFILTER_
+#define _WRTPLUGINS_TIZEN_JS_POIFILTER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSPOIFilter{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_POIFILTER_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSPOIGeometry.cpp b/src/standards/Tizen/POI/JSPOIGeometry.cpp
new file mode 100755 (executable)
index 0000000..40d80e5
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSPOIGeometry.h"
+#include "LBSUtil.h"
+#include "JSSimpleCoordinates.h"
+#include "JSGeoRectBounds.h"
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSPOIGeometry::m_jsClassRef = NULL;
+
+JSClassDefinition JSPOIGeometry::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "POIGeometry",                                                                                                          // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       NULL,           // static functions
+       JSPOIGeometry::initialize,                      // initialize
+       JSPOIGeometry::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       JSPOIGeometry::constructor, // constructor
+       JSPOIGeometry::hasInstance,
+       NULL
+};
+
+
+
+const JSClassRef JSPOIGeometry::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSPOIGeometry::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+JSObjectRef JSPOIGeometry::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       JSValueRef convertedArguments[3];
+       for( unsigned int i = 0 ; i < 3; i++ ){
+               if( i < argumentCount )
+                       convertedArguments[i] = arguments[i];
+               else
+                       convertedArguments[i] = JSValueMakeUndefined(ctx);
+       }
+
+
+       if( !JSValueIsObjectOfClass(ctx, convertedArguments[0], TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef()) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "First argument is not SimpleCoordinates");
+               return NULL;
+       }
+
+       if( !JSValueIsObjectOfClass(ctx, convertedArguments[1], TizenApis::Tizen1_0::LBS::JSGeoRectBounds::getClassRef()) ){
+               *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "First argument is not GeoRectBounds");
+               return NULL;
+       }       
+
+       JSObjectRef obj = JSObjectMake(ctx, getClassRef(), NULL);
+
+       LBSUtil::setProperty(ctx , obj ,"position" ,convertedArguments[0], kJSPropertyAttributeNone );
+       LBSUtil::setProperty(ctx , obj ,"viewport" ,convertedArguments[1], kJSPropertyAttributeNone );
+
+       if( JSValueIsString(ctx, convertedArguments[2]) ){
+               LBSUtil::setProperty(ctx , obj ,"wkt" , convertedArguments[2], kJSPropertyAttributeNone );
+       }else
+               LBSUtil::setProperty(ctx , obj ,"wkt" , JSValueMakeNull(ctx), kJSPropertyAttributeNone );
+
+       return obj;
+}
+
+
+void JSPOIGeometry::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+}
+
+void JSPOIGeometry::finalize(JSObjectRef object) 
+{
+}
+
+bool JSPOIGeometry::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/POI/JSPOIGeometry.h b/src/standards/Tizen/POI/JSPOIGeometry.h
new file mode 100755 (executable)
index 0000000..ee895a5
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_POIGEOMETRY_
+#define _WRTPLUGINS_TIZEN_JS_POIGEOMETRY_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSPOIGeometry{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);              
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       
+
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_POIGEOMETRY_
\ No newline at end of file
diff --git a/src/standards/Tizen/POI/JSPOIProvider.cpp b/src/standards/Tizen/POI/JSPOIProvider.cpp
new file mode 100755 (executable)
index 0000000..1aed45c
--- /dev/null
@@ -0,0 +1,794 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSPOIProvider.h"
+#include "JSLocationServiceProvider.h"
+#include "POIProvider.h"
+#include <vector>
+#include "POI.h"
+#include "LBSUtil.h"
+#include "RequestOptions.h"
+#include "GeoAddress.h"
+#include "JSPOI.h"
+#include "POIAce.h"
+#include "JSGeoRectBounds.h"
+#include "JSGeoCircleBounds.h"
+#include "JSGeoPolyBounds.h"
+#include "JSSimpleCoordinates.h"
+#include "JSLBSPending.h"
+#include "LBSPending.h"
+#include "JSLBS.h"
+
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+struct CallbackData {
+       JSObjectRef onSuccess;
+       JSObjectRef onFail;
+};
+
+
+JSContextRef JSPOIProvider::m_globalContextRef = NULL;
+JSClassRef JSPOIProvider::m_jsClassRef = NULL;
+
+JSClassDefinition JSPOIProvider::m_jsClassInfo = {
+       0, // current (and only) version is 0
+       kJSClassAttributeNone, //attributes
+       "POIProvider", // class name
+       JSLocationServiceProvider::getClassRef(), // parent class
+       NULL, //static values
+       JSPOIProvider::m_function, // static functions
+       JSPOIProvider::initialize, // initialize
+       JSPOIProvider::finalize,
+       NULL, //hasProperty
+       JSPOIProvider::getProperty, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       NULL, // constructor
+       JSPOIProvider::hasInstance,
+       NULL
+};
+
+
+JSStaticFunction JSPOIProvider::m_function[] = {
+       { "find",JSPOIProvider::find,kJSPropertyAttributeNone },
+       { "update",JSPOIProvider::update,kJSPropertyAttributeNone },
+       { "add",JSPOIProvider::add,kJSPropertyAttributeNone },
+       { "remove",JSPOIProvider::add,kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+
+const JSClassRef JSPOIProvider::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSPOIProvider::getClassInfo()
+{
+       return &m_jsClassInfo;
+}
+
+void JSPOIProvider::initialize(JSContextRef ctx, JSObjectRef object)
+{
+       if( JSPOIProvider::m_globalContextRef == NULL ){
+               JSPOIProvider::m_globalContextRef = ctx;
+       }
+}
+
+void JSPOIProvider::finalize(JSObjectRef object) 
+{
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(object));
+       if( priv ){
+               delete priv;
+               JSObjectSetPrivate(object, NULL);
+       }
+}
+
+bool JSPOIProvider::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSPOIProvider::getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(object));
+       if( priv == NULL)
+               return NULL;
+       int supportedType = 0;
+
+       if( (JSStringIsEqualToUTF8CString(propertyName, "supportedFilterTypes") && ( supportedType = 1) ) 
+                       || (JSStringIsEqualToUTF8CString(propertyName, "supportedPOIFilterAttributes") && ( supportedType = 2) ) 
+                       || (JSStringIsEqualToUTF8CString(propertyName, "supportedCategories") && ( supportedType = 3) ) 
+               ) {
+
+               vector<string> supportedVector;
+               if( supportedType == 1 )
+                       supportedVector = priv->getSupportedFilterTypes();
+               else if( supportedType == 2 )
+                       supportedVector = priv->getSupportedPOIFilterAttributes();
+               else if( supportedType == 3 )
+                       supportedVector = priv->getSupportedCategories();
+
+               JSValueRef*supportedValues = NULL;
+               supportedValues = new JSValueRef[supportedVector.size()];
+               for( unsigned int i=0 ; i < supportedVector.size(); i++){
+                       JSStringRef valueString =  JSStringCreateWithUTF8CString( supportedVector[i].c_str());
+                       supportedValues[i] = JSValueMakeString(ctx, valueString);
+                       JSStringRelease(valueString);
+               }
+               JSObjectRef supportedArray = JSObjectMakeArray(ctx, supportedVector.size(), supportedValues, NULL);
+               delete [] supportedValues;
+               return supportedArray;
+       }
+       else if( JSStringIsEqualToUTF8CString(propertyName, "capabilities") ) {
+               int count = 0;
+               int nativeCapa[3] = {0,0,0};
+               const char *capaStr[3] = {"REMOVE", "ADD", "UPDATE"};
+               JSValueRef* capbilitiesValues = NULL;
+               capbilitiesValues = new JSValueRef[3];
+               if( priv->isSupportRemove() )
+                       nativeCapa[0] = 1;
+               if(priv->isSupportAdd() )
+                       nativeCapa[1] = 1;
+               if(priv->isSupportUpdate())
+                       nativeCapa[2] = 1;
+
+               for(int i = 0; i < 3 ; i++){
+                       if( nativeCapa[i] ){
+                               JSStringRef valueString =  JSStringCreateWithUTF8CString( capaStr[i] );
+                               capbilitiesValues[count++] = JSValueMakeString(ctx, valueString);
+                               JSStringRelease(valueString);                   
+                       }
+               }               
+
+               JSObjectRef capbilitiesArray = JSObjectMakeArray(ctx, count , capbilitiesValues, NULL);
+               delete [] capbilitiesValues;
+               return capbilitiesArray;                                
+       }
+
+       return NULL;
+}
+
+void __findCallback( int result,  std::vector<POI*> POIArray,  void * user_data ){
+       CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+       if ( userdata == NULL)
+               return;
+
+       if( result == 0 ){
+               JSValueRef* POIValues = NULL;
+               POIValues = new JSValueRef[POIArray.size()];
+               for( unsigned int i=0 ; i < POIArray.size(); i++){
+                       POIValues[i] = POIArray[i]->toJSObject(JSLBS::getGlobalContext());
+                       JSValueProtect(JSLBS::getGlobalContext(), POIValues[i]);
+               }
+               JSObjectRef JSPOIArray = JSObjectMakeArray(JSLBS::getGlobalContext() , POIArray.size(), POIValues, NULL);
+               delete [] POIValues;
+               JSValueRef args[1] = {JSPOIArray};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onSuccess , NULL, 1, args, NULL);
+       }else if(result == POIProvider::POIERROR::NOT_FOUND ){
+               JSObjectRef JSPOIArray = JSObjectMakeArray(JSLBS::getGlobalContext() , 0, NULL, NULL);
+               JSValueRef args[1] = {JSPOIArray};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onSuccess , NULL, 1, args, NULL);
+       }else if(userdata->onFail) {
+               string errorCode;
+               switch(result){
+                       case POIProvider::POIERROR::INVALID_PARAMETER :
+                       case POIProvider::POIERROR::OUT_OF_MEMORY :
+                               errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                               break;
+                       case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                               errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                               break;
+                       case POIProvider::POIERROR::NETWORK_FAILED :
+                               errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                               break;
+               }
+
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , "Fail to search");
+               JSValueRef args[1] = {error};   
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+       }
+
+       if( userdata->onSuccess )
+               JSValueUnprotect(JSLBS::getGlobalContext() , userdata->onSuccess);
+       if( userdata->onFail )
+               JSValueUnprotect(JSLBS::getGlobalContext() , userdata->onFail);
+
+       delete userdata;
+}
+
+
+JSValueRef JSPOIProvider::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       LOGD("%s -start", __func__);
+
+       // Check the Object type
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+       
+       // Check the access control
+       AceSecurityStatus status;
+       if( priv->isUsedExternalNetwork() )
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_READ);
+       else
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_READ_WITH_NETWORK);
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       int ret = -1;
+       LBSPending *pending = NULL;
+       Converter convert(context);
+       RequestOptions options;
+
+       JSValueRef convertedArguments[4];
+       JSObjectRef convertedArgumentObjects[4];
+       for( unsigned int i = 0 ; i < 4; i++ ){
+               if( i < argumentCount ){
+                       convertedArguments[i] = arguments[i];
+                       if( JSValueIsObject(context, arguments[i]) )
+                               convertedArgumentObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+                       else
+                               convertedArgumentObjects[i] = NULL;
+               }else{
+                       convertedArguments[i] = JSValueMakeUndefined(context);
+                       convertedArgumentObjects[i] = NULL;
+               }
+       }
+
+       //Check The second argument is function object(mandatory)
+       if(  convertedArgumentObjects[1] == NULL ||  !JSObjectIsFunction(context, convertedArgumentObjects[1]) )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function");
+
+       //Check The third argument is NULL or Undefine or function object
+       if(  !JSValueIsNull(context, convertedArguments[2]) &&
+                 !JSValueIsUndefined(context, convertedArguments[2]) &&
+                 ( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[2]) )
+          )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be function or null");
+
+       // The 4th argument is options
+       if(  !JSValueIsNull(context, convertedArguments[3]) &&  !JSValueIsUndefined(context, convertedArguments[3])){
+               JSObjectRef jsOptions = convertedArgumentObjects[3];
+               if( jsOptions == NULL )
+                       return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The 4th argument must be dictionary or null");
+               else if(!RequestOptions::convert(context, jsOptions, &options , exception)){
+                       return JSValueMakeUndefined(context);
+               }
+       }
+
+       CallbackData * userdata =  new CallbackData();
+       userdata->onFail = NULL;        
+       userdata->onSuccess = NULL;
+
+       // The second argument is successCallback
+       userdata->onSuccess = convertedArgumentObjects[1];
+       JSValueProtect(context, convertedArguments[1]);
+
+       // The third argument is errorCallback
+       JSObjectRef onfail = convertedArgumentObjects[2];
+       if( onfail != NULL && JSObjectIsFunction(context, onfail)  ){
+               userdata->onFail = onfail;
+               JSValueProtect(context, convertedArguments[2]);
+       }
+
+
+       //the first argument is address
+       JSValueRef addressValue = convertedArguments[0];
+       JSObjectRef addressObj = convertedArgumentObjects[0];
+
+       // Is String object
+       if( JSValueIsString(context, addressValue ) ){
+               LOGD("%s - It is free form string value find", __func__);
+               string address = convert.toString(addressValue);
+               ret = priv->find(address , options, __findCallback, userdata, &pending);
+       }
+       //Is GeoRectBounds object
+       else if( JSValueIsObjectOfClass ( context, addressValue, JSGeoRectBounds::getClassRef())
+           || JSValueIsObjectOfClass ( context, addressValue, JSGeoCircleBounds::getClassRef())
+           || JSValueIsObjectOfClass ( context, addressValue, JSGeoPolyBounds::getClassRef())
+    ){
+               LOGD("%s - It is GeoBound value find", __func__);
+               GeoBounds bound = GeoBounds::convert(context, addressObj);
+               ret = priv->find(bound, options, __findCallback, userdata, &pending);
+       }
+       else{ // Is Address object?
+               LOGD("%s - address maybe value or unknown object", __func__);
+               if( addressObj == NULL){
+                       LOGD("%s - It is free form string value find", __func__);
+                       string address = convert.toString(addressValue);
+                       ret = priv->find(address , options, __findCallback, userdata, &pending);
+               }else{
+                       GeoAddress address = GeoAddress::convert(context, addressObj );
+                       ret = priv->find(address, options, __findCallback, userdata, &pending);
+               }
+       }
+
+       // Error, Should delete callback data
+       if (ret != 0 ){ 
+               JSValueUnprotect(context, userdata->onSuccess);
+               if( userdata->onFail )
+                       JSValueUnprotect(context, userdata->onFail);
+
+               string errorCode;
+               switch(ret){
+                       case POIProvider::POIERROR::OUT_OF_MEMORY :
+                       case POIProvider::POIERROR::INVALID_PARAMETER :
+                               errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                               break;
+                       case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                               errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                               break;
+                       case POIProvider::POIERROR::NOT_FOUND :
+                               errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                               break;
+                       case POIProvider::POIERROR::NETWORK_FAILED :
+                               errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                               break;
+               }
+
+               if( userdata->onFail ) {
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , errorCode);
+                       JSValueRef args[1] = {error};
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+               }
+               delete userdata;
+       }
+
+       if( pending )
+               delete pending;
+       return JSValueMakeUndefined(context);
+}
+
+void __poiResultCallback( int result , POI* poi, void *user_data){
+       CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+       if ( userdata == NULL)
+               return;
+
+       if( result == 0 ){
+               JSValueRef args[1];
+               args[0] = poi->toJSObject(JSLBS::getGlobalContext());
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onSuccess , NULL, 1, args, NULL);
+       }else if(userdata->onFail){
+               string errorCode;
+               switch(result){
+                       case POIProvider::POIERROR::INVALID_PARAMETER :
+                       case POIProvider::POIERROR::OUT_OF_MEMORY :
+                               errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                               break;
+                       case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                               errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                               break;
+                       case POIProvider::POIERROR::NOT_FOUND :
+                               errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                               break;
+                       case POIProvider::POIERROR::NETWORK_FAILED :
+                               errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                               break;
+               }
+
+               JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , "Fail");
+               JSValueRef args[1] = {error};
+               JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+       }
+
+       if( userdata->onSuccess )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onSuccess);
+       if( userdata->onFail )
+               JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onFail);
+
+       delete userdata;
+}
+
+JSValueRef JSPOIProvider::update(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       LOGD("%s -start", __func__);
+       // Check Object type
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+
+       // Check Access control
+       AceSecurityStatus status;
+       if( priv->isUsedExternalNetwork() )
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE);
+       else
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK);
+       
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       if( !priv->isSupportUpdate() ){
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::NOT_SUPPORTED_ERROR );
+       }
+
+       LBSPending *pending = NULL;
+
+       JSValueRef convertedArguments[3];
+       JSObjectRef convertedArgumentObjects[3];
+       for( unsigned int i = 0 ; i < 3; i++ ){
+               if( i < argumentCount ){
+                       convertedArguments[i] = arguments[i];
+                       if( JSValueIsObject(context, arguments[i]) )
+                               convertedArgumentObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+                       else
+                               convertedArgumentObjects[i] = NULL;
+               }else{
+                       convertedArguments[i] = JSValueMakeUndefined(context);
+                       convertedArgumentObjects[i] = NULL;
+               }
+       }
+
+       // The second argument is null or undefined or function object
+       if(  !JSValueIsNull(context, convertedArguments[1]) &&
+                 !JSValueIsUndefined(context, convertedArguments[1]) &&
+                 ( convertedArgumentObjects[1] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[1]) )
+          )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function or null");
+
+       // The third argument is null or undefined or function object
+       if(  !JSValueIsNull(context, convertedArguments[2]) &&
+                 !JSValueIsUndefined(context, convertedArguments[2]) &&
+                 ( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[2]) )
+               )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be function or null");
+
+       //The first argument is POI object
+       JSValueRef poiValue = convertedArguments[0];
+       JSObjectRef poiObject = convertedArgumentObjects[0];
+       if( !JSValueIsObjectOfClass(context, poiValue, JSPOI::getClassRef()) ){
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first arguments must be POI object");
+       }
+
+       POI *poi = new POI();
+       POI::convert(context, poiObject , poi);
+
+       CallbackData * userdata =  NULL;
+
+       // Check callback is exist
+       JSObjectRef onsuccess = convertedArgumentObjects[1];
+       JSObjectRef onfail = convertedArgumentObjects[2];
+       if( onsuccess != NULL || onfail != NULL ){
+               userdata = new CallbackData();
+               userdata->onSuccess = NULL;
+               userdata->onFail = NULL;
+
+               // The first argument is successCallback
+               if( onsuccess != NULL ){
+                       userdata->onSuccess = onsuccess;
+                       JSValueProtect(context, onsuccess);
+               }
+               // The second argument is errorCallback
+               if( onfail != NULL ){
+                       userdata->onFail = onfail;
+                       JSValueProtect(context, onfail);
+               }
+       }
+
+       int ret = priv->update(poi, __poiResultCallback, userdata, &pending);
+       delete poi;
+
+       //Fail to update
+       if( ret != 0 ){
+               if( userdata != NULL){
+                       if( userdata->onSuccess )
+                               JSValueUnprotect(context, userdata->onSuccess);
+                       if( userdata->onFail )
+                               JSValueUnprotect(context, userdata->onFail);
+                       delete userdata;
+               }
+
+               //Error callback
+               if ( onfail != NULL ){
+                       string errorCode;
+                       switch(ret){
+                               case POIProvider::POIERROR::OUT_OF_MEMORY :
+                               case POIProvider::POIERROR::INVALID_PARAMETER :
+                                       errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                                       errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NOT_FOUND :
+                                       errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NETWORK_FAILED :
+                                       errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                                       break;
+                       }
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , errorCode);
+                       JSValueRef args[1] = {error};
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext(), onfail  , NULL, 1, args, NULL);
+               }
+
+       }
+
+       if( pending )
+               delete pending;
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSPOIProvider::add(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       // Check Object type
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+
+       // Check Access control
+       AceSecurityStatus status;
+       if( priv->isUsedExternalNetwork() )
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE);
+       else
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK);
+
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       if( !priv->isSupportAdd() ){
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::NOT_SUPPORTED_ERROR );
+       }
+
+
+       LBSPending *pending = NULL;
+
+       JSValueRef convertedArguments[3];
+       JSObjectRef convertedArgumentObjects[3];
+       for( unsigned int i = 0 ; i < 3; i++ ){
+               if( i < argumentCount ){
+                       convertedArguments[i] = arguments[i];
+                       if( JSValueIsObject(context, arguments[i]) )
+                               convertedArgumentObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+                       else
+                               convertedArgumentObjects[i] = NULL;
+               }else{
+                       convertedArguments[i] = JSValueMakeUndefined(context);
+                       convertedArgumentObjects[i] = NULL;
+               }
+       }
+
+       //Check The second argument is function object(mandatory)
+       if(  convertedArgumentObjects[1] == NULL ||  !JSObjectIsFunction(context, convertedArgumentObjects[1]) )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function");
+
+       //Check The third argument is NULL or Undefine or function object
+       if(  !JSValueIsNull(context, convertedArguments[2]) &&
+                 !JSValueIsUndefined(context, convertedArguments[2]) &&
+                 ( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[2]))
+          )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be function or null");
+
+       // The first argument is POI object
+       JSValueRef poiValue = convertedArguments[0];
+       JSObjectRef poiObject = convertedArgumentObjects[0];
+
+       // Check, argument is POI instance?
+       if( !JSValueIsObjectOfClass(context, poiValue, JSPOI::getClassRef()) )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is not POI Object");
+
+       // Convert POI Object
+       POI *poi = new POI();
+       POI::convert(context, poiObject , poi);
+
+       // Create CallbackData
+       CallbackData * userdata =  NULL;
+       userdata = new CallbackData();
+       userdata->onFail = NULL;
+       userdata->onSuccess = NULL;
+
+       // The second argument is successCallback
+       userdata->onSuccess = convertedArgumentObjects[1];
+       JSValueProtect(context, convertedArguments[1]);
+
+       // The third argument is error callback.
+       JSObjectRef onfail = convertedArgumentObjects[2];
+       if( onfail != NULL ){
+                       userdata->onFail = onfail;
+                       JSValueProtect(context, onfail);
+       }
+
+       // call native add function     
+       int ret = priv->add(poi, __poiResultCallback, userdata, &pending);
+       delete poi;
+
+       // add was failed
+       if( ret != 0 ){
+               // remove callbackdata
+               if( userdata != NULL){
+                       JSValueUnprotect(context, userdata->onSuccess);
+                       if( userdata->onFail )
+                               JSValueUnprotect(context, userdata->onFail);
+                       delete userdata;
+               }
+
+               if( onfail != NULL ){
+                       string errorCode;
+                       switch(ret){
+                               case POIProvider::POIERROR::INVALID_PARAMETER :
+                               case POIProvider::POIERROR::OUT_OF_MEMORY :
+                                       errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                                       errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NOT_FOUND :
+                                       errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NETWORK_FAILED :
+                                       errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                                       break;
+                       }
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , errorCode);
+                       JSValueRef args[1] = {error};
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext(), onfail  , NULL, 1, args, NULL);
+               }
+       }
+
+       if( pending )
+               delete pending;
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSPOIProvider::remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+       // Check Object type
+       POIProvider * priv = reinterpret_cast<POIProvider*>(JSObjectGetPrivate(thisObject));
+       if( priv == NULL)
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+
+       // Check Access control
+       AceSecurityStatus status;
+       if( priv->isUsedExternalNetwork() )
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE);
+       else
+               status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK);
+
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       if( !priv->isSupportRemove() ){
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::NOT_SUPPORTED_ERROR );
+       }
+
+       LBSPending *pending = NULL;
+
+       JSValueRef convertedArguments[3];
+       JSObjectRef convertedArgumentObjects[3];
+       for( unsigned int i = 0 ; i < 3; i++ ){
+               if( i < argumentCount ){
+                       convertedArguments[i] = arguments[i];
+                       if( JSValueIsObject(context, arguments[i]) )
+                               convertedArgumentObjects[i] = JSValueToObject(context, arguments[i] , NULL );
+                       else
+                               convertedArgumentObjects[i] = NULL;
+               }else{
+                       convertedArguments[i] = JSValueMakeUndefined(context);
+                       convertedArgumentObjects[i] = NULL;
+               }
+       }
+
+       // The second argument is null or undefined or function object
+       if(  !JSValueIsNull(context, convertedArguments[1]) &&
+                 !JSValueIsUndefined(context, convertedArguments[1]) &&
+                 ( convertedArgumentObjects[1] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[1]) )
+          )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument must be function or null");
+
+       // The third argument is null or undefined or function object
+       if(  !JSValueIsNull(context, convertedArguments[2]) &&
+                 !JSValueIsUndefined(context, convertedArguments[2]) &&
+                ( convertedArgumentObjects[2] == NULL ||  !JSObjectIsFunction(context, convertedArgumentObjects[2]) )
+          )
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be function or null");
+
+       //The third argument is POI object
+       JSValueRef poiValue = convertedArguments[0];
+       JSObjectRef poiObject = convertedArgumentObjects[0];
+       if( !JSValueIsObjectOfClass(context, poiValue, JSPOI::getClassRef()) ){
+               return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first arguments must be POI object");
+       }
+
+       // Convert POI Object
+       POI *poi = new POI();
+       POI::convert(context, poiObject , poi);
+
+       CallbackData * userdata =  NULL;
+
+       // Check callback is exist
+       JSObjectRef onsuccess = convertedArgumentObjects[1];
+       JSObjectRef onfail = convertedArgumentObjects[2];
+       if( onsuccess != NULL || onfail != NULL ){
+               userdata = new CallbackData();
+               userdata->onSuccess = NULL;
+               userdata->onFail = NULL;
+
+               // The first argument is successCallback
+               if( onsuccess != NULL ){
+                       userdata->onSuccess = onsuccess;
+                       JSValueProtect(context, onsuccess);
+               }
+               // The second argument is errorCallback
+               if( onfail != NULL ){
+                       userdata->onFail = onfail;
+                       JSValueProtect(context, onfail);
+               }
+       }
+
+       // call native function
+       int ret = priv->remove(poi, __poiResultCallback, userdata, &pending);   
+       delete poi;
+
+       // Remove was failed
+       if( ret != 0 ){
+               // Delete callbackdata
+               if( userdata != NULL){
+                       if( userdata->onSuccess )
+                               JSValueUnprotect(context, userdata->onSuccess);
+                       if( userdata->onFail )
+                               JSValueUnprotect(context, userdata->onFail);
+                       delete userdata;
+               }
+               
+               //Error callback
+               if ( onfail != NULL ){
+                       string errorCode;
+                       switch(ret){
+                               case POIProvider::POIERROR::OUT_OF_MEMORY :
+                               case POIProvider::POIERROR::INVALID_PARAMETER :
+                                       errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::SERVICE_NOT_AVAILABLE :
+                                       errorCode = Commons::JSTizenException::NOT_SUPPORTED_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NOT_FOUND :
+                                       errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                                       break;
+                               case POIProvider::POIERROR::NETWORK_FAILED :
+                                       errorCode = Commons::JSTizenException::TIMEOUT_ERROR;
+                                       break;
+                       }
+                       JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , errorCode);
+                       JSValueRef args[1] = {error};   
+                       JSObjectCallAsFunction(JSLBS::getGlobalContext(), onfail  , NULL, 1, args, NULL);
+               }
+       }
+
+       if( pending )
+               delete pending;
+       return JSValueMakeUndefined(context);
+}
+
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/POI/JSPOIProvider.h b/src/standards/Tizen/POI/JSPOIProvider.h
new file mode 100755 (executable)
index 0000000..d4a8d3f
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_POIPROVIDER_
+#define _WRTPLUGINS_TIZEN_JS_POIPROVIDER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSPOIProvider {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+       static JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+
+    static JSValueRef find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef update(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef add(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef remove(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+       static JSContextRef m_globalContextRef; 
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_POIPROVIDER_
diff --git a/src/standards/Tizen/POI/JSPOIServiceManager.cpp b/src/standards/Tizen/POI/JSPOIServiceManager.cpp
new file mode 100755 (executable)
index 0000000..1d54742
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSPOIServiceManager.h"
+#include "JSPOIProvider.h"
+#include "POIAce.h"
+#include "DefaultPOIProvider.h"
+#include "POIProvider.h"
+
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSContextRef JSPOIServiceManager::m_globalContextRef = NULL;
+
+JSValueRef JSPOIServiceManager::m_defaultObj = NULL;
+
+JSClassRef JSPOIServiceManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSPOIServiceManager::m_jsClassInfo = {
+       0,                                                                                                                              // current (and only) version is 0
+       kJSClassAttributeNone,                                                  //attributes
+       "POI",                                                                                                          // class name
+       NULL,                                                                                                           // parent class
+       NULL,                                                                                                           // static values
+       JSPOIServiceManager::m_function,                // static functions
+       JSPOIServiceManager::initialize,                        // initialize
+       JSPOIServiceManager::finalize,
+       NULL, //hasProperty
+       NULL, //getProperty
+       NULL, //setProperty
+       NULL, //deleteProperty
+       NULL, //getPropertyNames
+       NULL,
+       NULL, // constructor
+       JSPOIServiceManager::hasInstance,
+       NULL
+};
+
+
+JSStaticFunction JSPOIServiceManager::m_function[] = {
+        { "getDefaultProvider",JSPOIServiceManager::getDefaultProvider,kJSPropertyAttributeNone },
+        { "getProviders",JSPOIServiceManager::getProviders,kJSPropertyAttributeNone },
+               { 0, 0, 0 }
+};
+
+
+const JSClassRef JSPOIServiceManager::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSPOIServiceManager::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSPOIServiceManager::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+       if( JSPOIServiceManager::m_globalContextRef == NULL ){
+               JSPOIServiceManager::m_globalContextRef = ctx;
+       }
+}
+
+void JSPOIServiceManager::finalize(JSObjectRef object) 
+{
+       if( JSPOIServiceManager::m_defaultObj != NULL ){
+               JSValueUnprotect(JSPOIServiceManager::m_globalContextRef, JSPOIServiceManager::m_defaultObj);
+               JSPOIServiceManager::m_defaultObj = NULL;
+       }
+}
+
+bool JSPOIServiceManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+JSValueRef JSPOIServiceManager::getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+
+       AceSecurityStatus status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_BASIC);
+       
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       
+       if( JSPOIServiceManager::m_defaultObj == NULL){
+               POIProvider *poi = new DefaultPOIProvider();            
+               JSPOIServiceManager::m_defaultObj  = JSObjectMake(context , JSPOIProvider::getClassRef() , poi);
+               JSValueProtect(context, JSPOIServiceManager::m_defaultObj);
+       }
+       return JSPOIServiceManager::m_defaultObj;
+}
+
+JSValueRef JSPOIServiceManager::getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+
+       AceSecurityStatus status = POI_CHECK_ACCESS(POI_FUNCTION_CATEGORY_BASIC);
+
+       if( status != AceSecurityStatus::AccessGranted )
+               return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+       JSValueRef providers[1];
+       JSObjectRef array;
+       providers[0] = getDefaultProvider(context ,object, thisObject, argumentCount, arguments, exception);
+       array = JSObjectMakeArray( context, 1, providers, NULL);
+       return array;
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApi
+
diff --git a/src/standards/Tizen/POI/JSPOIServiceManager.h b/src/standards/Tizen/POI/JSPOIServiceManager.h
new file mode 100755 (executable)
index 0000000..65a4fac
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_POISERVICEMANAGER_
+#define _WRTPLUGINS_TIZEN_JS_POISERVICEMANAGER_
+
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSPOIServiceManager {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+       static JSValueRef m_defaultObj; 
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSValueRef getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+       static JSContextRef m_globalContextRef; 
+
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_POISERVICEMANAGER_
+
diff --git a/src/standards/Tizen/POI/POI.cpp b/src/standards/Tizen/POI/POI.cpp
new file mode 100755 (executable)
index 0000000..834fcaf
--- /dev/null
@@ -0,0 +1,124 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+ #include "POI.h"
+ #include "JSPOI.h"
+ #include "LBSUtil.h"
+ #include <CommonsJavaScript/Converter.h>
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+POI::POI(){
+       addressType = POI::NoneAddress;
+       rating = 0.0;
+}
+
+JSObjectRef POI::toJSObject(JSContextRef ctx){
+       Converter convert(ctx);
+       JSObjectRef obj = JSObjectMake(ctx, JSPOI::getClassRef(), NULL);
+
+       LBSUtil::setProperty(ctx , obj, "id" , convert.toJSValueRef(id),  kJSPropertyAttributeReadOnly );
+       LBSUtil::setProperty(ctx , obj, "providerName" ,convert.toJSValueRef(providerName),  kJSPropertyAttributeReadOnly );    
+       LBSUtil::setProperty(ctx, obj, "name", convert.toJSValueRef(name), kJSPropertyAttributeNone);
+       LBSUtil::setProperty(ctx, obj, "categories", convert.toJSValueRef(categories), kJSPropertyAttributeNone);
+       LBSUtil::setProperty(ctx, obj, "phoneNumbers", convert.toJSValueRef(phoneNumbers), kJSPropertyAttributeNone);
+       LBSUtil::setProperty(ctx, obj, "urls", convert.toJSValueRef(urls), kJSPropertyAttributeNone);
+       LBSUtil::setProperty(ctx, obj, "rating", convert.toJSValueRef(rating), kJSPropertyAttributeNone);
+
+       LBSUtil::setProperty(ctx, obj, "geometry", geometry.toJSObject(ctx), kJSPropertyAttributeNone);
+       if( addressType == SimpleAddress ){
+               LBSUtil::setProperty(ctx, obj, "address", convert.toJSValueRef(simpleAddress), kJSPropertyAttributeNone);       
+       }else if( addressType == StructAddress ){
+               LBSUtil::setProperty(ctx, obj, "address", structedAddress, kJSPropertyAttributeNone);
+       }else{
+               LBSUtil::setProperty(ctx, obj, "address", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+       }       
+
+       if( tags.size() ){
+               JSObjectRef tagObject = JSObjectMake(ctx, NULL, NULL);  
+               for(unsigned int i =0 ; i < tags.size() ; i++)
+                       LBSUtil::setProperty(ctx, tagObject, tags[i].first.c_str() , tags[i].second, kJSPropertyAttributeNone);
+       }else {
+               LBSUtil::setProperty(ctx, obj, "tags", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+       }
+
+       return obj;
+}
+
+POI POI::convert(JSContextRef ctx, JSObjectRef object)
+{
+       POI poi;
+       convert(ctx, object, &poi);
+       return poi;
+}
+
+void POI::convert(JSContextRef ctx, JSObjectRef object, POI *poi)
+{
+       if( poi == NULL )
+               return;
+
+       Converter convert(ctx);
+
+       poi->id = LBSUtil::getPropertyToString(ctx, object, "id");
+       poi->providerName = LBSUtil::getPropertyToString(ctx, object, "providerName");
+       poi->name = LBSUtil::getPropertyToString(ctx, object, "name");
+       poi->categories = convert.toVectorOfStrings(LBSUtil::getPropertyToValueRef(ctx, object, "categories"));
+       poi->phoneNumbers = convert.toVectorOfStrings(LBSUtil::getPropertyToValueRef(ctx, object, "phoneNumber"));
+       poi->urls = convert.toVectorOfStrings(LBSUtil::getPropertyToValueRef(ctx, object, "urls"));
+       poi->rating = convert.toDouble(LBSUtil::getPropertyToValueRef(ctx, object, "rating"));
+
+       JSValueRef address ;
+       address = LBSUtil::getPropertyToValueRef(ctx , object , "address");
+       poi->addressType = POI::NoneAddress;
+       if( JSValueIsString(ctx, address) ){
+               poi->addressType = POI::SimpleAddress;
+               poi->simpleAddress = convert.toString(address);         
+       }else if ( !JSValueIsNull(ctx, address)){
+               JSObjectRef addressObj = JSValueToObject(ctx, address, NULL);
+               GeoAddress::convert(ctx, addressObj,&poi->structedAddress);
+       }
+
+       JSObjectRef geometry = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "geometry"), NULL);
+       if( geometry ){
+               POIGeometry::convert(ctx, geometry, &poi->geometry);
+       }
+
+       JSObjectRef tags = JSValueToObject(ctx, LBSUtil::getPropertyToValueRef(ctx, object, "tags"), NULL);
+       if( tags ){
+               JSPropertyNameArrayRef keyArray = JSObjectCopyPropertyNames(ctx, tags);
+               int nCount = JSPropertyNameArrayGetCount(keyArray);
+               for( int i = 0 ; i < nCount ; i++){
+                       JSStringRef keyString = JSPropertyNameArrayGetNameAtIndex(keyArray, i);
+                       string key = convert.toString(keyString);
+                       JSValueRef jsvalue = JSObjectGetProperty(ctx, tags, keyString, NULL);
+                       string value = convert.toString(jsvalue);
+                       poi->tags.push_back(make_pair(key, value));
+               }
+               JSPropertyNameArrayRelease(keyArray);
+       }       
+
+}
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
diff --git a/src/standards/Tizen/POI/POI.h b/src/standards/Tizen/POI/POI.h
new file mode 100755 (executable)
index 0000000..ca39903
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#ifndef _WRTPLUGINS_TIZEN_INERNALPOI_
+#define _WRTPLUGINS_TIZEN_INERNALPOI_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "GeoAddress.h"
+#include "POIGeometry.h"
+#include "ConvertibleJSObject.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+/**
+ * This object is used only data passing platform <-> JS Layer
+ * Not for private object
+ */
+class POI : public ConvertibleJSObject{
+public:
+       POI();
+       enum AddressType{ NoneAddress , SimpleAddress , StructAddress };
+
+       std::string id;
+       std::string providerName;
+       std::string name;
+       std::vector<std::string> categories;
+
+       AddressType addressType;
+
+       std::string simpleAddress;
+       GeoAddress structedAddress;
+
+       std::vector<std::string> phoneNumbers;
+       std::vector<std::string> urls;
+
+       POIGeometry geometry;
+
+       std::vector<std::pair<std::string, std::string>> tags;
+
+       double rating;
+
+       virtual JSObjectRef toJSObject(JSContextRef context);
+       static POI convert(JSContextRef ctx, JSObjectRef object);
+       static void convert(JSContextRef ctx, JSObjectRef object, POI *poi);    
+
+};
+
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_INERNALPOI_
+
diff --git a/src/standards/Tizen/POI/POIAce.cpp b/src/standards/Tizen/POI/POIAce.cpp
new file mode 100755 (executable)
index 0000000..7cb2379
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <iostream>
+#include <vector>
+#include "POIAce.h"
+
+#define FEATURE_POI_ALL "http://tizen.org/api/poi"
+#define FEATURE_POI_READ "http://tizen.org/api/poi.read"
+#define FEATURE_POI_WRITE "http://tizen.org/api/poi.write"
+#define DEVICE_CAPABILITY_EXT_NET "externalNetworkAccess"
+#define DEVICE_CAPABILITY_POI_READ "poi.read"
+#define DEVICE_CAPABILITY_POI_WRITE "poi.write"
+
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+static AceFunction __create_poi_basic_function();
+static AceFunction __create_poi_read_function();
+static AceFunction __create_poi_read_with_net_function();
+static AceFunction __create_poi_write_function();
+static AceFunction __create_poi_write_with_net_function();
+
+static AceFunction poi_basic_function = __create_poi_basic_function(); 
+static AceFunction poi_read_function = __create_poi_read_function();
+static AceFunction poi_read_with_net_function= __create_poi_read_with_net_function();
+static AceFunction poi_write_function = __create_poi_write_function();
+static AceFunction poi_write_with_net_function = __create_poi_write_with_net_function();
+
+static AceFunction __create_poi_basic_function()
+{
+       AceFeature poi_feature_all(FEATURE_POI_ALL);
+       AceFeature poi_feature_read(FEATURE_POI_READ);
+       AceFeature poi_feature_write(FEATURE_POI_WRITE);        
+
+       AceDeviceCaps empty_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(poi_feature_all);
+       executable_feature_list.push_back(poi_feature_read);
+       executable_feature_list.push_back(poi_feature_write);   
+
+       
+       return {POI_FUNCTION_CATEGORY_BASIC , executable_feature_list, empty_device_caps };
+}
+
+
+
+static AceFunction __create_poi_read_function()
+{
+       AceFeature poi_feature_all(FEATURE_POI_ALL);
+       AceFeature poi_feature_read(FEATURE_POI_READ);
+       AceDeviceCapability poi_read_cap(DEVICE_CAPABILITY_POI_READ, WrtDeviceApis::Commons::AceDeviceCapParams());
+
+       AceDeviceCaps required_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(poi_feature_all);
+       executable_feature_list.push_back(poi_feature_read);
+       required_device_caps.push_back(poi_read_cap);
+
+       return {POI_FUNCTION_CATEGORY_READ , executable_feature_list, required_device_caps };
+}
+
+static AceFunction __create_poi_read_with_net_function()
+{
+       AceFeature poi_feature_all(FEATURE_POI_ALL);
+       AceFeature poi_feature_read(FEATURE_POI_READ);
+       AceDeviceCapability poi_read_cap(DEVICE_CAPABILITY_POI_READ, WrtDeviceApis::Commons::AceDeviceCapParams());
+       AceDeviceCapability ext_network_cap(DEVICE_CAPABILITY_EXT_NET, WrtDeviceApis::Commons::AceDeviceCapParams());
+
+       AceDeviceCaps required_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(poi_feature_all);
+       executable_feature_list.push_back(poi_feature_read);
+       required_device_caps.push_back(poi_read_cap);
+       required_device_caps.push_back(ext_network_cap);        
+
+       return {POI_FUNCTION_CATEGORY_READ_WITH_NETWORK , executable_feature_list, required_device_caps };
+}
+static AceFunction __create_poi_write_function()
+{
+       AceFeature poi_feature_all(FEATURE_POI_ALL);
+       AceFeature poi_feature_write(FEATURE_POI_WRITE);
+       AceDeviceCapability poi_write_cap(DEVICE_CAPABILITY_POI_WRITE, WrtDeviceApis::Commons::AceDeviceCapParams());
+
+       AceDeviceCaps required_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(poi_feature_all);
+       executable_feature_list.push_back(poi_feature_write);
+       required_device_caps.push_back(poi_write_cap);
+
+       return {POI_FUNCTION_CATEGORY_WRITE , executable_feature_list, required_device_caps };
+}
+static AceFunction __create_poi_write_with_net_function()
+{
+       AceFeature poi_feature_all(FEATURE_POI_ALL);
+       AceFeature poi_feature_write(FEATURE_POI_WRITE);
+       AceDeviceCapability poi_write_cap(DEVICE_CAPABILITY_POI_WRITE, WrtDeviceApis::Commons::AceDeviceCapParams());
+       AceDeviceCapability ext_network_cap(DEVICE_CAPABILITY_EXT_NET, WrtDeviceApis::Commons::AceDeviceCapParams());
+
+       AceDeviceCaps required_device_caps;
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(poi_feature_all);
+       executable_feature_list.push_back(poi_feature_write);
+       required_device_caps.push_back(poi_write_cap);
+       required_device_caps.push_back(ext_network_cap);        
+
+       return {POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK , executable_feature_list, required_device_caps };
+}
+
+
+AceFunction getPOIFunctionData(const std::string & functionId){
+       if( functionId == POI_FUNCTION_CATEGORY_READ )
+               return poi_read_function; 
+       else if( functionId == POI_FUNCTION_CATEGORY_WRITE)
+               return poi_write_function;
+       else if( functionId == POI_FUNCTION_CATEGORY_READ_WITH_NETWORK )
+               return poi_read_with_net_function;
+       else if( functionId == POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK )
+               return poi_write_with_net_function;
+       else if( functionId == POI_FUNCTION_CATEGORY_BASIC )
+               return poi_basic_function;
+       return AceFunction();
+}
+       
+} //LBS
+} // Tizen1_0
+} //TizenApis
+
+
diff --git a/src/standards/Tizen/POI/POIAce.h b/src/standards/Tizen/POI/POIAce.h
new file mode 100755 (executable)
index 0000000..647ecb5
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef _WRTPLUGINS_TIZEN_POIACE_
+#define _WRTPLUGINS_TIZEN_POIACE_
+
+#include <string>
+#include <Commons/FunctionDeclaration.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+#define POI_FUNCTION_CATEGORY_BASIC "POI_FUNCTION_BASIC"
+#define POI_FUNCTION_CATEGORY_READ "POI_FUNCTION_READ"
+#define POI_FUNCTION_CATEGORY_WRITE "POI_FUNCTION_WRITE"
+#define POI_FUNCTION_CATEGORY_READ_WITH_NETWORK "POI_FUNCTION_READ_NETWORK"
+#define POI_FUNCTION_CATEGORY_WRITE_WITH_NETWORK "POI_FUNCTION_WRITE_NETWORK"
+
+
+WrtDeviceApis::Commons::AceFunction getPOIFunctionData(const std::string & functionId);
+
+#define POI_CHECK_ACCESS(functionName)                     \
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
+        getPOIFunctionData,           \
+        functionName)
+
+} // LBS
+} // Tizen1_0
+} // Tizen
+
+#endif // _WRTPLUGINS_TIZEN_POIACE_
+
diff --git a/src/standards/Tizen/POI/POIFilter.cpp b/src/standards/Tizen/POI/POIFilter.cpp
new file mode 100755 (executable)
index 0000000..f55278a
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "POIFilter.h"
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+POIFilter POIFilter::convert(JSContextRef ctx, JSObjectRef object){
+       POIFilter filter;
+       filter.numberValue = -1;
+
+       filter.attributeName = LBSUtil::getPropertyToString(ctx, object, "attributeName");
+       JSValueRef value = LBSUtil::getPropertyToValueRef(ctx, object, "value");
+       
+       if( JSValueIsNumber(ctx, value) ){
+               filter.numberValue = JSValueToNumber(ctx, value, NULL);
+       }else{
+               Converter convert(ctx);
+               filter.strValue = convert.toString(value);
+       }
+
+       return filter;
+}
+
+
+
+}
+}
+}
+
+
old mode 100644 (file)
new mode 100755 (executable)
similarity index 64%
rename from src/platform/API/Geocoder/IGeocoder.cpp
rename to src/standards/Tizen/POI/POIFilter.h
index 0c7bf08..f26d66b
  * limitations under the License. 
  */
 
+#ifndef _WRTPLUGINS_TIZEN_POIFILTER_
+#define _WRTPLUGINS_TIZEN_POIFILTER_
 
-
-
-
-/*
- * @author
- */
-
-#include "IGeocoder.h"
-
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
 namespace TizenApis {
-namespace Tizen1_0{
-namespace Api {
-namespace Geocoder{
+namespace Tizen1_0 {
+namespace LBS{
 
-//using namespace Platform;
 
-//TODO check thread type
-IGeocoder::IGeocoder() :
-        WrtDeviceApis::Commons::EventRequestReceiver<EventGeocoder>(WrtDeviceApis::Commons::ThreadEnum::GEOLOCATION_THREAD)
-{
-}
+class POIFilter{
+public:
+       std::string attributeName;
+       std::string strValue;
+       double numberValue;
 
-IGeocoder::~IGeocoder()
-{
-}
+static POIFilter convert(JSContextRef ctx, JSObjectRef object);
+
+};
 
 }
 }
 }
-}
+
+#endif //_WRTPLUGINS_TIZEN_POIFILTER_
+
diff --git a/src/standards/Tizen/POI/POIGeometry.cpp b/src/standards/Tizen/POI/POIGeometry.cpp
new file mode 100755 (executable)
index 0000000..b593abe
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <dlog.h>
+#include "POIGeometry.h"
+#include "LBSUtil.h"
+#include "LBSConverter.h"
+#include "JSPOIGeometry.h"
+#include "JSSimpleCoordinates.h"
+#include <JavaScriptCore/JavaScript.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+
+JSObjectRef POIGeometry::toJSObject(JSContextRef context)
+{
+       JSObjectRef obj = JSObjectMake(context, JSPOIGeometry::getClassRef(), NULL);
+
+       JSObjectRef positionObj = JSObjectMake(context, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+       LBSUtil::setProperty(context, positionObj, "latitude", position[0] , kJSPropertyAttributeNone);
+       LBSUtil::setProperty(context, positionObj, "longitude", position[1] , kJSPropertyAttributeNone);
+
+       LBSUtil::setProperty(context, obj, "position", positionObj, kJSPropertyAttributeNone);
+       LBSUtil::setProperty(context, obj, "viewport", viewport, kJSPropertyAttributeNone);
+       if( wellKnownText.size() > 0 ){
+               LBSUtil::setProperty(context, obj, "wkt", wellKnownText, kJSPropertyAttributeNone);
+       }
+       
+       return obj;
+}
+
+POIGeometry POIGeometry::convert(JSContextRef ctx, JSObjectRef object){
+       POIGeometry geometry;
+       convert(ctx, object, &geometry);
+       return geometry;
+}
+
+void POIGeometry::convert(JSContextRef ctx, JSObjectRef object, POIGeometry *geometry)
+{
+       if( geometry == NULL)
+               return ;
+
+       JSValueRef jsVPosition = LBSUtil::getPropertyToValueRef(ctx, object, "position");
+       JSObjectRef jsOPostion = JSValueToObject(ctx, jsVPosition, NULL);
+       if( jsOPostion ){
+               geometry->position[0] = LBSUtil::getPropertyToDouble(ctx, jsOPostion, "latitude");
+               geometry->position[1] = LBSUtil::getPropertyToDouble(ctx, jsOPostion, "longitude");
+       }
+       geometry->wellKnownText = LBSUtil::getPropertyToString(ctx, object, "wkt");
+
+       JSValueRef jsVviewport = LBSUtil::getPropertyToValueRef(ctx, object, "viewport");
+       JSObjectRef jsOviewport = JSValueToObject(ctx, jsVviewport, NULL);
+       if( jsOviewport ){
+               GeoBounds::convert(ctx, jsOviewport, &geometry->viewport );
+       }
+
+}
+
+}// LBS
+}//Tizen1_0
+}//TizenApis
similarity index 52%
rename from src/platform/Tizen/Filesystem/RemoveCommand.h
rename to src/standards/Tizen/POI/POIGeometry.h
index 1ee2719..76b8eaf 100755 (executable)
  * limitations under the License. 
  */
 
+#ifndef _WRTPLUGINS_TIZEN_POIGEOMETRY_
+#define _WRTPLUGINS_TIZEN_POIGEOMETRY_
 
-#ifndef TIZENAPIS_FILESYSTEM_REMOVECOMMAND_H_
-#define TIZENAPIS_FILESYSTEM_REMOVECOMMAND_H_
-
-#include "Command.h"
-#include <API/Filesystem/IPath.h>
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+#include "GeoBounds.h"
 
 namespace TizenApis {
-namespace Platform {
-namespace Filesystem {
-class RemoveCommand : public Command
-{
-  public:
-    explicit RemoveCommand(const Api::Filesystem::IPathPtr& path);
-    void setRecursive(bool recursive);
-    void setForce(bool force);
-
-  protected:
-    std::string prepare();
-
-  private:
-    Api::Filesystem::IPathPtr m_path;
-    bool m_recursive;
-    bool m_force;
+namespace Tizen1_0 {
+namespace LBS{
+
+class POIGeometry : public ConvertibleJSObject{
+public:
+       double position[2];
+
+       GeoBounds viewport;
+       std::string wellKnownText;
+
+       virtual JSObjectRef toJSObject(JSContextRef context);
+
+       static POIGeometry convert(JSContextRef ctx, JSObjectRef object);
+       static void convert(JSContextRef ctx, JSObjectRef object, POIGeometry *geometry);
+
+
 };
+
 }
 }
 }
 
-#endif // TIZENAPIS_FILESYSTEM_REMOVECOMMAND_H_
\ No newline at end of file
+#endif //_WRTPLUGINS_TIZEN_POIGEOMETRY_
diff --git a/src/standards/Tizen/POI/POIProvider.cpp b/src/standards/Tizen/POI/POIProvider.cpp
new file mode 100755 (executable)
index 0000000..dd8b0d6
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "POIProvider.h"
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+
+
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_POI"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+POIProvider::POIProvider(std::string _name): name(_name){
+}
+
+POIProvider::~POIProvider()
+{
+}
+
+void POIProvider::setName(std::string &setName){
+       name = setName;
+}
+
+std::string POIProvider::getName(){
+       return name;
+}
+
+std::string POIProvider::getAttribution(){
+       return "";
+}
+
+} //LBS
+} //Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/POI/POIProvider.h b/src/standards/Tizen/POI/POIProvider.h
new file mode 100755 (executable)
index 0000000..05cf03a
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_POIPROVIDER_
+#define _WRTPLUGINS_TIZEN_POIPROVIDER_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "POI.h"
+#include "LocationServiceProvider.h"
+#include "GeoAddress.h"
+#include "RequestOptions.h"
+#include "GeoBounds.h"
+#include "LBSPending.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+typedef void (* POIArrayCallback )( int result, std::vector<POI*> POIArray,  void * user_data );
+typedef void (*POIResultCallback)( int result ,POI* poi, void *user_data);
+
+class POIProvider :public LocationServiceProvider{
+       private:
+               std::string name;
+
+       protected:
+               void setName(std::string &name);
+               
+       public:
+
+               enum POIERROR{ NONE = 0 , INVALID_PARAMETER , OUT_OF_MEMORY, SERVICE_NOT_AVAILABLE, NOT_FOUND, NETWORK_FAILED};
+               
+               POIProvider(std::string _name);
+               virtual ~POIProvider();
+               virtual std::string getName();
+               virtual std::string getAttribution();
+               virtual std::vector<std::pair<std::string, std::string>> getMetadata()=0;
+               virtual std::vector<std::string> getSupportedOptions()=0;
+               virtual std::string getConnectivity()=0;
+               virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)=0;
+               virtual bool isUsedExternalNetwork()=0;
+
+
+               virtual std::vector<std::string> getSupportedFilterTypes()=0;
+               virtual std::vector<std::string> getSupportedPOIFilterAttributes()=0;
+               virtual std::vector<std::string> getSupportedCategories()=0;
+
+               virtual bool isSupportRemove()=0;
+               virtual bool isSupportUpdate()=0;
+               virtual bool isSupportAdd()=0;
+
+               virtual int find( GeoBounds bound  , RequestOptions& option ,  POIArrayCallback callback, void * user_data, LBSPending **pending)=0;
+               virtual int find( std::string& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending)=0;
+               virtual int find( GeoAddress& address , RequestOptions& option , POIArrayCallback callback, void * user_data, LBSPending **pending)=0;
+               
+               virtual int update( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending)=0;
+               virtual int add( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending)=0;
+               virtual int remove( POI* poi , POIResultCallback callback, void *user_data , LBSPending **pending)=0;
+       
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_POIPROVIDER_
+
diff --git a/src/standards/Tizen/POI/RequestOptions.cpp b/src/standards/Tizen/POI/RequestOptions.cpp
new file mode 100755 (executable)
index 0000000..379b802
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RequestOptions.h"
+#include "LBSUtil.h"
+#include "JSPOIFilter.h"
+#include "JSGeometryFilter.h"
+#include "JSSortMode.h"
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <limits>
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_LBS"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+RequestOptions::RequestOptions(){
+       filterType = FilterType::NONE;
+       addressType = AddressType::FORMATTED;
+       sortOrder = SortOrder::ASC;
+       maxResult = 10;
+       offset = 0;
+}
+
+bool RequestOptions::convert(JSContextRef ctx, JSObjectRef object, RequestOptions* options, JSValueRef* exception){
+       if(options == NULL){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "not object value");
+               return false;
+       }
+
+       //Convert filter
+       JSValueRef filterValue = LBSUtil::getPropertyToValueRef(ctx, object, "filter");
+       JSObjectRef filterObj= JSValueToObject(ctx, filterValue, NULL);
+       if( JSValueIsObjectOfClass(ctx, filterValue, JSPOIFilter::getClassRef()) ){
+               options->poiFilter = POIFilter::convert(ctx, filterObj);
+               options->filterType = FilterType::POI;
+       }else if( JSValueIsObjectOfClass(ctx, filterValue, JSGeometryFilter::getClassRef()) ){
+               options->geoFilter = GeometryFilter::convert(ctx, filterObj);
+               options->filterType = FilterType::GEO;
+       }else   if( !JSValueIsNull(ctx, filterValue) && !JSValueIsUndefined(ctx, filterValue) ){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "filter is not filter object");
+               return false;
+       }
+
+       //Convert sortMode
+       JSValueRef sortModeValue = LBSUtil::getPropertyToValueRef(ctx, object, "sortMode");
+       if( JSValueIsObjectOfClass(ctx, sortModeValue, TizenApis::Tizen1_0::Tizen::JSSortMode::getClassRef()) ){
+               JSObjectRef sortModeObject = JSValueToObject(ctx, sortModeValue , NULL);
+               options->sortAttributeName = LBSUtil::getPropertyToString(ctx, sortModeObject, "attributeName");
+               std::string order = LBSUtil::getPropertyToString(ctx, sortModeObject, "order");
+               if( order == "ASC" )
+                       options->sortOrder = SortOrder::ASC;
+               else if( order == "DESC" )
+                       options->sortOrder = SortOrder::DESC;
+       }else if( !JSValueIsNull(ctx, sortModeValue) && !JSValueIsUndefined(ctx, sortModeValue) ){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "sortMode is not SortMode object");
+               return false;
+       }
+
+       //Convert maxResult
+       JSValueRef maxResultsValue = LBSUtil::getPropertyToValueRef(ctx, object, "maxResults");
+       double maxresult = JSValueToNumber(ctx, maxResultsValue , NULL);
+       if( maxresult != std::numeric_limits<double>::quiet_NaN() )
+               options->maxResult = maxresult;
+       else{
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "maxResults is not number");
+               return false;
+       }
+
+       //Convert offset
+       JSValueRef offsetValue = LBSUtil::getPropertyToValueRef(ctx, object, "offset");
+       double offsetnumber = JSValueToNumber(ctx, offsetValue, NULL);
+       if( offsetnumber != std::numeric_limits<double>::quiet_NaN() ){
+               options->offset = offsetnumber;
+       }else if( !JSValueIsNull(ctx, offsetValue) && !JSValueIsUndefined(ctx, offsetValue) ){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "offset is not number");
+               return false;
+       }
+
+       //Convert cagegories
+       JSValueRef jsCategories = LBSUtil::getPropertyToValueRef(ctx, object, "categories");
+       if( JSIsArrayValue(ctx , jsCategories) ){
+               Converter convert(ctx);
+               options->categories = convert.toVectorOfStrings(jsCategories);
+       }else if( !JSValueIsNull(ctx, jsCategories) && !JSValueIsUndefined(ctx, jsCategories) ){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "categories is not array");
+               return false;
+       }
+
+       //Convert addressType
+       JSValueRef jsAddressType = LBSUtil::getPropertyToValueRef(ctx, object, "addressType");
+       if( JSValueIsString(ctx, jsAddressType) ){
+               JSStringRef validate = JSValueToStringCopy(ctx, jsAddressType, NULL);
+               if( JSStringIsEqualToUTF8CString(validate, "FORMATTED") )
+                       options->addressType = AddressType::FORMATTED;
+               else if( JSStringIsEqualToUTF8CString(validate, "STRUCTURED") )
+                       options->addressType = AddressType::STRUCTURED;
+               else{
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The addressType should be 'FORMATTED', 'STRUCTURED'");
+                       JSStringRelease(validate);
+                       return false;
+               }
+               if( validate )
+                       JSStringRelease(validate);
+       }else if( !JSValueIsNull(ctx, jsAddressType) && !JSValueIsUndefined(ctx, jsAddressType) ){
+               if( exception )
+                       *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "The addressType is not string");
+               return false;
+       }
+
+       return true;
+}
+
+}//LSB
+}// Tizen1_0
+}// TizenApis
+
diff --git a/src/standards/Tizen/POI/RequestOptions.h b/src/standards/Tizen/POI/RequestOptions.h
new file mode 100755 (executable)
index 0000000..3e7c9b7
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_REQUESTOPTIONS_
+#define _WRTPLUGINS_TIZEN_REQUESTOPTIONS_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "GeometryFilter.h"
+#include "POIFilter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+class RequestOptions{
+public:
+       enum AddressType { STRUCTURED , FORMATTED };
+       enum SortOrder { ASC , DESC };
+       enum FilterType { NONE, GEO , POI };
+       
+       RequestOptions();
+
+       std::vector<std::string> categories;
+       FilterType filterType;
+       POIFilter poiFilter;
+       GeometryFilter geoFilter;
+       AddressType addressType;
+       std::string sortAttributeName;
+       SortOrder sortOrder;
+       unsigned int maxResult;
+       unsigned int offset;
+
+       static bool convert(JSContextRef ctx, JSObjectRef object, RequestOptions *options, JSValueRef* exception);
+
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_REQUESTOPTIONS_
diff --git a/src/standards/Tizen/POI/config.xml b/src/standards/Tizen/POI/config.xml
new file mode 100755 (executable)
index 0000000..dfa0efb
--- /dev/null
@@ -0,0 +1,24 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+       <library-name>libwrt-plugins-tizen-1.0-poi.so</library-name>
+       <feature-install-uri>poi.install.uri</feature-install-uri>
+       <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+       <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+       <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+
+       <api-feature>
+               <name>http://tizen.org/api/poi</name>
+               <device-capability>poi.read</device-capability>
+               <device-capability>poi.write</device-capability>
+       </api-feature>
+       <api-feature>
+               <name>http://tizen.org/api/poi.read</name>
+               <device-capability>poi.read</device-capability>
+       </api-feature>
+       <api-feature>
+               <name>http://tizen.org/api/poi.write</name>
+               <device-capability>poi.write</device-capability>
+       </api-feature>
+</plugin-properties>
+
diff --git a/src/standards/Tizen/POI/plugin_initializer.cpp b/src/standards/Tizen/POI/plugin_initializer.cpp
new file mode 100755 (executable)
index 0000000..81e1b9f
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#define LOG_TAG "TIZEN_LBS"
+
+#include <dlog.h>
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include "JSPOIServiceManager.h"
+#include "JSPOI.h"
+#include "JSPOIGeometry.h"
+#include "JSGeoRectBounds.h"
+#include "JSGeoPolyBounds.h"
+#include "JSGeoCircleBounds.h"
+#include "JSPOIFilter.h"
+#include "JSGeometryFilter.h"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+
+void on_widget_start_callback(int widgetId) {
+       LOGD("on POI widget start callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess initialization failed");
+    }
+}
+
+void on_widget_stop_callback(int widgetId) {
+    LOGD("on LBS widget stop callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess deinitialization failed");
+    }
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs" , "poi",
+      TizenApis::Tizen1_0::LBS::JSPOIServiceManager::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "POI",
+      TizenApis::Tizen1_0::LBS::JSPOI::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "POIGeometry",
+      TizenApis::Tizen1_0::LBS::JSPOIGeometry::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "GeoRectBounds",
+      TizenApis::Tizen1_0::LBS::JSGeoRectBounds::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "GeoCircleBounds",
+      TizenApis::Tizen1_0::LBS::JSGeoCircleBounds::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "GeoPolyBounds",
+      TizenApis::Tizen1_0::LBS::JSGeoPolyBounds::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "POIFilter",
+      TizenApis::Tizen1_0::LBS::JSPOIFilter::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs", "GeometryFilter",
+      TizenApis::Tizen1_0::LBS::JSGeometryFilter::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_END
+
diff --git a/src/standards/Tizen/Route/CMakeLists.txt b/src/standards/Tizen/Route/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..126cc43
--- /dev/null
@@ -0,0 +1,60 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-route") 
+set(DESTINATION_NAME "tizen-1.0-route") 
+set(TARGET_IMPL_NAME "wrt-plugins-tizen-1.0-route-impl")
+
+pkg_search_module(route REQUIRED capi-location-route capi-location-manager)
+
+include_directories( 
+    ${route_INCLUDE_DIRS}
+    ../LBS
+    ../Tizen 
+)
+
+set(CMAKE_INSTALL_RPATH 
+    ${CMAKE_INSTALL_RPATH}
+    ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
+    ${CMAKE_INSTALL_PREFIX}/tizen-1.0-tizen
+    ${CMAKE_INSTALL_PREFIX}/tizen-1.0-lbs )
+    
+set(SRCS_IMPL 
+    JSRouteDuration.cpp
+    JSRouteResultSummary.cpp
+    JSRouteStep.cpp
+    JSRouteDistance.cpp
+    JSRouteResult.cpp
+    JSRouteServiceManager.cpp
+    JSRouteProvider.cpp
+    JSRouteSegment.cpp
+    DefaultRouteProvider.cpp
+    RouteDuration.cpp
+    RouteResult.cpp
+    RouteStep.cpp
+    RouteAce.cpp
+    RouteProvider.cpp
+    RouteResultSummary.cpp
+    RouteDistance.cpp
+    RouteRequestOptions.cpp
+    RouteSegment.cpp
+)
+
+add_library(${TARGET_IMPL_NAME} SHARED ${SRCS_IMPL}) 
+
+target_link_libraries(${TARGET_IMPL_NAME} 
+    wrt-plugins-tizen-1.0-tizen-impl
+    wrt-plugins-tizen-1.0-lbs-impl  
+    ${LIBS_COMMON}
+    ${route_LIBRARIES} 
+)
+
+set(SRCS 
+    plugin_initializer.cpp 
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS}) 
+
+target_link_libraries(${TARGET_NAME}
+    ${TARGET_IMPL_NAME} 
+)
+
+INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME}) 
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME}) 
\ No newline at end of file
diff --git a/src/standards/Tizen/Route/DefaultRouteProvider.cpp b/src/standards/Tizen/Route/DefaultRouteProvider.cpp
new file mode 100755 (executable)
index 0000000..5f26510
--- /dev/null
@@ -0,0 +1,646 @@
+#include <dlog.h>
+#include "DefaultRouteProvider.h"
+#include "RouteRequestOptions.h"
+#include "RouteResult.h"
+#include "RouteSegment.h"
+#include "RouteStep.h"
+#include <location_preference.h>
+#include <route_preference.h>
+#include <route.h>
+#include <route_service.h>
+#include <glib.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+typedef struct {
+    int ret;
+    void *user_data;
+    setOptionCb callback;
+}callback_data;
+
+typedef struct {
+    void *user_data;
+    RouteArrayCallback callback;
+    RouteRequestOptions option; 
+    std::vector<RouteResult*> list; 
+}route_search_callback_data;
+    
+typedef struct {
+    std::string distanceUnit;
+    std::vector<wayPoint> wayPoints;
+    int segment_num;
+    std::vector<RouteSegment*> segments;
+}segment_info;
+
+typedef struct {
+    std::string distanceUnit;
+    std::vector<RouteStep*> steps;    
+}step_info;
+
+bool DefaultRouteProvider::preference_init_cb(const char *property, void *user_data)
+{
+    int ret;
+    DefaultRouteProvider *obj = (DefaultRouteProvider *)user_data;
+    string key(property);
+    char* value_str = NULL;
+    ret = location_preference_get(obj->nativeHandle, property, &value_str);
+    if( ret == 0 && value_str != NULL ){
+        string value(value_str);
+        free(value_str);
+        obj->metadata.push_back(make_pair(key,value));
+    }
+    obj->supportedOptions.push_back(key);
+    return true;    
+}
+
+bool DefaultRouteProvider::supportedGoal_cb(const char *goal, void *user_data)
+{
+    DefaultRouteProvider *obj = (DefaultRouteProvider *)user_data;
+    string supportedGoal(goal);
+    obj->supportedGoals.push_back(supportedGoal);
+    return true;    
+}
+
+bool DefaultRouteProvider::supportedMode_cb(const char *mode, void *user_data)
+{
+    DefaultRouteProvider *obj = (DefaultRouteProvider *)user_data;
+    string supportedMode(mode);
+    obj->supportedModes.push_back(supportedMode);
+    return true;    
+}
+
+bool DefaultRouteProvider::supportedConstraint_cb(const char *constraint, void *user_data)
+{
+    DefaultRouteProvider *obj = (DefaultRouteProvider *)user_data;
+    string supportedConstraint(constraint);
+    obj->supportedConstraints.push_back(supportedConstraint);
+    return true;    
+}
+
+int DefaultRouteProvider::setOption_cb(void* user_data)
+{
+    callback_data *data = (callback_data*)user_data;
+    if( data == NULL)
+        return false;
+
+    data->callback( data->ret , data->user_data);
+    
+    if( data != NULL)
+        delete data;
+    return false;
+}
+
+DefaultRouteProvider::DefaultRouteProvider():RouteProvider("default"), nativeHandle(NULL)
+{    
+    int ret = route_service_create(&nativeHandle);
+    if( ret != 0 ){
+        LOGE("Error create Route service");
+        return;
+    }
+
+    char *provider_name = NULL;
+    ret = location_preference_get_provider_name(GET_LOCATION_SERVICE(nativeHandle) , &provider_name);
+    if( ret == 0 && provider_name != NULL){
+        string providerName(provider_name);
+        setName(providerName);  
+        free(provider_name);
+    }   
+
+    metadata.clear();
+    supportedOptions.clear();
+    supportedGoals.clear();
+    supportedModes.clear();
+    
+    location_preference_foreach_available_property_keys(GET_LOCATION_SERVICE(nativeHandle) , preference_init_cb, this); 
+    route_preference_foreach_available_goals(nativeHandle , supportedGoal_cb, this);
+    route_preference_foreach_available_transport_modes(nativeHandle , supportedMode_cb, this);
+    route_preference_foreach_available_constraints(nativeHandle , supportedConstraint_cb, this);
+}
+
+DefaultRouteProvider::~DefaultRouteProvider()
+{
+    route_service_destroy(nativeHandle);
+}
+
+vector<string> DefaultRouteProvider::getSupportedOptions()
+{
+    return supportedOptions;
+}
+
+vector<pair<string, string>> DefaultRouteProvider::getMetadata()
+{
+    return metadata;
+}
+
+int DefaultRouteProvider::setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)
+{
+    std::vector<std::pair<std::string, std::string>>::iterator pos;
+    for( pos = options.begin() ; pos != options.end() ; ++pos){
+        vector<string>::iterator check;
+        bool isvalid = false;
+        for ( check = supportedOptions.begin() ; check != supportedOptions.end() ; ++check ){
+            if( *check == pos->first )
+                isvalid = true;
+        }
+        if( isvalid == false )
+            return -1;
+    }
+
+    for( pos = options.begin() ; pos != options.end() ; ++pos){
+        std::vector<std::pair<std::string, std::string>>::iterator target;
+        int find = false;
+        for( target = metadata.begin() ; target != metadata.end() ; ++target){
+            if ( target->first == pos->first ){
+                find = true;
+                target->second = pos->second;
+            }
+        }
+        if( !find ){
+            metadata.push_back(*pos);
+        }
+    }
+
+    vector<pair<string, string>>::iterator key;
+    vector<pair<string, string>> newMetadata;
+    for( key = metadata.begin(); key != metadata.end() ; ++key){
+        if( 0 == location_preference_set(GET_LOCATION_SERVICE(nativeHandle), key->first.c_str() , key->second.c_str()))
+            newMetadata.push_back(*key);
+    }
+    metadata = newMetadata;
+
+    callback_data *data = new callback_data();
+
+    data->user_data = user_data;
+    data->callback = callback;
+    data->ret = 0;
+    g_idle_add_full(G_PRIORITY_HIGH_IDLE, setOption_cb, data, NULL);
+    return 0;
+}
+
+string DefaultRouteProvider::getConnectivity()
+{
+    return string("ONLINE");
+}
+
+bool DefaultRouteProvider::isUsedExternalNetwork()
+{
+    return true;
+}
+
+static bool __cancel_operation(int id, void *user_data)
+{
+    bool ret = false;
+    DefaultRouteProvider * obj = reinterpret_cast<DefaultRouteProvider*>(user_data);
+    if( obj )
+        ret = obj->cancel(id);
+    return ret;
+}
+
+vector<string> DefaultRouteProvider::getSupportedGoals()
+{
+    return supportedGoals;
+}
+
+vector<string> DefaultRouteProvider::getSupportedModes()
+{
+    return supportedModes;
+}
+
+vector<string> DefaultRouteProvider::getSupportedConstraints()
+{
+    return supportedConstraints;
+}
+
+bool DefaultRouteProvider::supportswayPoints()
+{
+    return true;
+}
+
+bool __isStopOver(int segment_num, vector<wayPoint> wayPoints)
+{
+    if(wayPoints.size() < (unsigned int)segment_num)
+        return false;
+    else    
+        return wayPoints[segment_num].isStopover;
+/*
+    location_coords_s origin;
+    route_segment_get_origin(segment, &origin);
+    
+    vector<wayPoint>::iterator pos;
+    for( pos = wayPoints.begin() ; pos != wayPoints.end() ; ++pos)
+    {
+        if((*pos).latitude == origin.latitude && (*pos).longitude == origin.longitude)
+        {
+            return (*pos).isStopover;
+        }
+    }
+*/
+
+    return false;
+}
+
+bool __geometry_cb(location_coords_s* geometry, void* user_data)
+{
+    LOGD("%s - start", __func__);
+
+    RouteStep* stepValue = (RouteStep*)user_data;
+    if(stepValue == NULL)
+        return false;
+
+    LOGD("%s - geometry(%f, %f)", __func__, geometry->latitude, geometry->longitude);
+    stepValue->points.push_back(make_pair(geometry->latitude, geometry->longitude));
+    return true;
+}
+
+bool __step_cb(route_step_h step, void *user_data)
+{
+    LOGD("%s - start", __func__);
+
+    step_info* step_data = (step_info*)user_data;
+    if( step_data == NULL )
+        return false;
+
+    RouteStep* stepValue = new RouteStep();
+
+    location_coords_s coords;
+    route_step_get_origin(step, &coords);
+    stepValue->originLatitude = coords.latitude;
+    stepValue->orginLogitude = coords.longitude;
+    LOGD("%s - origin(%f, %f)", __func__, stepValue->originLatitude, stepValue->orginLogitude);
+
+    route_step_get_destination(step, &coords);
+    stepValue->destLatitude = coords.latitude;
+    stepValue->destLogitude = coords.longitude;        
+    LOGD("%s - destination(%f, %f)", __func__, stepValue->destLatitude, stepValue->destLogitude);
+
+    stepValue->totalDistance.unit = step_data->distanceUnit;
+    double distance = 0.0;
+    route_step_get_distance(step, &distance);
+    LOGD("%s - distance : %f", __func__, distance);
+    stepValue->totalDistance.value = distance;    
+
+    long duration = 0;
+    route_step_get_duration(step, &duration);
+    LOGD("%s - duration : %f", __func__, (double)duration);
+    stepValue->totalDuration.value = (double)duration;
+
+    char* mode = NULL;
+    if( route_step_get_transport_mode(step, &mode) == ROUTE_ERROR_NONE )
+    {
+        LOGD("%s - mode : %s", __func__, mode);    
+        stepValue->mode = string(mode);
+    }        
+    free(mode);    
+
+    char* instruct = NULL;
+    if( route_step_get_instruction(step, &instruct) == ROUTE_ERROR_NONE )
+    {
+        LOGD("%s - instruct : %s", __func__, instruct);    
+        stepValue->instruction = string(instruct);\
+    }
+    free(instruct);
+
+    LOGD("%s - before route_step_foreach_geometries", __func__);
+    route_step_foreach_geometries(step, __geometry_cb, stepValue);
+    LOGD("%s - after route_step_foreach_geometries", __func__);
+
+    step_data->steps.push_back(stepValue);
+    //delete stepValue;
+    
+    return true;
+    
+}
+
+bool __segment_cb(route_segment_h segment, void *user_data)
+{
+    LOGD("%s - start", __func__);
+
+    segment_info* segment_data = (segment_info*)user_data;
+    if( segment_data == NULL )
+        return false;
+
+    step_info* step_data = new step_info();
+    if( step_data == NULL ){
+        return false;
+    }
+    step_data->distanceUnit = segment_data->distanceUnit;
+    LOGD("%s - before route_segment_foreach_steps", __func__);
+    route_segment_foreach_steps(segment, __step_cb, step_data);
+    LOGD("%s - after route_segment_foreach_steps", __func__);
+
+    RouteSegment* segmentValue;
+    if( segment_data->segments.size() == 0 || __isStopOver(segment_data->segment_num, segment_data->wayPoints) == true )
+    {
+        LOGD("%s - stop over", __func__);
+        segmentValue = new RouteSegment();
+
+        location_coords_s coords;
+        route_segment_get_origin(segment, &coords);
+        segmentValue->originLatitude = coords.latitude;
+        segmentValue->orginLogitude = coords.longitude;
+        LOGD("%s - origin(%f, %f)", __func__, segmentValue->originLatitude, segmentValue->orginLogitude);
+        
+        route_segment_get_destination(segment, &coords);
+        segmentValue->destLatitude = coords.latitude;
+        segmentValue->destLogitude = coords.longitude;
+        LOGD("%s - destination(%f, %f)", __func__, segmentValue->destLatitude, segmentValue->destLogitude);
+
+        segmentValue->totalDistance.unit = segment_data->distanceUnit;
+        double distance = 0.0;
+        route_segment_get_distance(segment, &distance);
+        LOGD("%s - distance : %f", __func__, distance);
+        segmentValue->totalDistance.value = distance;
+
+        long duration = 0;
+        route_segment_get_duration(segment, &duration);
+        LOGD("%s - duration : %f", __func__, (double)duration);
+        segmentValue->totalDuration.value = (double)duration;
+
+        segmentValue->steps = step_data->steps;
+        segment_data->segments.push_back(segmentValue);
+        //delete segmentValue;
+    }
+    else
+    {
+        LOGD("%s - Not stop over", __func__);
+        segmentValue = segment_data->segments.back();
+        
+        location_coords_s coords;
+        route_segment_get_destination(segment, &coords);
+        segmentValue->destLatitude = coords.latitude;
+        segmentValue->destLogitude = coords.longitude;
+        LOGD("%s - origin(%f, %f)", __func__, segmentValue->originLatitude, segmentValue->orginLogitude);
+        LOGD("%s - destination(%f, %f)", __func__, segmentValue->destLatitude, segmentValue->destLogitude);
+    
+        double distance = 0.0;
+        route_segment_get_distance(segment, &distance);
+        LOGD("%s - original distance : %f", __func__, segmentValue->totalDistance.value);
+        segmentValue->totalDistance.value += distance;
+        LOGD("%s - distance : %f", __func__, segmentValue->totalDistance.value);
+
+        long duration = 0;
+        route_segment_get_duration(segment, &duration);
+        LOGD("%s - original duration : %f", __func__, segmentValue->totalDuration.value);
+        segmentValue->totalDuration.value += (double)duration;
+        LOGD("%s - duration : %f", __func__, segmentValue->totalDuration.value);
+
+        vector<RouteStep*>::iterator pos;
+        for( pos = step_data->steps.begin() ; pos != step_data->steps.end() ; ++pos)
+        {
+            LOGD("%s - step origin(%f, %f)", __func__, (*pos)->originLatitude, (*pos)->orginLogitude);
+            LOGD("%s - step destination(%f, %f)", __func__, (*pos)->destLatitude, (*pos)->destLogitude);
+            segmentValue->steps.push_back(*pos);
+        }
+        /*
+        segment_data->segments.pop_back();
+        segment_data->segments.push_back(segmentValue);
+        */
+    }
+
+    /*
+    LOGD("%s - delete each step_data", __func__);
+    std::vector<RouteStep*>::iterator pos;
+    for( pos = step_data->steps.begin() ; pos != step_data->steps.end() ; ++pos )
+        delete *pos;
+    */        
+
+    //delete step_data;
+    segment_data->segment_num++;
+    return true;
+}
+
+std::string __convert_distance_unit_to_string(route_distance_unit_e unit)
+{
+    switch(unit) {
+        case ROUTE_DISTANCE_UNIT_M :
+            return string("M");
+        case ROUTE_DISTANCE_UNIT_FT :
+            return string("FT");
+        case ROUTE_DISTANCE_UNIT_YD :
+            return string("YD");
+        case ROUTE_DISTANCE_UNIT_MI :
+            return string("MI");
+        case ROUTE_DISTANCE_UNIT_KM :
+        default :
+                return string("KM");        
+    }
+}
+
+bool __route_found_cb(route_error_e error, int index, int total , route_h route, void * user_data)
+{
+    LOGD("%s - start", __func__);
+
+    route_search_callback_data* calldata = (route_search_callback_data*)user_data;
+    if( calldata == NULL )
+        return false;
+
+    if( error != ROUTE_ERROR_NONE ){
+        int result = 0;
+        if( error == ROUTE_ERROR_RESULT_NOT_FOUND )
+            result = RouteProvider::RouteERROR::NOT_FOUND;
+        else if( error == ROUTE_ERROR_SERVICE_NOT_AVAILABLE )
+            result = RouteProvider::RouteERROR::SERVICE_NOT_AVAILABLE;
+        else if( error == ROUTE_ERROR_NETWORK_FAILED )
+            result = RouteProvider::RouteERROR::NETWORK_FAILED;
+        
+        calldata->callback( result, calldata->list,  calldata->user_data );
+        return false;
+    }
+
+    RouteResult* result = new RouteResult();
+    
+    location_coords_s coords;
+    route_get_origin(route, &coords);
+    result->summary.originLatitude = coords.latitude;
+    result->summary.orginLogitude = coords.longitude;
+    LOGD("%s - origin(%f, %f)", __func__, result->summary.originLatitude, result->summary.orginLogitude);
+
+    route_get_destination(route, &coords);
+    result->summary.destLatitude = coords.latitude;
+    result->summary.destLogitude = coords.longitude;
+    LOGD("%s - destination(%f, %f)", __func__, result->summary.destLatitude, result->summary.destLogitude);
+
+    route_distance_unit_e unit = ROUTE_DISTANCE_UNIT_KM;
+    route_get_distance_unit(route, &unit);
+    result->summary.totalDistance.unit = __convert_distance_unit_to_string(unit);
+
+    double distance = 0.0;
+    route_get_total_distance(route, &distance);
+    result->summary.totalDistance.value = distance;
+    LOGD("%s - distance : %f", __func__, result->summary.totalDistance.value);
+
+    long duration = 0;
+    route_get_total_duration(route, &duration);
+    result->summary.totalDuration.value = (double)duration;
+    LOGD("%s - duration : %f", __func__, result->summary.totalDuration.value);  
+
+    segment_info* segment_data = new segment_info();
+    if( segment_data == NULL ){
+        return false;
+    }
+    segment_data->wayPoints = calldata->option.wayPoints;
+    segment_data->distanceUnit = result->summary.totalDistance.unit;
+    segment_data->segment_num = 0;
+    LOGD("%s - before route_foreach_segments", __func__);    
+    route_foreach_segments(route, __segment_cb, segment_data); 
+    LOGD("%s - after route_foreach_segments", __func__);
+
+    result->segments = segment_data->segments;
+
+    /*
+    std::vector<RouteSegment*>::iterator pos;
+    for( pos = segment_data->segments.begin() ; pos != segment_data->segments.end() ; ++pos)
+        delete *pos;
+    
+    delete segment_data;
+    */
+
+    calldata->list.push_back(result);
+    //delete result;
+    if( total == index+1 ){
+        calldata->callback(0 , calldata->list,  calldata->user_data);
+        std::vector<RouteResult*>::iterator pos;
+        for( pos = calldata->list.begin() ; pos != calldata->list.end() ; ++pos)
+            delete *pos;
+        
+        delete calldata;
+    }   
+    return true;
+}
+
+location_preference_distance_unit_e __convert_distance_unit(const char* unit)
+{
+    switch(unit[0]) {
+        case 'F' :
+            return LOCATION_PREFERENCE_DISTANCE_UNIT_FT;
+        case 'K' :
+            return LOCATION_PREFERENCE_DISTANCE_UNIT_KM;
+        case 'Y' :
+            return LOCATION_PREFERENCE_DISTANCE_UNIT_YD;
+        case 'M' :
+            if(unit[1] == 'I')
+                return LOCATION_PREFERENCE_DISTANCE_UNIT_MI;
+            else
+                return LOCATION_PREFERENCE_DISTANCE_UNIT_M;
+        default :
+            return LOCATION_PREFERENCE_DISTANCE_UNIT_KM;
+    }
+}
+
+int DefaultRouteProvider::find(double originLati, double originLongi, double destLati, double destLongi, RouteRequestOptions& option ,  RouteArrayCallback callback, void* user_data, LBSPending **pending)
+{
+    LOGD("%s - find route", __func__);
+    int ret = 0;
+    int retval = 0;    
+    int reqid = 0;
+    int waypoint_size = 0;
+    int constarints_size = 0;
+    location_coords_s* waypoint = NULL;
+    route_preference_h preference = NULL;
+    route_search_callback_data* calldata = NULL;
+    location_coords_s origin = {originLati, originLongi};
+    location_coords_s destination = {destLati, destLongi};
+
+    if(route_service_get_preference(nativeHandle, &preference) != ROUTE_ERROR_NONE){
+        retval = RouteERROR::OUT_OF_MEMORY;
+        goto destroy;
+    }
+
+    if(!option.unit.empty()) {
+        LOGD("%s - distance unit: %s", __func__, option.unit.c_str());
+        location_preference_set_distance_unit(GET_LOCATION_SERVICE(nativeHandle), __convert_distance_unit(option.unit.c_str()));
+    }
+    else
+        location_preference_set_distance_unit(GET_LOCATION_SERVICE(nativeHandle), LOCATION_PREFERENCE_DISTANCE_UNIT_KM);    
+
+    if(!option.mode.empty())
+        route_preference_set_transport_mode(preference, option.mode.c_str());
+    else if(supportedModes.size() > 0)
+        route_preference_set_transport_mode(preference, supportedModes[0].c_str());
+
+    if(!option.goal.empty())
+        route_preference_set_goal(preference, option.goal.c_str());
+    else if(supportedGoals.size() > 0)
+        route_preference_set_transport_mode(preference, supportedGoals[0].c_str());       
+
+    if(option.maxResult != 0)
+        route_preference_set_max_results(preference, option.maxResult);
+
+    route_preference_clear_constraints(preference);
+    constarints_size = (int)option.constraints.size();
+    for(int i = 0; i < constarints_size; i++) {
+        route_preference_add_constraint(preference, option.constraints[i].c_str()); 
+    }
+
+    waypoint_size = (int)option.wayPoints.size();
+    LOGD("%s - waypoint size: %d", __func__, waypoint_size);    
+    if(waypoint_size > 0) {
+        waypoint = (location_coords_s*)malloc(waypoint_size*sizeof(location_coords_s));
+        if(waypoint == NULL) {
+            retval = RouteERROR::OUT_OF_MEMORY;
+            goto destroy;
+        }
+    }
+
+    for(int i = 0; i<waypoint_size; i++) {
+        LOGD("%s - waypoint[i]: (%f, %f)", __func__, i, option.wayPoints[i].latitude, option.wayPoints[i].longitude);
+        waypoint[i] = {option.wayPoints[i].latitude, option.wayPoints[i].longitude};
+    }
+
+    calldata = new route_search_callback_data();
+    if( calldata == NULL ){
+        retval = RouteERROR::OUT_OF_MEMORY;
+        goto destroy;
+    }
+
+    calldata->user_data = user_data;
+    calldata->callback = callback;
+    calldata->option = option;
+
+    LOGD("%s - route_service_find", __func__);
+    //route_service_set_preference(nativeHandle, preference);
+    ret = route_service_find(nativeHandle, origin, destination, waypoint, waypoint_size, __route_found_cb , calldata, &reqid);
+
+    if( ret == ROUTE_ERROR_NONE ){
+        //should not be deleted
+        calldata = NULL;
+        if(pending)
+            *pending = new LBSPending(__cancel_operation, reqid, this);
+    }
+    else if( ret == ROUTE_ERROR_OUT_OF_MEMORY || ret == ROUTE_ERROR_RESULT_NOT_FOUND)
+        retval = RouteERROR::OUT_OF_MEMORY;
+    else if( ret == ROUTE_ERROR_INVALID_PARAMETER )
+        retval = RouteERROR::INVALID_PARAMETER;
+    else if(ret == ROUTE_ERROR_SERVICE_NOT_AVAILABLE)
+        retval = RouteERROR::SERVICE_NOT_AVAILABLE;
+    else if( ret == ROUTE_ERROR_NETWORK_FAILED )
+        retval = RouteERROR::NETWORK_FAILED;
+
+destroy:    
+    //route_preference_destroy(preference);
+    if(calldata)
+        delete calldata;
+
+    if(waypoint)
+        free(waypoint);
+    
+    return retval;
+}
+
+bool DefaultRouteProvider::cancel(int reqid)
+{
+    return route_service_cancel(nativeHandle, reqid);
+}
+
+       
+} //LBS
+} //Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/Route/DefaultRouteProvider.h b/src/standards/Tizen/Route/DefaultRouteProvider.h
new file mode 100755 (executable)
index 0000000..80b440d
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_H_
+#define _WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <route_service.h>
+#include "RouteProvider.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class DefaultRouteProvider :public RouteProvider{
+    private:
+        route_service_h nativeHandle;
+        std::vector<std::pair<std::string, std::string>> metadata;
+        std::vector<std::string> supportedOptions;
+        std::vector<std::string> supportedGoals;
+        std::vector<std::string> supportedModes;
+        std::vector<std::string> supportedConstraints;
+
+        static bool preference_init_cb(const char *property, void *user_data);
+        static int setOption_cb(void* user_data);
+        static bool supportedGoal_cb(const char *goal, void *user_data);
+        static bool supportedMode_cb(const char *mode, void *user_data);
+        static bool supportedConstraint_cb(const char *constraint, void *user_data);
+        
+    public:    
+        DefaultRouteProvider();   
+        virtual ~DefaultRouteProvider();
+        virtual std::vector<std::pair<std::string, std::string>> getMetadata();
+        virtual std::vector<std::string> getSupportedOptions();
+        virtual std::string getConnectivity();
+        virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending);
+        virtual bool isUsedExternalNetwork();
+
+        virtual std::vector<std::string> getSupportedGoals();
+        virtual std::vector<std::string> getSupportedModes();
+        virtual std::vector<std::string> getSupportedConstraints();
+        virtual bool supportswayPoints();
+
+        virtual int find(double originLati, double originLongi, double destLati, double destLongi, RouteRequestOptions& option ,  RouteArrayCallback callback, void* user_data, LBSPending **pending);
+        virtual bool cancel(int request);
+    
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_DEFAULTPOIPROVIDER_H_
+
+
diff --git a/src/standards/Tizen/Route/JSRouteDistance.cpp b/src/standards/Tizen/Route/JSRouteDistance.cpp
new file mode 100755 (executable)
index 0000000..af9f3a3
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteDistance.h"
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+ using namespace std;
+ using namespace WrtDeviceApis::CommonsJavaScript;
+ namespace TizenApis {
+ namespace Tizen1_0 {
+ namespace LBS {
+ JSClassRef JSRouteDistance::m_jsClassRef = NULL;
+ JSClassDefinition JSRouteDistance::m_jsClassInfo = {
+     0,  // current (and only) version is 0
+     kJSClassAttributeNone,  //attributes
+     "RouteResult",  // class name
+     NULL,  // parent class
+     NULL,  // static values
+     NULL,  // static functions
+     JSRouteDistance::initialize,  // initialize
+     JSRouteDistance::finalize,  // finalize
+     NULL,  // hasProperty
+     NULL,  // getProperty
+     NULL,  // setProperty
+     NULL,  // deleteProperty
+     NULL,  // getPropertyNames
+     NULL,  // callAsFunction
+     NULL,  // callAsConstructor
+     JSRouteDistance::hasInstance,  // hasInstance
+     NULL  // convertToType
+ };
+ const JSClassRef JSRouteDistance::getClassRef() 
+ {
+     if (!m_jsClassRef) {
+         m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+     }
+     return m_jsClassRef;
+ }
+ const JSClassDefinition* JSRouteDistance::getClassInfo() 
+ {
+     return &m_jsClassInfo;
+ }
+ void JSRouteDistance::initialize(JSContextRef ctx, JSObjectRef object) 
+ {
+ }
+ void JSRouteDistance::finalize(JSObjectRef object) 
+ {
+ }
+ bool JSRouteDistance::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+ }
+ } //LBS
+ } // Tizen1_0
+ } // TizenApis
diff --git a/src/standards/Tizen/Route/JSRouteDistance.h b/src/standards/Tizen/Route/JSRouteDistance.h
new file mode 100755 (executable)
index 0000000..0460a2d
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTEDISTANCE_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTEDISTANCE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteDistance {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+private:
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTEDISTANCE_H_
diff --git a/src/standards/Tizen/Route/JSRouteDuration.cpp b/src/standards/Tizen/Route/JSRouteDuration.cpp
new file mode 100755 (executable)
index 0000000..75af1a0
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteDuration.h"
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+ using namespace std;
+ using namespace WrtDeviceApis::CommonsJavaScript;
+ namespace TizenApis {
+ namespace Tizen1_0 {
+ namespace LBS {
+ JSClassRef JSRouteDuration::m_jsClassRef = NULL;
+ JSClassDefinition JSRouteDuration::m_jsClassInfo = {
+     0,  // current (and only) version is 0
+     kJSClassAttributeNone,  //attributes
+     "RouteResult",  // class name
+     NULL,  // parent class
+     NULL,  // static values
+     NULL,  // static functions
+     JSRouteDuration::initialize,  // initialize
+     JSRouteDuration::finalize,  // finalize
+     NULL,  // hasProperty
+     NULL,  // getProperty
+     NULL,  // setProperty
+     NULL,  // deleteProperty
+     NULL,  // getPropertyNames
+     NULL,  // callAsFunction
+     NULL,  // callAsConstructor
+     JSRouteDuration::hasInstance,  // hasInstance
+     NULL  // convertToType
+ };
+ const JSClassRef JSRouteDuration::getClassRef() 
+ {
+     if (!m_jsClassRef) {
+         m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+     }
+     return m_jsClassRef;
+ }
+ const JSClassDefinition* JSRouteDuration::getClassInfo() 
+ {
+     return &m_jsClassInfo;
+ }
+ void JSRouteDuration::initialize(JSContextRef ctx, JSObjectRef object) 
+ {
+ }
+ void JSRouteDuration::finalize(JSObjectRef object) 
+ {
+ }
+ bool JSRouteDuration::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+ }
+ } //LBS
+ } // Tizen1_0
+ } // TizenApis
+
+
diff --git a/src/standards/Tizen/Route/JSRouteDuration.h b/src/standards/Tizen/Route/JSRouteDuration.h
new file mode 100755 (executable)
index 0000000..0d9d0fa
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTEDURATION_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTEDURATION_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteDuration {
+    public:
+        static const JSClassDefinition* getClassInfo();
+        static const JSClassRef getClassRef();
+        
+    protected:
+        static void initialize(JSContextRef context, JSObjectRef object);
+        static void finalize(JSObjectRef object);
+        static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    
+    private:
+        static JSClassDefinition m_jsClassInfo;
+        static JSClassRef m_jsClassRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTEDURATION_H_
diff --git a/src/standards/Tizen/Route/JSRouteProvider.cpp b/src/standards/Tizen/Route/JSRouteProvider.cpp
new file mode 100755 (executable)
index 0000000..8ca02d7
--- /dev/null
@@ -0,0 +1,330 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSRouteProvider.h"
+#include "JSLocationServiceProvider.h"
+#include "RouteProvider.h"
+#include <vector>
+#include "RouteResult.h"
+#include "LBSUtil.h"
+#include "RouteRequestOptions.h"
+#include "JSRouteResult.h"
+#include "RouteAce.h"
+#include "JSLBSPending.h"
+#include "LBSPending.h"
+#include "JSLBS.h"
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+struct CallbackData {
+    JSObjectRef onSuccess;
+    JSObjectRef onFail;
+};
+
+JSContextRef JSRouteProvider::m_globalContextRef = NULL;
+JSClassRef JSRouteProvider::m_jsClassRef = NULL;
+JSClassDefinition JSRouteProvider::m_jsClassInfo = {
+    0,                                                  // current (and only) version is 0
+    kJSClassAttributeNone,              //attributes
+    "RouteProvider",                                // class name
+    JSLocationServiceProvider::getClassRef(),// parent class
+    NULL,                                           // static values
+    JSRouteProvider::m_function,                                    // static functions
+    JSRouteProvider::initialize,                                    // initialize
+    JSRouteProvider::finalize,
+    NULL, //hasProperty
+    JSRouteProvider::getProperty, //getProperty
+    NULL, //setProperty
+    NULL, //deleteProperty
+    NULL, //getPropertyNames
+    NULL,
+    NULL, // constructor
+    JSRouteProvider::hasInstance,
+    NULL
+};
+
+
+JSStaticFunction JSRouteProvider::m_function[] = {
+    { "find",JSRouteProvider::find,kJSPropertyAttributeNone },  
+    { 0, 0, 0 }
+};
+
+const JSClassRef JSRouteProvider::getClassRef() 
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSRouteProvider::getClassInfo() 
+{
+    return &m_jsClassInfo;
+}
+
+void JSRouteProvider::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+    if( JSRouteProvider::m_globalContextRef == NULL ){
+        JSRouteProvider::m_globalContextRef = ctx;
+    }
+
+}
+
+void JSRouteProvider::finalize(JSObjectRef object) 
+{
+    RouteProvider * priv = reinterpret_cast<RouteProvider*>(JSObjectGetPrivate(object));
+    if( priv ){
+        delete priv;
+        JSObjectSetPrivate(object, NULL);
+    }
+}
+
+bool JSRouteProvider::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSRouteProvider::getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception){
+    RouteProvider * priv = reinterpret_cast<RouteProvider*>(JSObjectGetPrivate(object));
+    if( priv == NULL)
+        return NULL;
+    int supportedType = 0;
+
+    if( (JSStringIsEqualToUTF8CString(propertyName, "supportedGoals") && ( supportedType = 1) ) 
+            || (JSStringIsEqualToUTF8CString(propertyName, "supportedModes") && ( supportedType = 2) ) 
+            || (JSStringIsEqualToUTF8CString(propertyName, "supportedConstraints") && ( supportedType = 3) ) 
+        ) {
+
+        vector<string> supportedVector;
+        if( supportedType == 1 )
+            supportedVector = priv->getSupportedGoals();
+        else if( supportedType == 2 )
+            supportedVector = priv->getSupportedModes();
+        else if( supportedType == 3 )
+            supportedVector = priv->getSupportedConstraints();
+        
+        JSValueRef* supportedValues = NULL;
+        supportedValues = new JSValueRef[supportedVector.size()];
+        for( unsigned int i=0 ; i < supportedVector.size(); i++){
+            JSStringRef valueString =  JSStringCreateWithUTF8CString( supportedVector[i].c_str());
+            supportedValues[i] = JSValueMakeString(ctx, valueString);
+            JSStringRelease(valueString);
+        }
+        JSObjectRef supportedArray = JSObjectMakeArray(ctx, supportedVector.size(), supportedValues, NULL);
+        delete [] supportedValues;
+        return supportedArray;
+    }
+    else if(JSStringIsEqualToUTF8CString(propertyName, "supportsWayPoints") ) {
+        bool supportsWayPoints = priv->supportswayPoints();
+        return JSValueMakeBoolean(ctx, supportsWayPoints);
+    }
+    
+    return NULL;
+}
+
+void __findCallback( int result,  std::vector<RouteResult*> RouteArray,  void * user_data ){
+    CallbackData * userdata =  static_cast<CallbackData *>(user_data);
+    if ( userdata == NULL)
+        return;
+
+    if( result == RouteProvider::RouteERROR::NONE ) {
+        JSValueRef* RouteValues = NULL;
+        RouteValues = new JSValueRef[RouteArray.size()];
+        for( unsigned int i=0 ; i < RouteArray.size(); i++){
+            RouteValues[i] = RouteArray[i]->toJSObject(JSLBS::getGlobalContext());
+            JSValueProtect(JSLBS::getGlobalContext(), RouteValues[i]);
+        }
+        JSObjectRef JSRouteArray = JSObjectMakeArray(JSLBS::getGlobalContext(), RouteArray.size(), RouteValues, NULL);
+        delete [] RouteValues;
+        JSValueRef args[1] = {JSRouteArray};        
+        JSObjectCallAsFunction(JSLBS::getGlobalContext(), userdata->onSuccess , NULL, 1, args, NULL);
+    }else if(  result == RouteProvider::RouteERROR::NOT_FOUND ) {
+        JSValueRef nullValue = JSObjectMakeArray(JSLBS::getGlobalContext() , 0, NULL, NULL);
+        JSValueRef args[1] = {nullValue};
+        JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onSuccess , NULL, 1, args, NULL);
+    }else if(userdata->onFail){
+        string errorCode;
+        switch(result){
+            case RouteProvider::RouteERROR::OUT_OF_MEMORY :
+            case RouteProvider::RouteERROR::INVALID_PARAMETER :
+                errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                break;
+            case RouteProvider::RouteERROR::SERVICE_NOT_AVAILABLE :
+                errorCode = Commons::JSTizenException::SERVICE_NOT_AVAILABLE;
+                break;
+            case RouteProvider::RouteERROR::NETWORK_FAILED :
+                errorCode = Commons::JSTizenException::NETWORK_ERROR;
+                break;
+        }
+        
+        JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , "Fail to search");
+        JSValueRef args[1] = {error};   
+        JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+    }
+
+    if( userdata->onSuccess )
+        JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onSuccess);
+    if( userdata->onFail )
+        JSValueUnprotect(JSLBS::getGlobalContext(), userdata->onFail);
+
+    delete userdata;
+}
+
+JSValueRef JSRouteProvider::find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception){
+    LOGD("%s -start", __func__);
+
+    // Check the Object type
+    RouteProvider * priv = reinterpret_cast<RouteProvider*>(JSObjectGetPrivate(thisObject));
+    if( priv == NULL)
+        return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Wrong object");
+    
+    // Check the access control
+    AceSecurityStatus status = ROUTE_CHECK_ACCESS(ROUTE_FUNCTION_CATEGORY_BASIC);
+    if( status != AceSecurityStatus::AccessGranted )
+        return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+    int ret = -1;
+    LBSPending *pending = NULL;
+    Converter convert(context); 
+    RouteRequestOptions options;
+
+    JSValueRef convertedArguments[5];
+    JSObjectRef convertedArgumentObjects[5];
+    for( unsigned int i = 0 ; i < 5; i++ ){
+        if( i < argumentCount ) {
+            convertedArguments[i] = arguments[i];
+            if( JSValueIsObject(context, arguments[i]) )
+                convertedArgumentObjects[i] = JSValueToObject(context, arguments[i], NULL );
+            else
+                convertedArgumentObjects[i] = NULL;    
+        } else {
+            convertedArguments[i] = JSValueMakeUndefined(context);
+            convertedArgumentObjects[i] = NULL;
+        }
+    }
+
+    //Check the first argument
+    if(JSValueIsNull(context, convertedArguments[0]) || JSValueIsUndefined(context, convertedArguments[0]) || !JSValueIsObject(context, convertedArguments[0]))
+    {
+        return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The first argument is invalid (null or undefined or not object)");
+    }
+
+    //Check the second argument
+    if(JSValueIsNull(context, convertedArguments[1]) || JSValueIsUndefined(context, convertedArguments[1]) || !JSValueIsObject(context, convertedArguments[1]))
+    {
+        return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The second argument is invalid (null or undefined or not object)");
+    }    
+
+    //Check the 3rd argument is function object
+    if( convertedArgumentObjects[2] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[2]) )
+        return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The third argument must be function");
+
+    //Check the 4th argument is NULL or Undefine or function object
+    if(  !JSValueIsNull(context, convertedArguments[3]) && !JSValueIsUndefined(context, convertedArguments[3])  &&  
+        ( convertedArgumentObjects[3] == NULL || !JSObjectIsFunction(context, convertedArgumentObjects[3]) ) )
+        return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The forth argument must be function or null");
+
+    // The 5th argument is options
+    if(  !JSValueIsNull(context, convertedArguments[4]) &&  !JSValueIsUndefined(context, convertedArguments[4])){
+        JSObjectRef jsOptions = convertedArgumentObjects[4]; 
+        if( jsOptions == NULL )
+            return Commons::JSTizenExceptionFactory::postException(context,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "options is not dictionary");
+        else if( !RouteRequestOptions::convert(context, jsOptions, &options, exception) )
+            return JSValueMakeUndefined(context);
+    }   
+
+    CallbackData * userdata =  new CallbackData();
+    userdata->onFail = NULL;    
+    userdata->onSuccess = NULL;
+
+    // Gets the value of the first argument
+    double originLati = LBSUtil::getPropertyToDouble(context, convertedArgumentObjects[0], "latitude");
+    double originLongi = LBSUtil::getPropertyToDouble(context, convertedArgumentObjects[0], "longitude");
+
+    // Gets the value of the second argument
+    double destLati = LBSUtil::getPropertyToDouble(context, convertedArgumentObjects[1], "latitude");
+    double destLongi = LBSUtil::getPropertyToDouble(context, convertedArgumentObjects[1], "longitude");
+
+    // The 3rd argument is successCallback
+    userdata->onSuccess = convertedArgumentObjects[2];
+    JSValueProtect(context, convertedArguments[2]);
+
+    // The 4th argument is errorCallback
+    JSObjectRef onfail = convertedArgumentObjects[3];
+    if( onfail != NULL && JSObjectIsFunction(context, onfail)  ){
+        userdata->onFail = onfail;
+        JSValueProtect(context, convertedArguments[3]);
+    }
+
+    ret = priv->find(originLati, originLongi, destLati, destLongi, options, __findCallback, userdata, &pending);
+    
+    // Error, Should delete callback data
+    if (ret != 0 ){ 
+        JSValueUnprotect(context, userdata->onSuccess);
+        if( userdata->onFail )
+            JSValueUnprotect(context, userdata->onFail);
+
+        string errorCode;
+        switch(ret){
+            case RouteProvider::RouteERROR::OUT_OF_MEMORY :
+            case RouteProvider::RouteERROR::INVALID_PARAMETER :
+                errorCode = Commons::JSTizenException::INVALID_VALUES_ERROR;
+                break;
+            case RouteProvider::RouteERROR::SERVICE_NOT_AVAILABLE :
+                errorCode = Commons::JSTizenException::SERVICE_NOT_AVAILABLE;
+                break;
+            case RouteProvider::RouteERROR::NOT_FOUND :
+                errorCode = Commons::JSTizenException::NOT_FOUND_ERROR;
+                break;    
+            case RouteProvider::RouteERROR::NETWORK_FAILED :
+                errorCode = Commons::JSTizenException::NETWORK_ERROR;
+                break;
+        }
+
+        if( userdata->onFail ) {
+            JSObjectRef error = Commons::JSTizenExceptionFactory::makeErrorObject(JSLBS::getGlobalContext(), errorCode , errorCode);
+            JSValueRef args[1] = {error};
+            JSObjectCallAsFunction(JSLBS::getGlobalContext() , userdata->onFail , NULL, 1, args, NULL);
+        }
+        delete userdata;
+    }
+
+    if( pending )
+        delete pending;
+    return JSValueMakeUndefined(context);
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
old mode 100644 (file)
new mode 100755 (executable)
similarity index 50%
rename from src/standards/Tizen/Sensors/JSSensorError.h
rename to src/standards/Tizen/Route/JSRouteProvider.h
index 7e2b34b..42e90b9
  */
 
  
-/**
-* @file                 JSSensorError.h
-* @author       Pius Lee (pius.lee@samsung.com)
-* @version      0.1
-*/
-
-#ifndef _WRTPLUGINS_TIZEN_JS_SENSOR_
-#define _WRTPLUGINS_TIZEN_JS_SENSOR_
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTEPROVIDER_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTEPROVIDER_H_
 
 #include <JavaScriptCore/JavaScript.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
+namespace LBS{
 
-class JSSensorError {
+class JSRouteProvider {
 public:
-    static const int PERMISSION_DENIED = -100;
-    static const int CONNECT_ERROR = -200;
-    static const int WATCH_ERROR = -300;
-    static const int END_WATCH_ERROR = -300;
-    static const int UNKNOWN_ERROR = -1000;
-
     static const JSClassDefinition* getClassInfo();
     static const JSClassRef getClassRef();
     
-    static JSObjectRef makeSensorError(JSContextRef ctx, const char* message, unsigned short code);
-
 protected:
-    static void initialize(JSContextRef ctx, JSObjectRef object);
+    static void initialize(JSContextRef context, JSObjectRef object);
     static void finalize(JSObjectRef object);
-    static bool hasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
-
-    // properties get / set
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
     static JSValueRef getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
-    static bool setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
-
-    // get static properties function
-    static JSValueRef getStaticProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception);
+    static JSValueRef find(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
 private:
     static JSClassDefinition m_jsClassInfo;
     static JSClassRef m_jsClassRef;
-    static JSStaticValue m_jsStaticProperties[];
+    static JSStaticFunction m_function[];
+    static JSContextRef m_globalContextRef;
 };
 
+} // LBS
 } // Tizen1_0
 } // TizenApis
 
-#endif
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTEPROVIDER_H_
\ No newline at end of file
diff --git a/src/standards/Tizen/Route/JSRouteResult.cpp b/src/standards/Tizen/Route/JSRouteResult.cpp
new file mode 100755 (executable)
index 0000000..b6b4490
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteResult.h"
+#include "LBSUtil.h"
+#include <dlog.h>
+#include <vector>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSClassRef JSRouteResult::m_jsClassRef = NULL;
+
+JSClassDefinition JSRouteResult::m_jsClassInfo = {
+    0,  // current (and only) version is 0
+    kJSClassAttributeNone,  //attributes
+    "RouteResult",  // class name
+    NULL,  // parent class
+    NULL,  // static values
+    JSRouteResult::m_function,  // static functions
+    JSRouteResult::initialize,  // initialize
+    JSRouteResult::finalize,  // finalize
+    NULL,  // hasProperty
+    NULL,  // getProperty
+    NULL,  // setProperty
+    NULL,  // deleteProperty
+    NULL,  // getPropertyNames
+    NULL,  // callAsFunction
+    NULL,  // callAsConstructor
+    JSRouteResult::hasInstance,  // hasInstance
+    NULL  // convertToType
+};
+
+JSStaticFunction JSRouteResult::m_function[] = {
+        { "toGeoJSON", JSRouteResult::toGeoJSON, kJSPropertyAttributeNone },    
+        { 0, 0, 0 }
+};
+
+const JSClassRef JSRouteResult::getClassRef() 
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSRouteResult::getClassInfo() 
+{
+    return &m_jsClassInfo;
+}
+
+void JSRouteResult::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+
+}
+
+void JSRouteResult::finalize(JSObjectRef object) 
+{
+
+}
+
+bool JSRouteResult::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSRouteResult::toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    vector<pair<double, double>> geometry;
+    string geojson = "{\"type\": \"LineString\", \"coordinates\": [ ";
+    Converter convert(context);
+
+    JSObjectRef segments = JSValueToObject(context, LBSUtil::getPropertyToValueRef(context, thisObject, "segments"), NULL);
+    int segCount = JSGetArrayLength(context, segments);
+    for( int i =0 ; i<segCount ; i++){
+        JSObjectRef segObj = JSValueToObject(context, JSGetArrayElement(context, segments, i), NULL);
+        JSObjectRef stepsObj = JSValueToObject(context, LBSUtil::getPropertyToValueRef(context, segObj, "steps"), NULL); 
+        int stepsCount = JSGetArrayLength(context, stepsObj);
+        for( int j =0 ; j<stepsCount ; j++){
+            JSObjectRef stepObj = JSValueToObject(context, JSGetArrayElement(context, stepsObj, j), NULL);    
+            JSObjectRef pointsObj = JSValueToObject(context, LBSUtil::getPropertyToValueRef(context, stepObj, "points"), NULL);       
+            int pointsCount = JSGetArrayLength(context, pointsObj);
+            for( int k =0 ; k<pointsCount ; k++){
+                JSObjectRef pointObj = JSValueToObject(context, JSGetArrayElement(context, pointsObj, k), NULL);
+                double latitude = LBSUtil::getPropertyToDouble(context, pointObj, "latitude");
+                double longitude = LBSUtil::getPropertyToDouble(context, pointObj, "longitude");
+                geometry.push_back(make_pair(latitude, longitude));
+            }            
+        }
+    }
+
+    vector<pair<double, double>>::iterator pos;
+    pos = geometry.begin();
+    geojson.append("[%g, %g]", (*pos).first, (*pos).second);
+    ++pos;
+    for( ; pos != geometry.end() ; ++pos)
+    {
+        geojson.append(", [%g, %g]", (*pos).first, (*pos).second);
+    }
+    geojson.append(" ]}");
+
+    return convert.toJSValueRef(geojson);
+}
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Route/JSRouteResult.h b/src/standards/Tizen/Route/JSRouteResult.h
new file mode 100755 (executable)
index 0000000..28e0862
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTERESULT_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTERESULT_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteResult{
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+       
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSValueRef toGeoJSON(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+               
+private:
+       static JSClassDefinition m_jsClassInfo;
+       static JSClassRef m_jsClassRef;
+       static JSStaticFunction m_function[];
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTERESULT_H_
diff --git a/src/standards/Tizen/Route/JSRouteResultSummary.cpp b/src/standards/Tizen/Route/JSRouteResultSummary.cpp
new file mode 100755 (executable)
index 0000000..10c401f
--- /dev/null
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteResultSummary.h"
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+
+JSClassRef JSRouteResultSummary::m_jsClassRef = NULL;
+
+JSClassDefinition JSRouteResultSummary::m_jsClassInfo = {
+    0,  // current (and only) version is 0
+    kJSClassAttributeNone,  //attributes
+    "RouteResult",  // class name
+    NULL,  // parent class
+    NULL,  // static values
+    NULL,  // static functions
+    JSRouteResultSummary::initialize,  // initialize
+    JSRouteResultSummary::finalize,  // finalize
+    NULL,  // hasProperty
+    NULL,  // getProperty
+    NULL,  // setProperty
+    NULL,  // deleteProperty
+    NULL,  // getPropertyNames
+    NULL,  // callAsFunction
+    NULL,  // callAsConstructor
+    JSRouteResultSummary::hasInstance,  // hasInstance
+    NULL  // convertToType
+};
+
+const JSClassRef JSRouteResultSummary::getClassRef() 
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSRouteResultSummary::getClassInfo() 
+{
+    return &m_jsClassInfo;
+}
+
+void JSRouteResultSummary::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+
+}
+
+void JSRouteResultSummary::finalize(JSObjectRef object) 
+{
+
+}
+
+bool JSRouteResultSummary::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Route/JSRouteResultSummary.h b/src/standards/Tizen/Route/JSRouteResultSummary.h
new file mode 100755 (executable)
index 0000000..e48ee30
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTERESULTSUMMARY_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTERESULTSUMMARY_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteResultSummary {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+
+private:
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTERESULTSUMMARY_H_
diff --git a/src/standards/Tizen/Route/JSRouteSegment.cpp b/src/standards/Tizen/Route/JSRouteSegment.cpp
new file mode 100755 (executable)
index 0000000..6e73617
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteSegment.h"
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+ using namespace std;
+ using namespace WrtDeviceApis::CommonsJavaScript;
+ namespace TizenApis {
+ namespace Tizen1_0 {
+ namespace LBS {
+ JSClassRef JSRouteSegment::m_jsClassRef = NULL;
+ JSClassDefinition JSRouteSegment::m_jsClassInfo = {
+     0,  // current (and only) version is 0
+     kJSClassAttributeNone,  //attributes
+     "RouteResult",  // class name
+     NULL,  // parent class
+     NULL,  // static values
+     NULL,  // static functions
+     JSRouteSegment::initialize,  // initialize
+     JSRouteSegment::finalize,  // finalize
+     NULL,  // hasProperty
+     NULL,  // getProperty
+     NULL,  // setProperty
+     NULL,  // deleteProperty
+     NULL,  // getPropertyNames
+     NULL,  // callAsFunction
+     NULL,  // callAsConstructor
+     JSRouteSegment::hasInstance,  // hasInstance
+     NULL  // convertToType
+ };
+ const JSClassRef JSRouteSegment::getClassRef() 
+ {
+     if (!m_jsClassRef) {
+         m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+     }
+     return m_jsClassRef;
+ }
+ const JSClassDefinition* JSRouteSegment::getClassInfo() 
+ {
+     return &m_jsClassInfo;
+ }
+ void JSRouteSegment::initialize(JSContextRef ctx, JSObjectRef object) 
+ {
+ }
+ void JSRouteSegment::finalize(JSObjectRef object) 
+ {
+ }
+ bool JSRouteSegment::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+ }
+ } //LBS
+ } // Tizen1_0
+ } // TizenApis
diff --git a/src/standards/Tizen/Route/JSRouteSegment.h b/src/standards/Tizen/Route/JSRouteSegment.h
new file mode 100755 (executable)
index 0000000..3b427f5
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTESEGMENT_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTESEGMENT_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteSegment {
+    public:
+        static const JSClassDefinition* getClassInfo();
+        static const JSClassRef getClassRef();
+        
+    protected:
+        static void initialize(JSContextRef context, JSObjectRef object);
+        static void finalize(JSObjectRef object);
+        static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    
+    private:
+        static JSClassDefinition m_jsClassInfo;
+        static JSClassRef m_jsClassRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTESEGMENT_H_
diff --git a/src/standards/Tizen/Route/JSRouteServiceManager.cpp b/src/standards/Tizen/Route/JSRouteServiceManager.cpp
new file mode 100755 (executable)
index 0000000..bad71c4
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSRouteServiceManager.h"
+#include "JSRouteProvider.h"
+#include "RouteAce.h"
+#include "DefaultRouteProvider.h"
+#include "RouteProvider.h"
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+JSContextRef JSRouteServiceManager::m_globalContextRef = NULL;
+
+JSValueRef JSRouteServiceManager::m_defaultObj = NULL;
+
+JSClassRef JSRouteServiceManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSRouteServiceManager::m_jsClassInfo = {
+    0,  // current (and only) version is 0
+    kJSClassAttributeNone,  //attributes
+    "Route",  // class name
+    NULL,  // parent class
+    NULL,  // static values  
+    JSRouteServiceManager::m_function,  // static functions
+    JSRouteServiceManager::initialize,  // initialize
+    JSRouteServiceManager::finalize,  // finalize
+    NULL,  // hasProperty
+    NULL,  // getProperty
+    NULL,  // setProperty
+    NULL,  // deleteProperty
+    NULL,  // getPropertyNames
+    NULL,  // callAsFunction
+    NULL,  // callAsConstructor
+    JSRouteServiceManager::hasInstance,  // hasInstance
+    NULL  // convertToType
+};
+
+JSStaticFunction JSRouteServiceManager::m_function[] = {
+    { "getDefaultProvider", JSRouteServiceManager::getDefaultProvider, kJSPropertyAttributeNone },
+    { "getProviders", JSRouteServiceManager::getProviders, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+const JSClassRef JSRouteServiceManager::getClassRef() 
+{
+    if (!m_jsClassRef)
+    {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSRouteServiceManager::getClassInfo() 
+{
+    return &m_jsClassInfo;
+}
+
+void JSRouteServiceManager::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+    if( JSRouteServiceManager::m_globalContextRef == NULL )
+    {
+        JSRouteServiceManager::m_globalContextRef = ctx;
+    }
+}
+
+void JSRouteServiceManager::finalize(JSObjectRef object) 
+{
+    if( JSRouteServiceManager::m_defaultObj != NULL ){
+        JSValueUnprotect(JSRouteServiceManager::m_globalContextRef, JSRouteServiceManager::m_defaultObj);
+        JSRouteServiceManager::m_defaultObj = NULL;
+    }
+}
+
+bool JSRouteServiceManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) 
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSRouteServiceManager::getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AceSecurityStatus status = ROUTE_CHECK_ACCESS(ROUTE_FUNCTION_CATEGORY_BASIC);
+    
+    if( status != AceSecurityStatus::AccessGranted )
+        return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+
+    
+    if( JSRouteServiceManager::m_defaultObj == NULL){
+        RouteProvider *route = new DefaultRouteProvider();        
+        JSRouteServiceManager::m_defaultObj  = JSObjectMake(context , JSRouteProvider::getClassRef() , route);
+        JSValueProtect(context, JSRouteServiceManager::m_defaultObj);
+    }
+    return JSRouteServiceManager::m_defaultObj;
+}
+
+JSValueRef JSRouteServiceManager::getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    AceSecurityStatus status = ROUTE_CHECK_ACCESS(ROUTE_FUNCTION_CATEGORY_BASIC);
+    
+    if( status != AceSecurityStatus::AccessGranted )
+        return Commons::JSTizenExceptionFactory::postException(context,exception, Commons::JSTizenException::PERMISSION_DENIED_ERROR );
+    
+    JSValueRef providers[1];
+    JSObjectRef array;
+    providers[0] = getDefaultProvider(context ,object, thisObject, argumentCount, arguments, exception);
+    array = JSObjectMakeArray(context, 1, providers, NULL);
+    return array;   
+}
+
+
+} //LBS
+} // Tizen1_0
+} // TizenApis
+
diff --git a/src/standards/Tizen/Route/JSRouteServiceManager.h b/src/standards/Tizen/Route/JSRouteServiceManager.h
new file mode 100755 (executable)
index 0000000..297dd18
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTESERVICEMANAGER_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTESERVICEMANAGER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteServiceManager {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    static JSValueRef m_defaultObj;
+
+protected:
+    static void initialize(JSContextRef context, JSObjectRef object);
+    static void finalize(JSObjectRef object);
+    static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    static JSValueRef getDefaultProvider(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    static JSValueRef getProviders(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+private:
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+    static JSStaticFunction m_function[];
+    static JSContextRef m_globalContextRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTESERVICEMANAGER_H_
+
diff --git a/src/standards/Tizen/Route/JSRouteStep.cpp b/src/standards/Tizen/Route/JSRouteStep.cpp
new file mode 100755 (executable)
index 0000000..6bc91a5
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSRouteStep.h"
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+ using namespace std;
+ using namespace WrtDeviceApis::CommonsJavaScript;
+ namespace TizenApis {
+ namespace Tizen1_0 {
+ namespace LBS {
+ JSClassRef JSRouteStep::m_jsClassRef = NULL;
+ JSClassDefinition JSRouteStep::m_jsClassInfo = {
+     0,  // current (and only) version is 0
+     kJSClassAttributeNone,  //attributes
+     "RouteResult",  // class name
+     NULL,  // parent class
+     NULL,  // static values
+     NULL,  // static functions
+     JSRouteStep::initialize,  // initialize
+     JSRouteStep::finalize,  // finalize
+     NULL,  // hasProperty
+     NULL,  // getProperty
+     NULL,  // setProperty
+     NULL,  // deleteProperty
+     NULL,  // getPropertyNames
+     NULL,  // callAsFunction
+     NULL,  // callAsConstructor
+     JSRouteStep::hasInstance,  // hasInstance
+     NULL  // convertToType
+ };
+ const JSClassRef JSRouteStep::getClassRef() 
+ {
+     if (!m_jsClassRef) {
+         m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+     }
+     return m_jsClassRef;
+ }
+ const JSClassDefinition* JSRouteStep::getClassInfo() 
+ {
+     return &m_jsClassInfo;
+ }
+ void JSRouteStep::initialize(JSContextRef ctx, JSObjectRef object) 
+ {
+ }
+ void JSRouteStep::finalize(JSObjectRef object) 
+ {
+ }
+ bool JSRouteStep::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+     return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+ }
+ } //LBS
+ } // Tizen1_0
+ } // TizenApis
diff --git a/src/standards/Tizen/Route/JSRouteStep.h b/src/standards/Tizen/Route/JSRouteStep.h
new file mode 100755 (executable)
index 0000000..86037d7
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTESTEP_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTESTEP_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class JSRouteStep {
+    public:
+        static const JSClassDefinition* getClassInfo();
+        static const JSClassRef getClassRef();
+        
+    protected:
+        static void initialize(JSContextRef context, JSObjectRef object);
+        static void finalize(JSObjectRef object);
+        static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
+    
+    private:
+        static JSClassDefinition m_jsClassInfo;
+        static JSClassRef m_jsClassRef;
+};
+
+} // LBS
+} // Tizen1_0
+} // TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_JS_ROUTESTEP_H_
diff --git a/src/standards/Tizen/Route/RouteAce.cpp b/src/standards/Tizen/Route/RouteAce.cpp
new file mode 100755 (executable)
index 0000000..6d6322b
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <Commons/FunctionDefinition.h>
+#include <Commons/FunctionDeclaration.h>
+#include <iostream>
+#include <vector>
+#include "RouteAce.h"
+
+#define FEATURE_ROUTE "http://tizen.org/api/lbs.route"
+#define DEVICE_CAPABILITY_EXT_NET "externalNetworkAccess"
+
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+static AceFunction __route_function();
+static AceFunction route_function = __route_function(); 
+
+static AceFunction __route_function()
+{
+       AceFeature route_function(FEATURE_ROUTE);
+       AceFeatures executable_feature_list;
+       executable_feature_list.push_back(route_function);
+
+       AceDeviceCapability ext_network_cap(DEVICE_CAPABILITY_EXT_NET, WrtDeviceApis::Commons::AceDeviceCapParams());
+       AceDeviceCaps required_device_caps;
+       required_device_caps.push_back(ext_network_cap);
+       
+       return {ROUTE_FUNCTION_CATEGORY_BASIC , executable_feature_list, required_device_caps };
+}
+
+AceFunction getRouteFunctionData(const std::string & functionId)
+{
+    return route_function;
+}
+       
+} //LBS
+} // Tizen1_0
+} //TizenApis
+
+
similarity index 50%
rename from src/standards/Tizen/Geocoder/plugin_config.h
rename to src/standards/Tizen/Route/RouteAce.h
index cd74c6e..e24e958 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
-#ifndef _GEOCODER_PLUGIN_CONFIG_H_
-#define _GEOCODER_PLUGIN_CONFIG_H_
+#ifndef _WRTPLUGINS_TIZEN_JS_ROUTEACE_H_
+#define _WRTPLUGINS_TIZEN_JS_ROUTEACE_H_
 
+#include <string>
 #include <Commons/FunctionDeclaration.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
+namespace LBS {
 
-extern const char* GEOCODER_FUNCTION_API_GEOCODE;
-extern const char* GEOCODER_FUNCTION_API_REVERSE_GEOCODE;
+#define ROUTE_FUNCTION_CATEGORY_BASIC "ROUTE_FUNCTION_BASIC"
 
-DECLARE_FUNCTION_GETTER(Geocoder);
+WrtDeviceApis::Commons::AceFunction getRouteFunctionData(const std::string & functionId);
 
-#define GEOCODER_CHECK_ACCESS(globalContext, functionName)                     \
-    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> > (                \
-                                            globalContext,                     \
-                                            getGeocoderFunctionData,           \
-                                            functionName)
+#define ROUTE_CHECK_ACCESS(functionName)                     \
+    aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
+        getRouteFunctionData,           \
+        functionName)
 
-}
-}
+} // LBS
+} // Tizen1_0
+} // Tizen
+
+#endif // _WRTPLUGINS_TIZEN_JS_ROUTEACE_H_
 
-#endif //  _GEOCODER_PLUGIN_CONFIG_H_
diff --git a/src/standards/Tizen/Route/RouteDistance.cpp b/src/standards/Tizen/Route/RouteDistance.cpp
new file mode 100755 (executable)
index 0000000..5ea59f8
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+     
+#include "RouteDistance.h"
+#include "JSRouteDistance.h"
+#include "JSSimpleCoordinates.h" 
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+      
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+  
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+  
+JSObjectRef RouteDistance::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteDistance::getClassRef(), NULL);
+
+    if( text.size() > 0 )     
+        LBSUtil::setProperty(ctx, obj, "text", convert.toJSValueRef(text), kJSPropertyAttributeNone);
+    else
+        LBSUtil::setProperty(ctx, obj, "text", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+    
+    LBSUtil::setProperty(ctx, obj, "value", convert.toJSValueRef(value), kJSPropertyAttributeNone);   
+    LBSUtil::setProperty(ctx, obj, "unit", convert.toJSValueRef(unit), kJSPropertyAttributeNone);    
+    return obj;
+}
+     
+
+} //LBS
+} //Tizen1_0
+}//LBS
similarity index 53%
rename from src/platform/API/Call/CallServiceObject.h
rename to src/standards/Tizen/Route/RouteDistance.h
index 5d54070..4e47084 100755 (executable)
  * See the License for the specific language governing permissions and
  * limitations under the License. 
  */
+#ifndef _WRTPLUGINS_TIZEN_ROUTEDISTANCE_H_
+#define _WRTPLUGINS_TIZEN_ROUTEDISTANCE_H_
 
-#ifndef TIZENAPIS_API_CALLSERVICEOBJECT_H_
-#define TIZENAPIS_API_CALLSERVICEOBJECT_H_
-
-#include <dpl/shared_ptr.h>
-#include <API/Account/AccountServices.h>
-#include "ICallService.h"
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
 
 namespace TizenApis {
-namespace Api {
-namespace Call{
+namespace Tizen1_0 {
+namespace LBS{
+
 
-class CallServiceObject : public Api::Account::AccountServices
-{
-private:
-       ICallServicePtr m_ICallServicePtr;
+/**
+ * This object is used only data passing platform <-> JS Layer
+ * Not for private object
+ */
+class RouteDistance : public ConvertibleJSObject{
 public:
-       CallServiceObject(const Api::Account::AccountServices &accountServices, ICallServicePtr iCallServicePtr);
-       ~CallServiceObject();
-       ICallServicePtr getICallService();
+    std::string text;
+    double value;
+    std::string unit;
+
+    virtual JSObjectRef toJSObject(JSContextRef context);
 };
+    
 
-typedef DPL::SharedPtr<CallServiceObject> CallServiceObjectPtr;
+} //LBS
+} //Tizen1_0
+} //TizenApis
 
-}
-}
-}
+#endif //_WRTPLUGINS_TIZEN_ROUTEDISTANCE_H_
 
-#endif
diff --git a/src/standards/Tizen/Route/RouteDuration.cpp b/src/standards/Tizen/Route/RouteDuration.cpp
new file mode 100755 (executable)
index 0000000..e16208b
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RouteDuration.h"
+#include "JSRouteDuration.h"
+#include "JSSimpleCoordinates.h" 
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+      
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+  
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+  
+JSObjectRef RouteDuration::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteDuration::getClassRef(), NULL);
+    if( text.size() > 0 ) 
+        LBSUtil::setProperty(ctx, obj, "text", convert.toJSValueRef(text), kJSPropertyAttributeNone);
+    else
+        LBSUtil::setProperty(ctx, obj, "text", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+    
+    LBSUtil::setProperty(ctx, obj, "value", convert.toJSValueRef(value), kJSPropertyAttributeNone);
+    return obj;
+}
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
similarity index 54%
rename from src/platform/API/Call/EventSendUSSD.h
rename to src/standards/Tizen/Route/RouteDuration.h
index 5e4d68e..b2b8139 100755 (executable)
  * See the License for the specific language governing permissions and
  * limitations under the License. 
  */
-
-
-#ifndef TIZENAPIS_API_CALL_EVENT_SENDUSSD_H_
-#define TIZENAPIS_API_CALL_EVENT_SENDUSSD_H_
+#ifndef _WRTPLUGINS_TIZEN_ROUTEDURATION_H_
+#define _WRTPLUGINS_TIZEN_ROUTEDURATION_H_
 
 #include <string>
-#include <Commons/IEvent.h>
-#include <dpl/shared_ptr.h>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
 
 namespace TizenApis {
-namespace Api {
-namespace Call {
-class EventSendUSSD : public WrtDeviceApis::Commons::IEvent<EventSendUSSD>
-{
-  private:
-       std::string m_command;
-       std::string m_result;
-
-  public:
-       void setCommand(const std::string command);
-       void setResult(const std::string result);
-       std::string getCommand() const;
-       std::string getResult() const;
-
-       EventSendUSSD();
+namespace Tizen1_0 {
+namespace LBS{
+
+
+/**
+ * This object is used only data passing platform <-> JS Layer
+ * Not for private object
+ */
+class RouteDuration : public ConvertibleJSObject{
+public:
+    std::string text;
+    double value;
+
+    virtual JSObjectRef toJSObject(JSContextRef context);
 };
+    
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
 
-typedef DPL::SharedPtr<EventSendUSSD> EventSendUSSDPtr;
-}
-}
-}
+#endif //_WRTPLUGINS_TIZEN_ROUTEDURATION_H_
 
-#endif
diff --git a/src/standards/Tizen/Route/RouteProvider.cpp b/src/standards/Tizen/Route/RouteProvider.cpp
new file mode 100755 (executable)
index 0000000..7159d73
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RouteProvider.h"
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+RouteProvider::RouteProvider(std::string _name): name(_name)
+{
+}
+
+RouteProvider::~RouteProvider()
+{
+}
+
+void RouteProvider::setName(std::string &setName){
+    name = setName;
+}
+
+std::string RouteProvider::getName(){
+    return name;
+}
+
+std::string RouteProvider::getAttribution(){
+    return "";
+}
+
+       
+} //LBS
+} //Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Route/RouteProvider.h b/src/standards/Tizen/Route/RouteProvider.h
new file mode 100755 (executable)
index 0000000..5294050
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_ROUTEPROVIDER_H_
+#define _WRTPLUGINS_TIZEN_ROUTEPROVIDER_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "LocationServiceProvider.h"
+#include "RouteRequestOptions.h"
+#include "RouteResult.h"
+#include "LBSPending.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+typedef void (* RouteArrayCallback )( int result, std::vector<RouteResult*> RouteArray,  void* user_data );
+
+class RouteProvider :public LocationServiceProvider{
+    private:
+        std::string name;
+
+    protected:
+        void setName(std::string &name);
+        
+    public:
+        enum RouteERROR{ NONE = 0 , INVALID_PARAMETER , OUT_OF_MEMORY, SERVICE_NOT_AVAILABLE, NOT_FOUND, NETWORK_FAILED};
+        
+        RouteProvider(std::string _name);
+        ~RouteProvider();
+        virtual std::string getName();
+        virtual std::string getAttribution();
+        virtual std::vector<std::pair<std::string, std::string>> getMetadata()=0;
+        virtual std::vector<std::string> getSupportedOptions()=0;
+        virtual std::string getConnectivity()=0;
+        virtual int setOption( std::vector<std::pair<std::string, std::string>> options, setOptionCb callback, void *user_data, LBSPending **pending)=0;
+        virtual bool isUsedExternalNetwork()=0;    
+
+        virtual std::vector<std::string> getSupportedGoals()=0;
+        virtual std::vector<std::string> getSupportedModes()=0;
+        virtual std::vector<std::string> getSupportedConstraints()=0;
+        virtual bool supportswayPoints()=0;
+
+        virtual int find(double originLati, double originLongi, double destLati, double destLongi, RouteRequestOptions& option ,  RouteArrayCallback callback, void* user_data, LBSPending **pending)=0;
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_ROUTEPROVIDER_H_
+
diff --git a/src/standards/Tizen/Route/RouteRequestOptions.cpp b/src/standards/Tizen/Route/RouteRequestOptions.cpp
new file mode 100755 (executable)
index 0000000..67e7daa
--- /dev/null
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RouteRequestOptions.h"
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <dlog.h>
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace WrtDeviceApis::Commons;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS {
+
+RouteRequestOptions::RouteRequestOptions(){
+    unit = "KM";
+    maxResult = 1;
+}
+
+bool RouteRequestOptions::convert(JSContextRef ctx, JSObjectRef object, RouteRequestOptions* options, JSValueRef* exception){
+    if(options == NULL) {        
+        if( exception )
+            *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "options is not object value");
+        return false;
+    }
+
+    // Convert mode
+    std::string modeValue = LBSUtil::getPropertyToString(ctx, object, "mode");
+    if(!modeValue.empty())
+        options->mode = modeValue;
+
+    // Convert unit
+    JSValueRef unitValue = LBSUtil::getPropertyToValueRef(ctx, object, "unit");
+    if( !JSValueIsUndefined(ctx, unitValue) && !JSValueIsNull(ctx, unitValue) && JSValueIsString(ctx, unitValue) ) {
+        JSStringRef unitString = JSValueToStringCopy(ctx, unitValue, NULL);
+        if( JSStringIsEqualToUTF8CString(unitString, "M") || JSStringIsEqualToUTF8CString(unitString, "KM") || 
+            JSStringIsEqualToUTF8CString(unitString, "MI") || JSStringIsEqualToUTF8CString(unitString, "FT") )
+            options->unit = LBSUtil::getPropertyToString(ctx, object, "unit");
+        else {
+            *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR, "The unit is not ReouteDistanceUnit");
+            JSStringRelease(unitString);
+            return false;
+        }
+        if( unitString )
+            JSStringRelease(unitString);
+    }
+
+    // Convert routeGoal
+    std::string routeGoalValue = LBSUtil::getPropertyToString(ctx, object, "routeGoal");
+    if(!routeGoalValue.empty())
+        options->goal = routeGoalValue;
+
+    // Convert constraints
+    Converter convert(ctx);
+    JSValueRef constraintsValue = LBSUtil::getPropertyToValueRef(ctx, object, "constraints");
+    if( !JSValueIsUndefined(ctx, constraintsValue) && !JSValueIsNull(ctx, constraintsValue) ) {
+        if( !JSIsArrayValue(ctx, constraintsValue) ) {
+            if( exception )
+                *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "constraints is not array");
+            return false;        
+        }
+        options->constraints = convert.toVectorOfStrings(constraintsValue);
+    }
+
+    // Convert wayPoints
+    JSValueRef wayPointsValue = LBSUtil::getPropertyToValueRef(ctx, object, "wayPoints");
+    if( !JSValueIsUndefined(ctx, wayPointsValue) && !JSValueIsNull(ctx, wayPointsValue) ) {
+        if( !JSIsArrayValue(ctx, wayPointsValue) ) {
+            if( exception )
+                *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "wayPoints is not array");
+            return false;        
+        }    
+        
+        JSObjectRef wayPointsObj = JSValueToObject(ctx, wayPointsValue, NULL);
+        int count = JSGetArrayLength(ctx, wayPointsObj);
+        for( int i =0 ; i<count ; i++){        
+            JSObjectRef pointObj = JSValueToObject(ctx, JSGetArrayElement(ctx, wayPointsObj, i), NULL);        
+            if( pointObj == NULL ) {
+                if( exception )
+                    *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "A RouteWaypoint in wayPoints is not object");
+                return false;        
+            }                
+
+            double latitude = 0.0;
+            double longitude = 0.0;
+            JSValueRef positionValue = LBSUtil::getPropertyToValueRef(ctx, pointObj, "position");
+
+            //Check the first argument
+            if(JSValueIsNull(ctx, positionValue) || JSValueIsUndefined(ctx, positionValue) || !JSValueIsObject(ctx, positionValue))
+            {
+                if( exception )
+                    *exception = Commons::JSTizenExceptionFactory::makeErrorObject(ctx, Commons::JSTizenException::TYPE_MISMATCH_ERROR , "position in RouteWaypoint is invalid (null or undefined or not object)");
+                return false;        
+            }
+            
+            JSObjectRef positionObj = JSValueToObject(ctx, positionValue, NULL);
+            JSValueRef latCheck = LBSUtil::getPropertyToValueRef(ctx, positionObj, "latitude");
+            JSValueRef longCheck = LBSUtil::getPropertyToValueRef(ctx, positionObj, "longitude");
+            if ( JSValueIsNull(ctx, latCheck ) || JSValueIsUndefined(ctx, latCheck) || JSValueIsNull(ctx, longCheck ) || JSValueIsUndefined(ctx, longCheck))
+            {
+                if( exception )
+                    *exception = Commons::JSTizenExceptionFactory::postException(ctx,exception,  Commons::JSTizenException::TYPE_MISMATCH_ERROR, "position is not AbstractCoordinates");
+                return false;
+            }                      
+            latitude = LBSUtil::getPropertyToDouble(ctx, positionObj, "latitude");
+            longitude = LBSUtil::getPropertyToDouble(ctx, positionObj, "longitude");
+
+            bool isStopover = true;
+            JSValueRef stopOver = LBSUtil::getPropertyToValueRef(ctx, pointObj, "isStopover");
+            if(JSValueIsBoolean(ctx, stopOver))
+                isStopover = JSValueToBoolean(ctx, stopOver);
+
+            if(isStopover == true)
+                LOGI("%s - ######################### stopOver", __func__);
+            else
+                LOGI("%s - ######################### Not stopOver", __func__);
+            
+            wayPoint wayPointValue = {latitude, longitude, isStopover};
+            options->wayPoints.push_back(wayPointValue);
+        }
+    }
+
+    // masResults
+    JSValueRef maxResultsValue = LBSUtil::getPropertyToValueRef(ctx, object, "maxResults");
+    if(JSValueIsNumber(ctx, maxResultsValue)){
+        options->maxResult = JSValueToNumber(ctx, maxResultsValue , NULL);
+        LOGI("%s - max result: %d", __func__, options->maxResult);
+    }   
+
+    return true;
+}    
+
+    
+    
+}//LSB
+}// Tizen1_0
+}// TizenApis
+
diff --git a/src/standards/Tizen/Route/RouteRequestOptions.h b/src/standards/Tizen/Route/RouteRequestOptions.h
new file mode 100755 (executable)
index 0000000..92ff78f
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#ifndef _WRTPLUGINS_TIZEN_REQUESTOPTIONS_H_
+#define _WRTPLUGINS_TIZEN_REQUESTOPTIONS_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+struct wayPoint
+{
+    double latitude;
+    double longitude;
+    bool isStopover;
+};
+
+class RouteRequestOptions{
+public:
+       RouteRequestOptions();
+       
+       std::string mode;
+       std::string unit;
+       std::string goal;    
+       std::vector<std::string> constraints;
+       std::vector<wayPoint> wayPoints;    
+       unsigned int maxResult;
+               
+       static bool convert(JSContextRef ctx, JSObjectRef object, RouteRequestOptions* options, JSValueRef* exception);
+};
+
+}
+}
+}
+
+#endif //_WRTPLUGINS_TIZEN_REQUESTOPTIONS_H_
diff --git a/src/standards/Tizen/Route/RouteResult.cpp b/src/standards/Tizen/Route/RouteResult.cpp
new file mode 100755 (executable)
index 0000000..8729a73
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+ #include "RouteResult.h"
+ #include "JSRouteResult.h"
+ #include "LBSUtil.h"
+ #include <CommonsJavaScript/Converter.h>
+
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+RouteResult::~RouteResult()
+{
+    std::vector<RouteSegment*>::iterator pos;
+    for( pos = segments.begin() ; pos != segments.end() ; ++pos)
+        delete *pos;
+}
+
+JSObjectRef RouteResult::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteResult::getClassRef(), NULL);
+
+    LBSUtil::setProperty(ctx, obj, "summary", summary.toJSObject(ctx), kJSPropertyAttributeNone);
+
+    if( warnings.size() > 0 ) 
+        LBSUtil::setProperty(ctx, obj, "warnings", convert.toJSValueRef(warnings), kJSPropertyAttributeNone);
+    else
+        LBSUtil::setProperty(ctx, obj, "warnings", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+
+     int length = segments.size();
+     JSValueRef* segmentsArray = NULL;
+     segmentsArray = new JSValueRef[length];
+     
+     for(int i = 0; i < length ; i++){
+         segmentsArray[i] = (*(segments[i])).toJSObject(ctx);
+     }
+     JSObjectRef segmentsObj = JSObjectMakeArray(ctx, length, segmentsArray, NULL);
+     LBSUtil::setProperty(ctx, obj, "segments", segmentsObj , kJSPropertyAttributeReadOnly);
+     delete [] segmentsArray;    
+
+     return obj;
+}
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
diff --git a/src/standards/Tizen/Route/RouteResult.h b/src/standards/Tizen/Route/RouteResult.h
new file mode 100755 (executable)
index 0000000..7f61297
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#ifndef _WRTPLUGINS_TIZEN_ROUTERESULT_H_
+#define _WRTPLUGINS_TIZEN_ROUTERESULT_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+#include "RouteResultSummary.h"
+#include "RouteSegment.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+
+/**
+ * This object is used only data passing platform <-> JS Layer
+ * Not for private object
+ */
+class RouteResult : public ConvertibleJSObject{
+public:  
+    RouteResultSummary summary;
+    std::vector<RouteSegment*> segments;
+    std::vector<std::string> warnings;
+
+    ~RouteResult();
+    virtual JSObjectRef toJSObject(JSContextRef context);
+};
+    
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_ROUTERESULT_H_
+
diff --git a/src/standards/Tizen/Route/RouteResultSummary.cpp b/src/standards/Tizen/Route/RouteResultSummary.cpp
new file mode 100755 (executable)
index 0000000..1616c73
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RouteResultSummary.h"
+#include "JSRouteResultSummary.h"
+#include "JSSimpleCoordinates.h"
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+JSObjectRef RouteResultSummary::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteResultSummary::getClassRef(), NULL);
+
+    JSObjectRef originObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, originObj, "latitude", originLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, originObj, "longitude", orginLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "origin", originObj, kJSPropertyAttributeNone);
+
+    JSObjectRef destObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, destObj, "latitude", destLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, destObj, "longitude", destLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "destination", destObj, kJSPropertyAttributeNone);
+    
+    LBSUtil::setProperty(ctx, obj, "totalDistance", totalDistance.toJSObject(ctx), kJSPropertyAttributeNone);    
+    LBSUtil::setProperty(ctx, obj, "totalDuration", totalDuration.toJSObject(ctx), kJSPropertyAttributeNone);    
+
+     return obj;
+}
+
+} //LBS
+} //Tizen1_0
+}//LBS
similarity index 50%
rename from src/platform/API/Account/AccountFactory.h
rename to src/standards/Tizen/Route/RouteResultSummary.h
index 0bf0f61..02f897f 100755 (executable)
  * See the License for the specific language governing permissions and
  * limitations under the License. 
  */
+#ifndef _WRTPLUGINS_TIZEN_ROUTERESULTSUMMARY_H_
+#define _WRTPLUGINS_TIZEN_ROUTERESULTSUMMARY_H_
 
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+#include "RouteDistance.h"
+#include "RouteDuration.h"
 
-/**
- * @file        ICalendarFactory.h
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- */
-
-#ifndef _ABSTRACT_LAYER_ACCOUNT_FACTORY_H_
-#define _ABSTRACT_LAYER_ACCOUNT_FACTORY_H_
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
 
-#include "IAccountManager.h"
-#include "IAccountService.h"
-#include <dpl/shared_ptr.h>
+class RouteResultSummary : public ConvertibleJSObject{
+public:
+    double originLatitude;
+    double orginLogitude;
 
-namespace TizenApis {
-namespace Api {
-namespace Account{
+    double destLatitude;
+    double destLogitude;
 
-       
-class AccountFactory : private DPL::Noncopyable
-{
-  private:
-    AccountFactory()
-    {
-    }
-  public:
-    static AccountFactory& getInstance();
-    IAccountManagerPtr    createAccountManagerObject();
-//    IAccountServicePtr           createAccountObject();
+    RouteDistance totalDistance;
+    RouteDuration totalDuration;
+    
+    virtual JSObjectRef toJSObject(JSContextRef context);
 };
-}
-}
-}
+       
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_ROUTERESULTSUMMARY_H_
 
-#endif /* WRTPLUGINSCAMERAFACTORY_H_ */
diff --git a/src/standards/Tizen/Route/RouteSegment.cpp b/src/standards/Tizen/Route/RouteSegment.cpp
new file mode 100755 (executable)
index 0000000..546ab8e
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+
+#include "RouteSegment.h"
+#include "JSRouteSegment.h"
+#include "JSSimpleCoordinates.h" 
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+RouteSegment::~RouteSegment()
+{
+    std::vector<RouteStep*>::iterator pos;
+    for( pos = steps.begin() ; pos != steps.end() ; ++pos)
+        delete *pos;
+}
+
+JSObjectRef RouteSegment::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteSegment::getClassRef(), NULL);
+
+    JSObjectRef originObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, originObj, "latitude", originLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, originObj, "longitude", orginLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "origin", originObj, kJSPropertyAttributeNone);
+
+    JSObjectRef destObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, destObj, "latitude", destLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, destObj, "longitude", destLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "destination", destObj, kJSPropertyAttributeNone);
+    
+    LBSUtil::setProperty(ctx, obj, "distance", totalDistance.toJSObject(ctx), kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "duration", totalDuration.toJSObject(ctx), kJSPropertyAttributeNone);    
+
+    int length = steps.size();
+    JSValueRef* stepsArray = NULL;
+    stepsArray = new JSValueRef[length];
+    
+    for(int i = 0; i < length ; i++){
+        stepsArray[i] = (*(steps[i])).toJSObject(ctx);
+    }
+    JSObjectRef stepsObj = JSObjectMakeArray(ctx, length, stepsArray, NULL);
+    LBSUtil::setProperty(ctx, obj, "steps", stepsObj , kJSPropertyAttributeReadOnly);
+    delete [] stepsArray;    
+
+    return obj;
+}
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
diff --git a/src/standards/Tizen/Route/RouteSegment.h b/src/standards/Tizen/Route/RouteSegment.h
new file mode 100755 (executable)
index 0000000..f83dc12
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#ifndef _WRTPLUGINS_TIZEN_ROUTESEGMENT_H_
+#define _WRTPLUGINS_TIZEN_ROUTESEGMENT_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+#include "RouteDistance.h"
+#include "RouteDuration.h"
+#include "RouteStep.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class RouteSegment : public ConvertibleJSObject{
+public:
+    double originLatitude;
+    double orginLogitude;
+
+    double destLatitude;
+    double destLogitude;
+
+    RouteDistance totalDistance;
+    RouteDuration totalDuration;
+
+    std::vector<RouteStep*> steps;
+
+    ~RouteSegment();
+    virtual JSObjectRef toJSObject(JSContextRef context);
+};
+
+       
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_ROUTESEGMENT_H_
+
diff --git a/src/standards/Tizen/Route/RouteStep.cpp b/src/standards/Tizen/Route/RouteStep.cpp
new file mode 100755 (executable)
index 0000000..cd99eae
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include "RouteStep.h"
+#include "JSRouteStep.h"
+#include "JSSimpleCoordinates.h" 
+#include "LBSUtil.h"
+#include <CommonsJavaScript/Converter.h>
+#include <vector>
+using namespace std;
+using namespace WrtDeviceApis::CommonsJavaScript;
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+JSObjectRef RouteStep::toJSObject(JSContextRef ctx){
+    Converter convert(ctx);
+    JSObjectRef obj = JSObjectMake(ctx, JSRouteStep::getClassRef(), NULL);
+
+    JSObjectRef originObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, originObj, "latitude", originLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, originObj, "longitude", orginLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "origin", originObj, kJSPropertyAttributeNone);
+
+    JSObjectRef destObj = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+    LBSUtil::setProperty(ctx, destObj, "latitude", destLatitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, destObj, "longitude", destLogitude, kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "destination", destObj, kJSPropertyAttributeNone);
+    
+    LBSUtil::setProperty(ctx, obj, "distance", totalDistance.toJSObject(ctx), kJSPropertyAttributeNone);
+    LBSUtil::setProperty(ctx, obj, "duration", totalDuration.toJSObject(ctx), kJSPropertyAttributeNone);    
+
+    LBSUtil::setProperty(ctx, obj, "mode", convert.toJSValueRef(mode), kJSPropertyAttributeNone);
+
+    if( instruction.size() > 0 )
+        LBSUtil::setProperty(ctx, obj, "instruction", convert.toJSValueRef(instruction), kJSPropertyAttributeNone);
+    else
+        LBSUtil::setProperty(ctx, obj, "instruction", JSValueMakeNull(ctx), kJSPropertyAttributeNone);
+    
+    int length = points.size();
+    JSValueRef* pointsArray = NULL;
+    pointsArray = new JSValueRef[length];
+    
+    for(int i = 0; i < length ; i++){
+        JSObjectRef pos = JSObjectMake(ctx, Tizen::JSSimpleCoordinates::getClassRef(), NULL);
+        LBSUtil::setProperty(ctx, pos, "latitude", points[0].first, kJSPropertyAttributeReadOnly);
+        LBSUtil::setProperty(ctx, pos, "longitude", points[0].second, kJSPropertyAttributeReadOnly);
+        pointsArray[i] = pos;
+    }
+    JSObjectRef pointsObj = JSObjectMakeArray(ctx, length, pointsArray, NULL);
+    LBSUtil::setProperty(ctx, obj, "points", pointsObj , kJSPropertyAttributeReadOnly);
+    delete [] pointsArray;    
+
+    return obj;
+}
+
+
+} //LBS
+} //Tizen1_0
+}//LBS
diff --git a/src/standards/Tizen/Route/RouteStep.h b/src/standards/Tizen/Route/RouteStep.h
new file mode 100755 (executable)
index 0000000..f5b3506
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+#ifndef _WRTPLUGINS_TIZEN_ROUTESTEP_H_
+#define _WRTPLUGINS_TIZEN_ROUTESTEP_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include "ConvertibleJSObject.h"
+#include "RouteDistance.h"
+#include "RouteDuration.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace LBS{
+
+class RouteStep : public ConvertibleJSObject{
+public:
+    double originLatitude;
+    double orginLogitude;
+
+    double destLatitude;
+    double destLogitude;
+
+    RouteDistance totalDistance;
+    RouteDuration totalDuration;
+
+    std::string mode;
+    std::string instruction;
+    std::vector<std::pair<double, double>> points;
+    
+    virtual JSObjectRef toJSObject(JSContextRef context);
+};
+       
+
+} //LBS
+} //Tizen1_0
+} //TizenApis
+
+#endif //_WRTPLUGINS_TIZEN_ROUTESTEP_H_
+
diff --git a/src/standards/Tizen/Route/config.xml b/src/standards/Tizen/Route/config.xml
new file mode 100755 (executable)
index 0000000..664ea21
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+       <library-name>libwrt-plugins-tizen-1.0-route.so</library-name>
+       <feature-install-uri>route.install.uri</feature-install-uri>
+       <feature-key-cn>SAMSUNG plugin group</feature-key-cn>
+       <feature-root-cn>SAMSUNG certificate authority</feature-root-cn>
+       <feature-root-fingerprint>AAAABBBBCCCCDDDEEEE0000</feature-root-fingerprint>
+
+       <api-feature>
+               <name>http://tizen.org/api/lbs.route</name>
+       </api-feature>
+</plugin-properties>
+
diff --git a/src/standards/Tizen/Route/plugin_initializer.cpp b/src/standards/Tizen/Route/plugin_initializer.cpp
new file mode 100755 (executable)
index 0000000..fc82097
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the License);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an AS IS BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. 
+ */
+
+#include <dlog.h>
+#include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+#include "JSRouteServiceManager.h"
+
+#undef LOG_TAG
+#define LOG_TAG "TIZEN_ROUTE"
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+
+void on_widget_start_callback(int widgetId) {
+    LOGD("on Route widget start callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess initialization failed");
+    }
+}
+
+void on_widget_stop_callback(int widgetId) {
+    LOGD("on Route widget stop callback (%d)", widgetId);
+    try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    catch(...)
+    {
+        LOGE("WrtAccess deinitialization failed");
+    }
+}
+
+PLUGIN_ON_WIDGET_START(on_widget_start_callback)
+PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
+
+PLUGIN_CLASS_MAP_BEGIN
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN ".lbs" , "route",
+      TizenApis::Tizen1_0::LBS::JSRouteServiceManager::getClassRef(),NULL)
+PLUGIN_CLASS_MAP_END
+
index 4ca86fb..cf1c889 100755 (executable)
@@ -7,7 +7,6 @@ include_directories(${system_INCLUDE_DIRS})
 set(SRCS
   JSSensor.cpp
   JSSensorDataEvent.cpp
-  JSSensorError.cpp
   JSSensorManager.cpp
   JSSensorRequest.cpp
   JSSensorConnection.cpp
old mode 100755 (executable)
new mode 100644 (file)
index 0b0448f..df52154
@@ -16,6 +16,7 @@
 #include <map>
 #include <vector>
 #include <algorithm>
+#include <dpl/mutex.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/JSUtils.h>
@@ -24,7 +25,6 @@
 #include "JSSensorManager.h"
 #include "JSSensorConnection.h"
 #include "JSSensorDataEvent.h"
-#include "JSSensorError.h"
 #include "SensorType.h"
 
 #include <dlog.h>
@@ -61,6 +61,9 @@ struct SensorConnection {
 
     map< int, vector<JSValueRef> > listeners;
     JSObjectRef jsobj;
+    DPL::Mutex m_stopMutex;
+
+    float lastValues[3];
 };
 
 enum {
@@ -249,8 +252,10 @@ void JSSensorConnection::finalize(JSObjectRef object)
     struct SensorConnection* scon = (struct SensorConnection*) JSObjectGetPrivate(object);
 
     if(scon != NULL){
+        DPL::Mutex::ScopedLock lock(&scon->m_stopMutex);
         if(scon->handle != NULL){
             sensor_destroy(scon->handle);
+            scon->handle = NULL;
         }
     }
 }
@@ -374,10 +379,13 @@ bool JSSensorConnection::setProperty(JSContextRef ctx, JSObjectRef object, JSStr
     return false;
 }
 
-static void throwError(struct SensorConnection* scon, const char* msg, int code)
+static void throwError(struct SensorConnection* scon, JSDOMExceptionFactory *factory)
 {
     JSContextRef ctx = JSSensorManager::gCtx;
-    scon->error = JSSensorError::makeSensorError(ctx, msg, code);
+    JSValueRef exception;
+    factory->make(ctx, &exception);
+    scon->error = JSValueToObject(ctx, exception, NULL);
+
     fireEvent(scon, SENSOR_LISTENER_ERROR, scon->error);
 }
 
@@ -387,7 +395,7 @@ static gboolean connect_sensor(gpointer user_data)
     struct SensorConnection* scon = (struct SensorConnection*) user_data;
 
     if(scon == NULL){
-        throwError(scon, "Unknown error", JSSensorError::UNKNOWN_ERROR);
+        throwError(scon, &JSDOMExceptionFactory::UnknownException);
         return false;
     }
 
@@ -399,7 +407,7 @@ static gboolean connect_sensor(gpointer user_data)
 
     int err = sensor_create(&scon->handle);
     if(err < 0) {
-        throwError(scon, "Connect fail", JSSensorError::CONNECT_ERROR);
+        throwError(scon, &JSDOMExceptionFactory::UnknownException);
         return false;
     }
     scon->status = SENSOR_CON_OPEN;
@@ -414,6 +422,7 @@ JSObjectRef JSSensorConnection::constructor(JSContextRef ctx, JSObjectRef constr
     char buf[64];
     char buf2[64];
     int type;
+
     if(argumentCount < 1){
         *exception = JSDOMExceptionFactory::InvalidValuesException.make(ctx);
         return NULL;
@@ -481,10 +490,14 @@ JSObjectRef JSSensorConnection::constructor(JSContextRef ctx, JSObjectRef constr
     scon->onsensordata = NULL;
     scon->onstatuschange = NULL;
     scon->oncalibneed = NULL;
+    scon->lastValues[0] = -2012;
+    scon->lastValues[1] = -2012;
+    scon->lastValues[2] = -2012;
 
     fireEvent( scon, SENSOR_LISTENER_STATUS, NULL);
 
     g_idle_add_full(G_PRIORITY_HIGH_IDLE, connect_sensor, scon, NULL);
+//    JSGarbageCollect(ctx);
     return obj;
 }
 
@@ -492,11 +505,21 @@ static void sensor_cb_accelerometer(sensor_data_accuracy_e accuracy, float x, fl
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && 
+            scon->lastValues[0] == x &&
+            scon->lastValues[1] == y &&
+            scon->lastValues[2] == z)
+        return;
+
+    scon->lastValues[0] = x;
+    scon->lastValues[1] = y;
+    scon->lastValues[2] = z;
+
     if(accuracy < SENSOR_DATA_ACCURACY_UNDEFINED  || accuracy > SENSOR_DATA_ACCURACY_VERYGOOD){
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
 
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
@@ -505,11 +528,20 @@ static void sensor_cb_magnetic(sensor_data_accuracy_e accuracy, float x, float y
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && 
+            scon->lastValues[0] == x &&
+            scon->lastValues[1] == y &&
+            scon->lastValues[2] == z)
+        return;
+
+    scon->lastValues[0] = x;
+    scon->lastValues[1] = y;
+    scon->lastValues[2] = z;
     if(accuracy < SENSOR_DATA_ACCURACY_UNDEFINED  || accuracy > SENSOR_DATA_ACCURACY_VERYGOOD){
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
@@ -517,11 +549,20 @@ static void sensor_cb_orientation(sensor_data_accuracy_e accuracy, float alpha,
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && 
+            scon->lastValues[0] == alpha &&
+            scon->lastValues[1] == beta &&
+            scon->lastValues[2] == gamma)
+        return;
+
+    scon->lastValues[0] = alpha;
+    scon->lastValues[1] = beta;
+    scon->lastValues[2] = gamma;
     if(accuracy < SENSOR_DATA_ACCURACY_UNDEFINED  || accuracy > SENSOR_DATA_ACCURACY_VERYGOOD){
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
 
     alpha = alpha * ( PI / 180 );
     beta = beta * ( PI / 180 );
@@ -534,11 +575,20 @@ static void sensor_cb_gyroscope(sensor_data_accuracy_e accuracy, float x, float
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && 
+            scon->lastValues[0] == x &&
+            scon->lastValues[1] == y &&
+            scon->lastValues[2] == z)
+        return;
+
+    scon->lastValues[0] = x;
+    scon->lastValues[1] = y;
+    scon->lastValues[2] = z;
     if(accuracy < SENSOR_DATA_ACCURACY_UNDEFINED  || accuracy > SENSOR_DATA_ACCURACY_VERYGOOD){
         accuracy = SENSOR_DATA_ACCURACY_UNDEFINED;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
     data->set(accuracy, g_get_monotonic_time(), x, y, z);
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
@@ -546,12 +596,17 @@ static void sensor_cb_light(sensor_data_accuracy_e accuracy, float lux, void* ud
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && scon->lastValues[0] == lux)
+        return;
+
+    scon->lastValues[0] = lux;
+
 
     if(scon->threshold >= 0 && lux != scon->threshold){
         return;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
     data->set(accuracy, g_get_monotonic_time(), lux);
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
@@ -559,12 +614,17 @@ static void sensor_cb_proximity(sensor_data_accuracy_e accuracy, float distance,
 {
     JSContextRef ctx = JSSensorManager::gCtx;
     struct SensorConnection* scon = (struct SensorConnection*) ud;
+    if(scon->interval == 0 && scon->lastValues[0] == distance)
+        return;
+
+    scon->lastValues[0] = distance;
+
 
     if(scon->threshold >= 0 && distance != scon->threshold){
         return;
     }
 
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, true, scon->type);
     data->set(accuracy, g_get_monotonic_time(), distance);
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
@@ -586,10 +646,10 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
     }
 
     bool started = false;
-    float x, y, z;
+    float x=0, y=0, z=0;
     float lux, cm;
     sensor_data_accuracy_e acc;
-    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_READ, scon->type);
+    JSSensorDataEvent* data = new JSSensorDataEvent(ctx, false, scon->type);
     if(scon->status != SENSOR_CON_WATCHING){
         sensor_start(scon->handle, scon->type);
         started = true;
@@ -621,6 +681,7 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
             break;
         case SENSOR_PROXIMITY:
             sensor_proximity_read_data(scon->handle, &acc, &cm);
+            data->set(acc, g_get_monotonic_time(), cm);
             break;
 
         default:
@@ -644,93 +705,98 @@ static gboolean registerAndStart(gpointer user_data)
         case SENSOR_ACCELEROMETER:
             err = sensor_accelerometer_set_cb(scon->handle, (int)scon->interval, sensor_cb_accelerometer, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_ACCELEROMETER);
             if(err <0) {
                 sensor_accelerometer_unset_cb(scon->handle);
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         case SENSOR_MAGNETIC:
             err = sensor_magnetic_set_cb(scon->handle, (int)scon->interval, sensor_cb_magnetic, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_magnetic_set_calibration_cb(scon->handle, sensor_cb_calibration, scon);
             if(err <0) {
                 sensor_magnetic_unset_cb(scon->handle);
-                throwError(scon, "Calibration watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_MAGNETIC);
             if(err <0) {
                 sensor_magnetic_unset_cb(scon->handle);
                 sensor_magnetic_unset_calibration_cb(scon->handle);
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         case SENSOR_ORIENTATION:
             err = sensor_orientation_set_cb(scon->handle, (int)scon->interval, sensor_cb_orientation, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_ORIENTATION);
             if(err <0) {
                 sensor_orientation_unset_cb(scon->handle);
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         case SENSOR_GYROSCOPE:
             err = sensor_gyroscope_set_cb(scon->handle, (int)scon->interval, sensor_cb_gyroscope, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_GYROSCOPE);
             if(err <0) {
                 sensor_gyroscope_unset_cb(scon->handle);
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         case SENSOR_LIGHT:
             err = sensor_light_set_cb(scon->handle, (int)scon->interval, sensor_cb_light, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_LIGHT);
             if(err <0) {
                 sensor_light_unset_cb(scon->handle);
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         case SENSOR_PROXIMITY:
             err = sensor_proximity_set_cb(scon->handle, (int)scon->interval, sensor_cb_proximity, scon);
             if(err <0) {
-                throwError(scon, "Watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             err = sensor_start(scon->handle, SENSOR_PROXIMITY);
             if(err <0) {
                 sensor_proximity_unset_cb(scon->handle);
-                throwError(scon, "Calibration watching fail", JSSensorError::WATCH_ERROR);
-                return false;
+                throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
+                break;
             }
             break;
         default:
-            throwError(scon, "Unknown error", JSSensorError::UNKNOWN_ERROR);
+            throwError(scon, &JSDOMExceptionFactory::UnknownException);
             return false;
     }
 
+    if(err < 0) {
+        throwError(scon, &JSDOMExceptionFactory::UnknownException);
+        return false;
+    }
+
     scon->status = SENSOR_CON_WATCHING;
     fireEvent( scon, SENSOR_LISTENER_STATUS, NULL);
 
@@ -757,23 +823,35 @@ JSValueRef JSSensorConnection::startWatch(JSContextRef ctx, JSObjectRef object,
         JSStringRef pname_interval = JSStringCreateWithUTF8CString("interval");
         if(JSObjectHasProperty(ctx, watchOption, pname_threshold)){
             JSValueRef jsv_threshold = JSObjectGetProperty(ctx, watchOption, pname_threshold, NULL);
-            threshold = JSValueToNumber(ctx, jsv_threshold, NULL);
+            if(!JSValueIsNumber(ctx, jsv_threshold)){
+                return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+            }
+            threshold = JSValueToNumber(ctx, jsv_threshold, exception);
+            if(isnan(threshold))
+                return JSValueMakeUndefined(ctx);
         }
         if(JSObjectHasProperty(ctx, watchOption, pname_interval)){
             JSValueRef jsv_interval = JSObjectGetProperty(ctx, watchOption, pname_interval, NULL);
-            interval = JSValueToNumber(ctx, jsv_interval, NULL);
+            if(!JSValueIsNumber(ctx, jsv_interval)){
+                return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+            }
+            interval = JSValueToNumber(ctx, jsv_interval, exception);
+            if(isnan(threshold))
+                return JSValueMakeUndefined(ctx);
         }
         JSStringRelease(pname_threshold);
         JSStringRelease(pname_interval);
         scon->threshold = threshold;
         scon->interval = interval;
+
     }else{
         scon->threshold = -1;
         scon->interval = 0;
+        scon->lastValues[0] = -2012;
+        scon->lastValues[1] = -2012;
+        scon->lastValues[2] = -2012;
     }
 
-//    JSSensorDataEvent::setReason(ctx, scon->eventData, JSSENSOR_REASON_WATCH);
-
     g_idle_add_full(G_PRIORITY_HIGH_IDLE, registerAndStart, scon, NULL);
 
     return JSValueMakeUndefined(ctx);
@@ -784,6 +862,12 @@ static gboolean deregisterandstop(gpointer user_data)
 {
     struct SensorConnection* scon = (struct SensorConnection*) user_data;
     int err = 0;
+    if(scon->handle == NULL){
+        scon->status = SENSOR_CON_OPEN;
+        fireEvent(scon, SENSOR_LISTENER_STATUS, NULL);
+        return true;
+    }
+    DPL::Mutex::ScopedLock lock(&scon->m_stopMutex);
     switch(scon->type){
         case SENSOR_ACCELEROMETER:
             err += sensor_stop(scon->handle, SENSOR_ACCELEROMETER);
@@ -811,11 +895,11 @@ static gboolean deregisterandstop(gpointer user_data)
             err += sensor_proximity_unset_cb(scon->handle);
             break;
         default:
-            throwError(scon, "Unknown error", JSSensorError::UNKNOWN_ERROR);
+            throwError(scon, &JSDOMExceptionFactory::UnknownException);
             return false;
     }
     if(err <0) {
-        throwError(scon, "End watching fail", JSSensorError::END_WATCH_ERROR);
+        throwError(scon, &JSDOMExceptionFactory::InvalidAccessException);
         return false;
     }
 
@@ -862,17 +946,26 @@ JSValueRef JSSensorConnection::addEventListener(JSContextRef ctx, JSObjectRef ob
     struct SensorConnection* scon = (struct SensorConnection*) JSObjectGetPrivate(thisObject);
     Converter converter(ctx);
 
-    if( argumentCount < 2 )
-        return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
+    ParamUtil param(ctx, argumentCount, arguments);
 
-    std::string typeStr = converter.toString(arguments[0]);
-    int type = detectListenerType(typeStr);
+    std::string typeStr;
 
+    if( !param.toString(0, &typeStr, exception) ) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+    int type = detectListenerType(typeStr);
     if(type < 0){
         return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
     }
 
-    addListener(ctx, scon, type, arguments[1]);
+    if(!param.isUndefined(1)) {
+        if(!param.isFunction(1)) {
+            return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+        }
+        JSValueRef listener = param.get(1);
+        addListener(ctx, scon, type, listener);
+    }
+
 
     return JSValueMakeUndefined(ctx);
 }
@@ -880,19 +973,26 @@ JSValueRef JSSensorConnection::addEventListener(JSContextRef ctx, JSObjectRef ob
 JSValueRef JSSensorConnection::removeEventListener(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
     struct SensorConnection* scon = (struct SensorConnection*) JSObjectGetPrivate(thisObject);
-    Converter converter(ctx);
 
-    if( argumentCount < 2 )
-        return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
+    ParamUtil param(ctx, argumentCount, arguments);
 
-    std::string typeStr = converter.toString(arguments[0]);
-    int type = detectListenerType(typeStr);
+    std::string typeStr;
 
+    if( !param.toString(0, &typeStr, exception) ) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+    int type = detectListenerType(typeStr);
     if(type < 0){
         return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
     }
 
-    removeListener(ctx, scon, type, arguments[1]);
+    if(!param.isUndefined(1)) {
+        if(!param.isFunction(1)) {
+            return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+        }
+        JSValueRef listener = param.get(1);
+        removeListener(ctx, scon, type, listener);
+    }
     return JSValueMakeUndefined(ctx);
 }
 
@@ -904,7 +1004,9 @@ JSValueRef JSSensorConnection::dispatchEvent(JSContextRef ctx, JSObjectRef objec
     if( argumentCount < 1 )
         return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
 
-    JSObjectRef event = JSValueToObject(ctx, arguments[0], NULL);
+    JSObjectRef event = JSValueToObject(ctx, arguments[0], exception);
+    if(event == NULL)
+        return JSValueMakeUndefined(ctx);
     JSStringRef jss_type = JSStringCreateWithUTF8CString("type");
     JSValueRef jsv_type = JSObjectGetProperty(ctx, event, jss_type, NULL);
     JSStringRelease(jss_type);
index c8efc3b..f02aba4 100644 (file)
@@ -23,6 +23,7 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
 #include "JSSensorDataEvent.h"
+#include "SensorType.h"
 
 #include <dlog.h>
 
@@ -40,19 +41,16 @@ namespace Tizen1_0 {
 static const char* DATA_ACCURACY[] = {
     "unreliable", "low", "medium", "high"
 };
-static const char* REASON[] = {
-    "read", "watch"
-};
 
 enum {
     PROPERTY_DATA,
     PROPERTY_ACCURACY,
     PROPERTY_TIMESTAMP,
-    PROPERTY_REASON,
+    PROPERTY_ISWATCHPOINT,
     PROPERTY_COUNT
 };
 
-static const char* PROPERTY_NAMES[] = {"data", "accuracy", "timestamp", "reason"};
+static const char* PROPERTY_NAMES[] = {"data", "accuracy", "timestamp", "isWatchPoint"};
 
 static int accuracy_map(sensor_data_accuracy_e accuracy) {
     switch(accuracy){
@@ -70,11 +68,9 @@ static int accuracy_map(sensor_data_accuracy_e accuracy) {
     return JSSENSOR_DATA_ACCURACY_UNDEFINED;
 }
 
-JSSensorDataEvent::JSSensorDataEvent (JSContextRef ctx, int reason, sensor_type_e type)
-    : mType(type), mAccuracy(0), mTimestamp(0), mCtx(ctx)
+JSSensorDataEvent::JSSensorDataEvent (JSContextRef ctx, bool isWatchPoint, sensor_type_e type)
+    : mType(type), mIsWatchPoint(isWatchPoint), mAccuracy(0), mTimestamp(0), mCtx(ctx)
 {
-    setReason(reason);
-
     mData = NULL;
 }
 JSSensorDataEvent::~JSSensorDataEvent()
@@ -138,6 +134,8 @@ void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp,
         case SENSOR_PROXIMITY:
             mData = JSValueMakeNumber(mCtx, x);
             break;
+        default:
+            break;
     }
     if(mData != NULL){
         JSValueProtect(mCtx, mData);
@@ -156,14 +154,9 @@ void JSSensorDataEvent::set (sensor_data_accuracy_e accuracy, double timestamp,
     JSValueProtect(mCtx, mData);
 }
 
-void JSSensorDataEvent::setReason(int reason)
+void JSSensorDataEvent::setWatchPoint(bool watchPoint)
 {
-    if(reason < JSSENSOR_REASON_READ || reason > JSSENSOR_REASON_WATCH){
-        mReason = JSSENSOR_REASON_UNDEFINED;
-    }
-    else{
-        mReason = reason;
-    }
+    mIsWatchPoint = watchPoint;
 }
 
 JSObjectRef JSSensorDataEvent::makeJSObj()
@@ -217,6 +210,7 @@ JSObjectRef JSSensorDataEvent::m_DOMEvent = NULL;
 
 void JSSensorDataEvent::initialize(JSContextRef ctx, JSObjectRef object) 
 {
+    JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(object);
     if(m_DOMEvent == NULL){
         JSStringRef scriptJS = JSStringCreateWithUTF8CString("return Event");
         JSObjectRef fn = JSObjectMakeFunction(ctx, NULL, 0, NULL, scriptJS, NULL, 1, NULL);
@@ -232,12 +226,14 @@ void JSSensorDataEvent::initialize(JSContextRef ctx, JSObjectRef object)
     JSValueRef args[] = {jsv_type};
     JSObjectRef domEvent = JSObjectCallAsConstructor(ctx, m_DOMEvent, 1, args, NULL);
 
-    JSObjectSetPrototype(ctx, object, domEvent);
+    eventData->event = domEvent;
+    JSValueProtect(ctx, eventData->event);
 }
 
 void JSSensorDataEvent::finalize(JSObjectRef object) 
 {
     JSSensorDataEvent* eventData = (JSSensorDataEvent*)JSObjectGetPrivate(object);
+
     if(eventData != NULL){
         delete eventData;
     }
@@ -267,18 +263,12 @@ JSValueRef JSSensorDataEvent::getProperty(JSContextRef ctx, JSObjectRef object,
     else if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[PROPERTY_TIMESTAMP])) {
         return convert.toJSValueRef(eventData->mTimestamp);
     }
-    else if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[PROPERTY_REASON])) {
-        if(eventData->mReason != JSSENSOR_REASON_UNDEFINED){
-//            return convert.toJSValueRef(REASON[eventData->mReason]);
-            JSStringRef rsStr = JSStringCreateWithUTF8CString(REASON[eventData->mReason]);
-            JSValueRef result = JSValueMakeString(ctx, rsStr);
-            JSStringRelease(rsStr);
-            return result;
-        }
-        else
-            return JSValueMakeUndefined(ctx);
+    else if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[PROPERTY_ISWATCHPOINT])) {
+        return JSValueMakeBoolean(ctx, eventData->mIsWatchPoint);
     }
 
+    if(JSObjectHasProperty(ctx, eventData->event, propertyName))
+        return JSObjectGetProperty(ctx, eventData->event, propertyName, exception);
     return NULL; 
 }
 
@@ -294,6 +284,11 @@ bool JSSensorDataEvent::setProperty(JSContextRef ctx, JSObjectRef object, JSStri
 
 bool JSSensorDataEvent::hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName)
 {
+    JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(object);
+    
+    if(JSObjectHasProperty(ctx, eventData->event, propertyName))
+        return true;
+    
     for(int i=0; i<PROPERTY_COUNT; i++){
         if(JSStringIsEqualToUTF8CString(propertyName, PROPERTY_NAMES[i])){
             return true;
@@ -304,70 +299,90 @@ bool JSSensorDataEvent::hasProperty(JSContextRef ctx, JSObjectRef object, JSStri
 }
 void JSSensorDataEvent::getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames)
 {
+    JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(object);
     for(int i=0; i<PROPERTY_COUNT; i++){
         JSStringRef pname = JSStringCreateWithUTF8CString(PROPERTY_NAMES[i]);
         JSPropertyNameAccumulatorAddName(propertyNames, pname);
         JSStringRelease(pname);
     }
+
+    JSPropertyNameArrayRef eventProperty = JSObjectCopyPropertyNames(ctx, eventData->event);
+    size_t len = JSPropertyNameArrayGetCount(eventProperty);
+    for(int i=0; i<len; i++){
+        JSStringRef epname = JSPropertyNameArrayGetNameAtIndex(eventProperty, i);
+        JSPropertyNameAccumulatorAddName(propertyNames, epname);
+        JSStringRelease(epname);
+    }
 }
 
 JSValueRef JSSensorDataEvent::initSensorDataEvent(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(object);
+    JSSensorDataEvent* eventData = (JSSensorDataEvent*) JSObjectGetPrivate(thisObject);
 
     if(eventData == NULL){
-        return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
+        return JSDOMExceptionFactory::InvalidAccessException.make(ctx, exception);
     }
 
-    if(argumentCount < 7){
-        // It will must be replace other error except DOMException
-        return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
+    ParamUtil param(ctx, argumentCount, arguments);
+
+    JSValueRef jsv_type = param.get(0);
+    JSValueRef jsv_bubbles = param.get(1);
+    JSValueRef jsv_cancelable = param.get(2);
+
+    JSObjectRef eventObj = eventData->event;
+
+    JSStringRef initEventStr = 
+        JSStringCreateWithUTF8CString(
+                "this.initEvent(a,b,c);");
+    JSStringRef arg1 = JSStringCreateWithUTF8CString("a");
+    JSStringRef arg2 = JSStringCreateWithUTF8CString("b");
+    JSStringRef arg3 = JSStringCreateWithUTF8CString("c");
+    JSStringRef argNames[] = {arg1, arg2, arg3};
+    JSObjectRef initEventFn = JSObjectMakeFunction(ctx, NULL, 3, argNames, initEventStr, NULL, 1, exception);
+    if(initEventFn == NULL) return JSValueMakeUndefined(ctx);
+    JSValueRef args[] = { jsv_type, jsv_bubbles, jsv_cancelable };
+    JSValueRef ret = JSObjectCallAsFunction(ctx, initEventFn, eventObj, 3, args, exception);
+    if(ret == NULL)
+        return JSValueMakeUndefined(ctx);
+
+    JSStringRelease(initEventStr);
+    JSStringRelease(arg1);
+    JSStringRelease(arg2);
+    JSStringRelease(arg3);
+
+
+    double timestamp = param.toNumber(4, exception);
+    if(isnan(timestamp))
+        return JSValueMakeUndefined(ctx);
+    eventData->mTimestamp = timestamp;
+
+    bool isWatchPoint = param.toBool(3, exception);
+    eventData->mIsWatchPoint = isWatchPoint;
+
+    std::string accuracy;
+    if( !param.toString(5, &accuracy, exception) ){
+        return JSValueMakeUndefined(ctx);
     }
-    JSValueRef jsv_type = arguments[0];
-    JSValueRef jsv_bubble = arguments[1];
-    JSValueRef jsv_cancelable = arguments[2];
-    JSValueRef jsv_reason = arguments[3];
-    JSValueRef jsv_timestamp = arguments[4];
-    JSValueRef jsv_accuracy = arguments[5];
-    JSValueRef jsv_data = arguments[6];
-
-    JSStringRef pname_type = JSStringCreateWithUTF8CString("type");
-    JSObjectSetProperty(ctx, object, pname_type, jsv_type, kJSPropertyAttributeNone, NULL);
-    JSStringRelease(pname_type);
-
-    JSStringRef pname_bubble = JSStringCreateWithUTF8CString("bubble");
-    JSObjectSetProperty(ctx, object, pname_bubble, jsv_bubble, kJSPropertyAttributeNone, NULL);
-    JSStringRelease(pname_bubble);
-
-    JSStringRef pname_cancelable = JSStringCreateWithUTF8CString("cancelable");
-    JSObjectSetProperty(ctx, object, pname_cancelable, jsv_cancelable, kJSPropertyAttributeNone, NULL);
-    JSStringRelease(pname_cancelable);
+    JSValueRef data = param.get(6);
 
-    Converter convert(ctx);
 
-    std::string reason = convert.toString(jsv_reason);
-    int r = JSSENSOR_REASON_UNDEFINED;
-    for(int i=0; i<JSSENSOR_REASON_COUNT; i++){
-        if(reason.compare(REASON[i]) == 0){
-            r = i;
-            break;
-        }
-    }
-    eventData->mReason = r;
-
-    eventData->mTimestamp = convert.toDouble(jsv_timestamp);
-    
-    std::string accuracy = convert.toString(jsv_accuracy);
+    bool isAccuracy = false;
     int a = JSSENSOR_DATA_ACCURACY_UNDEFINED;
     for(int i=0; i<JSSENSOR_DATA_ACCURACY_COUNT; i++){
         if(accuracy.compare(DATA_ACCURACY[i]) == 0){
             a = i;
+            isAccuracy = true;
             break;
         }
     }
+    if(!isAccuracy)
+        return JSDOMExceptionFactory::InvalidValuesException.make(ctx, exception);
     eventData->mAccuracy = a;
 
-    eventData->mData = jsv_data;
+    if(eventData->mData != NULL)
+        JSValueUnprotect(ctx, eventData->mData);
+    eventData->mData = data;
+    JSValueProtect(ctx, eventData->mData);
 
     return JSValueMakeUndefined(ctx);
 }
index 39a82a3..1590bcc 100644 (file)
@@ -51,13 +51,13 @@ public:
     static const JSClassDefinition* getClassInfo();
     static const JSClassRef getClassRef();
 
-    JSSensorDataEvent (JSContextRef ctx, int reason, sensor_type_e type);
+    JSSensorDataEvent (JSContextRef ctx, bool isWatchPoint, sensor_type_e type);
     ~JSSensorDataEvent();
                                                                                                   
     void set (sensor_data_accuracy_e accuracy, double timestamp, float x, float y, float z);
     void set (sensor_data_accuracy_e accuracy, double timestamp, float v);
 
-    void setReason(int reason);
+    void setWatchPoint(bool watchPoint);
 
     JSObjectRef makeJSObj();
 
@@ -72,7 +72,6 @@ protected:
     static bool setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
     static bool hasProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName);
     static void getPropertyNames(JSContextRef ctx, JSObjectRef object, JSPropertyNameAccumulatorRef propertyNames); 
-
        static JSValueRef initSensorDataEvent(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
 
 private:
@@ -86,7 +85,9 @@ private:
     sensor_type_e mType;
     int mAccuracy;
     double mTimestamp;
-    int mReason;
+    bool mIsWatchPoint;
+
+    JSObjectRef event;
 };
 
 } // Tizen1_0
diff --git a/src/standards/Tizen/Sensors/JSSensorError.cpp b/src/standards/Tizen/Sensors/JSSensorError.cpp
deleted file mode 100644 (file)
index 0a3d650..0000000
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Licensed under the Apache License, Version 2.0 (the License);
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an AS IS BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License. 
- */
-#include <vector>
-#include <CommonsJavaScript/Converter.h>
-#include <CommonsJavaScript/Validator.h>
-#include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
-#include "JSSensorError.h"
-
-#include <dlog.h>
-
-#undef LOG_TAG
-#define LOG_TAG "TIZEN_SENSOR"
-
-using namespace std;
-using namespace DPL;
-using namespace WrtDeviceApis::CommonsJavaScript;
-
-namespace TizenApis {
-namespace Tizen1_0 {
-
-struct MsgCode {
-    string msg;
-    int code;
-};
-
-JSClassRef JSSensorError::m_jsClassRef = NULL;
-
-JSClassDefinition JSSensorError::m_jsClassInfo = {
-               0,
-               kJSClassAttributeNone,
-               "SensorError",
-               NULL,
-               m_jsStaticProperties,
-        NULL,
-               initialize,
-               finalize,
-               NULL, //hasProperty,
-               JSSensorError::getProperty, //getProperty,
-               JSSensorError::setProperty, //setProperty,
-               NULL, //deleteProperty,Geolocation
-               NULL, //getPropertyNames,
-               NULL,
-               NULL, // constructor
-               hasInstance,
-               NULL
-};
-
-JSStaticValue JSSensorError::m_jsStaticProperties[] = {
-    {"PERMISSION_DENIED", JSSensorError::getStaticProperty, NULL, kJSPropertyAttributeReadOnly},
-    {"CONNECTION_ERROR", JSSensorError::getStaticProperty, NULL, kJSPropertyAttributeReadOnly},
-    {0, 0, 0, 0}
-};
-
-
-const JSClassRef JSSensorError::getClassRef() 
-{
-       if (!m_jsClassRef) {
-               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
-       }
-       return m_jsClassRef;
-}
-
-const JSClassDefinition* JSSensorError::getClassInfo() 
-{
-       return &m_jsClassInfo;
-}
-
-JSObjectRef JSSensorError::makeSensorError(JSContextRef ctx, const char* message, unsigned short code)
-{
-    struct MsgCode* msgcode = new MsgCode;
-    msgcode->msg = message;
-    msgcode->code = code;
-
-    JSObjectRef errorObj = JSObjectMake(ctx, getClassRef(), (void*)msgcode);
-
-    return errorObj;
-}
-
-void JSSensorError::initialize(JSContextRef ctx, JSObjectRef object) 
-{
-}
-
-void JSSensorError::finalize(JSObjectRef object) 
-{
-}
-
-bool JSSensorError::hasInstance(JSContextRef ctx, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-       return JSValueIsObjectOfClass(ctx, possibleInstance, getClassRef());
-}
-
-JSValueRef JSSensorError::getProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
-{
-    struct MsgCode* msgcode = (struct MsgCode*) JSObjectGetPrivate(object);
-    if(msgcode == NULL){
-        return JSValueMakeNull(ctx);
-    }
-
-    if(JSStringIsEqualToUTF8CString(propertyName, "message")) {
-        JSStringRef msg = JSStringCreateWithUTF8CString(msgcode->msg.c_str());
-        JSValueRef msgVal = JSValueMakeString(ctx, msg);
-        JSStringRelease(msg);
-        return msgVal;
-    }
-    else if(JSStringIsEqualToUTF8CString(propertyName, "code")) {
-        JSValueRef msgVal = JSValueMakeNumber(ctx, msgcode->code);
-        return msgVal;
-    }
-
-    return NULL;
-}
-
-bool JSSensorError::setProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef value, JSValueRef* exception)
-{
-    // return true for read only
-    if(JSStringIsEqualToUTF8CString(propertyName, "message")) {
-        return true;
-    }
-    else if(JSStringIsEqualToUTF8CString(propertyName, "code")) {
-        return true;
-    }
-
-    return false; 
-}
-
-JSValueRef JSSensorError::getStaticProperty(JSContextRef ctx, JSObjectRef object, JSStringRef propertyName, JSValueRef* exception)
-{
-    if(JSStringIsEqualToUTF8CString(propertyName, "PERMISSION_DENIED")) {
-        return JSValueMakeNumber(ctx, PERMISSION_DENIED);
-    }
-    else if(JSStringIsEqualToUTF8CString(propertyName, "CONNECTION_ERROR")) {
-        return JSValueMakeNumber(ctx, PERMISSION_DENIED);
-    }
-    return JSValueMakeNull(ctx);
-}
-
-} // Tizen1_0
-} // TizenApis
index 0475d04..48bf782 100644 (file)
@@ -91,11 +91,17 @@ JSValueRef JSSensorManager::findSensors(JSContextRef ctx, JSObjectRef object, JS
 {
     char type[30];
     JSObjectRef request = NULL;
-    if(argumentCount > 0 && JSValueIsString(ctx, arguments[0])){
-        JSStringRef jss_type = JSValueToStringCopy(ctx, arguments[0], NULL);
-        JSStringGetUTF8CString(jss_type, type, 30);
-        JSStringRelease(jss_type);
-        request = JSSensorRequest::makeSensorRequest(ctx, type);
+
+    if(argumentCount > 0) {
+        if(JSValueIsString(ctx, arguments[0])){
+            JSStringRef jss_type = JSValueToStringCopy(ctx, arguments[0], NULL);
+            JSStringGetUTF8CString(jss_type, type, 30);
+            JSStringRelease(jss_type);
+            request = JSSensorRequest::makeSensorRequest(ctx, type);
+        }
+        else {
+            return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+        }
     }
     else{
         request = JSSensorRequest::makeSensorRequest(ctx, NULL);
index ffacff5..966a0db 100644 (file)
@@ -59,11 +59,11 @@ JSClassDefinition JSSensorRequest::m_jsClassInfo = {
 
 struct ResultSet {
     JSObjectRef sensors;
-    JSObjectRef error;
     JSValueRef onsuccess;
     JSValueRef onerror;
     char* type;
     bool done;
+    int error;
 };
 
 const JSClassRef JSSensorRequest::getClassRef() 
@@ -107,7 +107,7 @@ static gboolean afterProcess(gpointer user_data)
     result->sensors = sensorArray;
     result->done = true;
 
-    if(JSValueIsObject(ctx, onsuccess)){
+    if(onsuccess != NULL && JSValueIsObject(ctx, onsuccess)){
         JSObjectRef successFunc = JSValueToObject(ctx, onsuccess, NULL);
         JSObjectCallAsFunction(ctx, successFunc, sensorRequest, 0, NULL, NULL);
     }
@@ -129,6 +129,8 @@ JSObjectRef JSSensorRequest::makeSensorRequest(JSContextRef ctx, const char* typ
         result->type = NULL;
 
     result->done = false;
+    result->onsuccess = NULL;
+    result->onerror = NULL;
 
     g_idle_add_full(G_PRIORITY_HIGH_IDLE, afterProcess, sensorRequest, NULL); 
 
@@ -172,7 +174,7 @@ JSValueRef JSSensorRequest::getProperty(JSContextRef ctx, JSObjectRef object, JS
         if(!result->done){
             return JSDOMExceptionFactory::InvalidStateException.make(ctx, exception);
         }else{
-            return result->error;
+            return JSValueMakeNull(ctx);
         }
     }
     else if(JSStringIsEqualToUTF8CString(propertyName, "readyState")) {
index fdeb3f6..c0f3fb2 100644 (file)
@@ -16,6 +16,8 @@
 #include "SensorType.h"
 #include <sensors.h>
 #include "JSSensor.h"
+#include <limits>
+#include <cmath>
 
 using namespace std;
 
@@ -220,10 +222,95 @@ JSObjectRef SensorTypeUtil::getSensorArray(JSContextRef ctx, const char* type)
 
     JSObjectRef sensorArray = JSObjectMakeArray(ctx, scount, ss, NULL);
     if(ss != NULL)
-        delete ss;
+        delete[] ss;
 
     return sensorArray;
 }
 
+ParamUtil::ParamUtil(JSContextRef ctx, int length, const JSValueRef arguments[]):
+    mCtx(ctx), mLength(length), mArguments(arguments)
+{
+}
+
+double ParamUtil::toNumber(int index, JSValueRef* exception)
+{
+    JSValueRef value = NULL;
+    if (index < mLength) {
+        value = mArguments[index];
+    }else {
+        return std::numeric_limits<double>::quiet_NaN();
+    }
+    return JSValueToNumber(mCtx, value, exception);
+}
+
+bool ParamUtil::toString(int index, std::string* out, JSValueRef* exception)
+{
+    JSValueRef value = NULL;
+    if (index < mLength) {
+        value = mArguments[index];
+    }else {
+        *out = "undefined";
+        return true;
+    }
+    JSStringRef str = JSValueToStringCopy(mCtx, value, exception);
+    if(str == NULL)
+        return false;
+
+    size_t jsStrSize = JSStringGetMaximumUTF8CStringSize(str);
+    if(jsStrSize>0) {
+        jsStrSize = jsStrSize + 1;
+        char* buffer = new char[jsStrSize];
+        size_t written = JSStringGetUTF8CString(str, buffer, jsStrSize);
+        if(written > jsStrSize) {
+            JSStringRelease(str);
+            delete[] buffer;
+            return false;
+        }
+        *out = buffer;
+        delete[] buffer;
+    }
+    JSStringRelease(str);
+    return true;
+}
+
+
+bool ParamUtil::toBool(int index, JSValueRef* exception)
+{
+    JSValueRef value = NULL;
+    if (index < mLength) {
+        value = mArguments[index];
+    }else {
+        return false;
+    }
+
+    return JSValueToBoolean(mCtx, value);
+}
+
+bool ParamUtil::isUndefined(int index)
+{
+    return !(index < mLength && JSValueGetType(mCtx, mArguments[index]) != kJSTypeUndefined);
+}
+
+bool ParamUtil::isFunction(int index)
+{
+    if(index >= mLength)
+        return false;
+
+    if(JSValueIsObject(mCtx, mArguments[index])) {
+        JSObjectRef o = JSValueToObject(mCtx, mArguments[index], NULL);
+        return JSObjectIsFunction(mCtx, o);
+    }
+    return false;
+}
+
+JSValueRef ParamUtil::get(int index)
+{
+    if(index < mLength){
+        return mArguments[index];
+    }else {
+        return JSValueMakeUndefined(mCtx);
+    }
+}
+
 } // Tizen1_0
 } // TizenApis
index 99e86c8..a83eddb 100644 (file)
 namespace TizenApis {
 namespace Tizen1_0 {
 
+enum {
+    TIZEN_SENSOR_ERROR_PERMISSION_DENIED,
+    TIZEN_SENSOR_ERROR_INVALID_STATE
+};
+
 class SensorTypeUtil
 {
     public:
@@ -70,6 +75,25 @@ class SensorTypeUtil
         std::vector<JSValueRef> sensors;
 };
 
+class ParamUtil {
+    public:
+        ParamUtil(JSContextRef ctx, int length, const JSValueRef arguments[]);
+        double toNumber(int index, JSValueRef* exception);
+        bool toString(int index, std::string* out, JSValueRef* exception);
+        bool toBool(int index, JSValueRef* exception);
+
+        JSValueRef get(int index);
+
+        bool isUndefined(int index);
+        bool isFunction(int index);
+
+
+    private:
+        JSContextRef mCtx;
+        const JSValueRef* mArguments;
+        int mLength;
+};
+
 } // Tizen1_0
 } // TizenApis
 
index 2a5c6e0..4d8d80f 100644 (file)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
+
 /**
 * @file                 Plugin_initializer.cpp
 * @author       Pius Lee (pius.lee@samsung.com)
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <Commons/Exception.h>
 #include "JSSensorManager.h"
 #include "JSSensorConnection.h"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId) {
     LogDebug("[Tizen\\Sensors ] on_widget_start_callback ("<<widgetId<<")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(widgetId,context,interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("[Tizen\\Sensors] Wrt wrapper registration failed");
+        LogError("[Tizen\\Sensors] WrtAccess initialization failed");
     }
 }
 
@@ -44,11 +47,11 @@ void on_widget_stop_callback(int widgetId) {
     LogDebug("[Tizen\\Sensors] on_widget_stop_callback ("<<widgetId<<")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogError("[Tizen\\Sensors] Wrt wrapper removal failed");
+        LogError("[Tizen\\Sensors] WrtAccess deinitialization failed");
     }
 }
 
@@ -56,9 +59,9 @@ PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
 PLUGIN_CLASS_MAP_BEGIN
-PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "sensors", 
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "sensors",
       TizenApis::Tizen1_0::JSSensorManager::getClassRef(),NULL)
-PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "SensorConnection", 
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "SensorConnection",
       TizenApis::Tizen1_0::JSSensorConnection::getClassRef(),NULL)
 PLUGIN_CLASS_MAP_END
 
old mode 100755 (executable)
new mode 100644 (file)
index 9ba7642..20e7236
@@ -32,7 +32,7 @@ const char* CELLULARNETWORK_APN_PROPERTY = "apn";
 const char* CELLULARNETWORK_IPADDRESS_PROPERTY = "ipAddress";
 const char* CELLULARNETWORK_MCC_PROPERTY = "mcc";
 const char* CELLULARNETWORK_MNC_PROPERTY = "mnc";
-const char* CELLULARNETWORK_CELLID_PROPERTY = "cellid";
+const char* CELLULARNETWORK_CELLID_PROPERTY = "cellId";
 const char* CELLULARNETWORK_LAC_PROPERTY = "lac";
 const char* CELLULARNETWORK_SERVICETYPE_PROPERTY = "serviceType";
 const char* CELLULARNETWORK_ROAMING_PROPERTY = "isRoaming";
@@ -138,7 +138,7 @@ JSValueRef JSCellularNetworkInfo::getProperty(JSContextRef context, JSObjectRef
         } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_MNC_PROPERTY)) {
             return convert.toJSValueRef(cellularNetworkInfo->mnc);            
         } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_CELLID_PROPERTY)) {
-            return convert.toJSValueRef(cellularNetworkInfo->cellid);            
+            return convert.toJSValueRef(cellularNetworkInfo->cellId);            
         } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_LAC_PROPERTY)) {
             return convert.toJSValueRef(cellularNetworkInfo->lac);            
         } else if (JSStringIsEqualToUTF8CString(propertyName, CELLULARNETWORK_SERVICETYPE_PROPERTY)) {
index d41b654..fe0b251 100644 (file)
@@ -89,7 +89,6 @@ JSClassRef JSSysteminfo::m_jsClassRef = JSClassCreate(JSSysteminfo::getClassInfo
 void JSSysteminfo::initialize(JSContextRef context, JSObjectRef object)
 {
     JSSysteminfoPriv* priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(object));
-    assert(!priv && "Invalid object creation.");
     ISysteminfoPtr Systeminfos(SysteminfoFactory::getInstance().getSysteminfos());
     priv = new JSSysteminfoPriv(context, Systeminfos);
     if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
@@ -114,35 +113,39 @@ JSValueRef JSSysteminfo::isSupported(JSContextRef context, JSObjectRef object, J
 {
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_IS_SUPPORTED);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(SYSTEMINFO_FUNCTION_API_IS_SUPPORTED);
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Converter converter(context);
     Validator check(context, exception);
-    
-    if (argumentCount > 1 || argumentCount == 0) {
-        LogError("argument count is not correct");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
-    }
 
+    if (!priv) {
+        LogError("private object is null");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+    }
     Try
     {
         ISysteminfoPtr Systeminfos(priv->getObject());
 
         bool retVal;
-        retVal = Systeminfos->isPropertyValid(priv->getContext(), arguments[0]);
+        
+        if (argumentCount == 0) {
+            retVal = Systeminfos->isPropertyValid(priv->getContext(), JSValueMakeUndefined(context));
+        } else {
+            retVal = Systeminfos->isPropertyValid(priv->getContext(), arguments[0]);        
+        }
 
         return converter.toJSValueRef(retVal);
     }
-
-    Catch(ConversionException) {
-        LogError("Error on conversion");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+    Catch(WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
     }
-    Catch(InvalidArgumentException) {
-        LogError("JSSysteminfo::get InvalidArgumentException");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter");
+    Catch(WrtDeviceApis::Commons::InvalidArgumentException){
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
     }
+    Catch(WrtDeviceApis::Commons::Exception) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+    }    
 
     return JSValueMakeUndefined(context);
 }
@@ -152,85 +155,65 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
 {
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_GET_PROPERTY_VALUE);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-    
+    AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(
+        SYSTEMINFO_FUNCTION_API_GET_PROPERTY_VALUE);
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
     Converter converter(context);
     Validator check(context, exception);
+    std::string property;
+    JSValueRef errorCallback;
 
     if (!priv) {
         LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "unknown error");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
     }
-
-    if (argumentCount == 0 || argumentCount > 4) {
-        LogError("argument count is not correct");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+    if (argumentCount < 2) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
-
-    if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !check.isCallback(arguments[1])) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-    }
-    
-    if (argumentCount > 2) {
-        if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !check.isCallback(arguments[2])) {
-            LogError("wrong argument");
-            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-        }
+    if (!check.isCallback(arguments[1])) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
 
     JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-    if (check.isCallback(arguments[1])) {
-        onSuccessForCbm = arguments[1];
-    }
-    if (argumentCount > 2) {
+    onSuccessForCbm = arguments[1];
+    if (argumentCount == 3) {
         if (check.isCallback(arguments[2])) {
             onErrorForCbm = arguments[2];
+        } else if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
         }
     }
     
     JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, onErrorForCbm, true, true));
-
+    JSValueProtect(priv->getContext(), thisObject);
 
     Try {
-        if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
-            || JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) {
-            LogError("successCallback parameter is JSNull/JSUndefined");
-            Throw(InvalidArgumentException);
-        }
-        
         ISysteminfoPtr Systeminfos(priv->getObject());
         
         EventGetSysteminfoPtr event(new EventGetSysteminfo());
-        
         event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]));
         event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
 
         SysteminfoListener& listener = SysteminfoListener::getInstance();
         event->setForAsynchronousCall(&listener);
 
-        JSObjectRef pendingOperation = makePendingOperation(context, event);
         Systeminfos->get(event);
-        
-        return pendingOperation;
+
+        return JSValueMakeUndefined(context);
     }
     
-    Catch(PendingOperationException) {
-        LogError("JSSysteminfo::get PendingOperationException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
+    Catch(WrtDeviceApis::Commons::PendingOperationException) {
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown error"));
     }
-    Catch(ConversionException) {
-        LogError("JSSysteminfo::get ConversionException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"));
+    Catch(WrtDeviceApis::Commons::ConversionException) {
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error"));
     }
-    Catch(InvalidArgumentException) {
-        LogError("JSSysteminfo::get InvalidArgumentException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
+    Catch(WrtDeviceApis::Commons::InvalidArgumentException){
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
     }
     Catch(WrtDeviceApis::Commons::Exception) {
-        LogError("JSSysteminfo::get Exception");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknown error"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown error"));
     }
     return JSValueMakeUndefined(context);
 }
@@ -238,68 +221,56 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
 JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
         size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    LogDebug("enter");
-    JSValueRef property = NULL;
+    JSValueRef propertyId = NULL;
     WatchOption option;
-    int failId = -1;    
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+    AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(
+        SYSTEMINFO_FUNCTION_API_ADD_PROPERTY_VALUE_CHANGE_LISTENER);
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
     Converter converter(context);
     Validator check(context, exception);
 
     if (!priv) {
         LogError("private object is null");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "unknown error");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
     }
-
-    if (argumentCount == 0 || argumentCount > 4) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+    if (argumentCount < 2) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
-
-    if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !check.isCallback(arguments[1])) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+    if (!check.isCallback(arguments[1])) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
-
-    if (argumentCount > 2) {
-        if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2]) && !check.isCallback(arguments[2])) {
-            LogError("wrong argument");
-            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-        }
-    }
-
+    
     JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-    if (check.isCallback(arguments[1])) {
-        onSuccessForCbm = arguments[1];
-    }
+    onSuccessForCbm = arguments[1];
     if (argumentCount > 2) {
         if (check.isCallback(arguments[2])) {
             onErrorForCbm = arguments[2];
+        } else if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
+            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
         }
     }
+
     JSCallbackManagerPtr cbm(JSCallbackManager::createObject(priv->getContext(), onSuccessForCbm, onErrorForCbm, true, true));
+    JSValueProtect(priv->getContext(), thisObject);
 
     Try {
-        if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
-            || JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1])) {
-            LogError("successCallback parameter is JSNull/JSUndefined");
-            Throw(InvalidArgumentException);
-        }
-        property = arguments[0];
-        if (argumentCount > 3 && JSValueIsObject(context, arguments[3])) {
-            option.timeout = converter.toULong(JSUtils::getJSProperty(context, arguments[3], "timeout", exception));
-            option.highThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[3], "highThreshold", exception));
-            option.lowThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[3], "lowThreshold", exception));
+        if (argumentCount > 3) {
+            if (JSValueIsObject(context, arguments[3])) {
+                option.timeout = converter.toULong(JSUtils::getJSProperty(context, arguments[3], "timeout", exception));
+                option.highThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[3], "highThreshold", exception));
+                option.lowThreshold = converter.toDouble(JSUtils::getJSProperty(context, arguments[3], "lowThreshold", exception));
+            } else if (!JSValueIsNull(context, arguments[3]) && !JSValueIsUndefined(context, arguments[3])) {
+                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");        
+            }
         }
         ISysteminfoPtr Systeminfos(priv->getObject());
 
         EventWatchSysteminfoPtr event(new EventWatchSysteminfo);
         event->setWatchOption(option);
-        event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), property));
+        event->setBasePropertyPtr(Systeminfos->getBasePropertyPtr(priv->getContext(), arguments[0]));
         event->setPrivateData(StaticPointerCast<IEventPrivateData>(cbm));
 
         SysteminfoListener& listener = SysteminfoListener::getInstance();
@@ -308,64 +279,56 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
         Systeminfos->watch(event);
         LogDebug("event->getId()" << event->getId());
         return converter.toJSValueRef(event->getId());
-        }
-    
-    Catch(PendingOperationException) {
-        LogError("JSSysteminfo::get PendingOperationException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
     }
-    Catch(ConversionException) {
-        LogError("JSSysteminfo::get ConversionException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"));
+
+    Catch(WrtDeviceApis::Commons::ConversionException) {
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
     }
-    Catch(InvalidArgumentException) {
-        LogError("JSSysteminfo::get InvalidArgumentException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
+    Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error"));
     }
     Catch(WrtDeviceApis::Commons::Exception) {
-        LogError("JSSysteminfo::get Exception");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknown error"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown error"));
     }
+    
     return JSValueMakeUndefined(context);    
 }
 
 JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
         size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
 {
-    int id = 0;
+    long id = 0;
     JSSysteminfoPriv *priv = static_cast<JSSysteminfoPriv*>(JSObjectGetPrivate(thisObject));    
 
-       AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(priv->getContext(),SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-    
-    Converter converter(context);
+    AceSecurityStatus status = SYSTEMINFO_CHECK_ACCESS(
+        SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER);
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    if (argumentCount == 0 || argumentCount > 1) {
-        LogError("argument count is not correct");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
-    } else if (!JSValueIsNumber(context, arguments[0])) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+    Converter converter(context);
+    if (!priv) {
+        LogError("private object is null");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Wrong Object");
+    }
+    if (argumentCount < 1) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
     }
 
     Try {
-               if (!priv) {
-                       ThrowMsg(NullPointerException, "No private object");
-               }
         ISysteminfoPtr Systeminfos(priv->getObject());
+        id = static_cast<long>(converter.toLong(arguments[0]));
 
-               if (argumentCount == 1) {
-                       id = static_cast<int>(converter.toInt(arguments[0]));
-               }
                LogDebug("clearWatch id = " << id );
                Systeminfos->clearWatch(id);
                return JSValueMakeUndefined(context);
        }
-       Catch (InvalidArgumentException) {
-       LogError("JSSysteminfo::get InvalidArgumentException");
-       }
-       Catch (WrtDeviceApis::Commons::Exception) {
-        LogError("JSSysteminfo::get Exception");
+    Catch(WrtDeviceApis::Commons::ConversionException) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type missmatch error");
+    }    
+    Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
+    }
+    Catch(WrtDeviceApis::Commons::Exception) {
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");        
     }
 
     return JSValueMakeUndefined(context);
index 20260f5..732fcbc 100755 (executable)
@@ -29,12 +29,11 @@ extern const char* SYSTEMINFO_FUNCTION_API_REMOVE_PROPERTY_VALUE_CHANGE_LISTENER
 
 DECLARE_FUNCTION_GETTER(Systeminfo);
 
-#define SYSTEMINFO_CHECK_ACCESS(globalContext, functionName)               \
+#define SYSTEMINFO_CHECK_ACCESS(functionName)               \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(             \
-                                            globalContext,                 \
                                             getSysteminfoFunctionData,     \
                                             functionName)
 }
 }
 
-#endif
\ No newline at end of file
+#endif
index c036d88..eb11209 100755 (executable)
@@ -1,35 +1,56 @@
 /*
  *
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved 
- * 
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
- *  
+ *
  */
+
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
+#include <Commons/WrtAccess/WrtAccess.h>
+
 #include "JSSysteminfo.h"
 
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\Systeminfo ] on_widget_start_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().initialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess initialization failed");
+    }    
 }
 
 void on_widget_stop_callback(int widgetId)
 {
     LogDebug("[Tizen\\Systeminfo ] on_widget_stop_callback (" << widgetId << ")");
+    Try
+    {
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("WrtAccess deinitialization failed");
+    }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
index efd2910..a25915d 100755 (executable)
@@ -229,82 +229,58 @@ JSObjectRef JSTZDate::constructor(JSContextRef ctx, JSObjectRef constructor, siz
        TZDatePrivObject* mainPriv = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(constructor));
        JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
        Try {
-               if (argumentCount > 8) {
-                       LogError("Wrong argument count");
-                       ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
-               }
-
                if (argumentCount == 0) {
-                       return createJSObject(global_context);
+                       return createJSObject(ctx);
                } else if (argumentCount <= 2) {
-                       if (!JSValueIsUndefined(ctx, arguments[0])) {
-                               std::string timezone = "";
-                               if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1])) {
-                                       if (JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1]))
-                                               ThrowMsg(ConversionException, "Argument is invalid");
-                                       timezone = converter.toString(arguments[1]);
-                               }
+                       std::string timezone = "";
+                       if ((argumentCount == 2) && !JSValueIsNull(ctx, arguments[1]) && !JSValueIsUndefined(ctx, arguments[1])) {
+                               timezone = converter.toString(arguments[1]);
+                       }
 
-                               if (JSValueIsNull(ctx, arguments[0]))
-                                       return createJSObject(global_context, timezone);
-                               
-                               std::time_t date;
-                               date = converter.toDateTimeT(arguments[0]);
-                               long msec = 0;
-                              JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
-                               JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
-                               JSStringRelease(getMillisecondsName);
-                               if (getMiliSecFuction) {
-                                       JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
-                                       JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
-                                       msec = converter.toLong(result);
-                                       LogDebug("getMilliseconds = " << msec);
-                                       return createJSObject(global_context, date, msec, timezone);
-                               }
-                               return createJSObject(global_context, date, timezone);
+                       if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]))
+                               return createJSObject(ctx, timezone);
+                       
+                       std::time_t date;
+                       date = converter.toDateTimeT(arguments[0]);
+                       long msec = 0;
+                      JSStringRef getMillisecondsName = JSStringCreateWithUTF8CString("getMilliseconds");
+                       JSValueRef getMiliSecFuction = JSObjectGetProperty(ctx, converter.toJSObjectRef(arguments[0]), getMillisecondsName, exception);
+                       JSStringRelease(getMillisecondsName);
+                       if (getMiliSecFuction) {
+                               JSObjectRef function = JSValueToObject(ctx, getMiliSecFuction, exception);
+                               JSValueRef result = JSObjectCallAsFunction(ctx, function, converter.toJSObjectRef(arguments[0]), 0, NULL, exception);
+                               msec = converter.toLong(result);
+                               LogDebug("getMilliseconds = " << msec);
+                               return createJSObject(ctx, date, msec, timezone);
                        }
+                       return createJSObject(ctx, date, timezone);
+
                } else {
-                       prop.year = converter.FromJSValueReftolong(arguments[0]);
-                       prop.month = converter.FromJSValueReftolong(arguments[1]);
-                       prop.day = converter.FromJSValueReftolong(arguments[2]);
+                       prop.year = converter.toLong(arguments[0]);
+                       prop.month = converter.toLong(arguments[1]);
+                       prop.day = converter.toLong(arguments[2]);
                        if (argumentCount > 3) {
-                               if (JSValueIsUndefined(ctx, arguments[3]) || !(JSValueIsNumber(ctx, arguments[3]))) {
-                                       ThrowMsg(ConversionException, "Argument is invalid");
-                               }
-                               if (!JSValueIsNull(ctx, arguments[3]))
-                                       prop.hours = converter.FromJSValueReftolong(arguments[3]);
+                               if (!JSValueIsUndefined(ctx, arguments[3]) && !JSValueIsNull(ctx, arguments[3]))
+                                       prop.hours = converter.toLong(arguments[3]);
                                if (argumentCount > 4) {
-                                       if (JSValueIsUndefined(ctx, arguments[4]) || !JSValueIsNumber(ctx, arguments[4])) {
-                                               ThrowMsg(ConversionException, "Argument is invalid");
-                                       }
-                                       if (!JSValueIsNull(ctx, arguments[4]))
+                                       if (!JSValueIsUndefined(ctx, arguments[4]) && !JSValueIsNull(ctx, arguments[4]))
                                                prop.minutes = converter.FromJSValueReftolong(arguments[4]);
                                        if (argumentCount > 5) {
-                                               if (JSValueIsUndefined(ctx, arguments[5]) || !JSValueIsNumber(ctx, arguments[5])) {
-                                                       ThrowMsg(ConversionException, "Argument is invalid");
-                                               }
-                                               if (!JSValueIsNull(ctx, arguments[5]))
+                                               if (!JSValueIsUndefined(ctx, arguments[5]) && !JSValueIsNull(ctx, arguments[5]))
                                                        prop.seconds = converter.FromJSValueReftolong(arguments[5]);
                                                if (argumentCount > 6) {
-                                                       if (JSValueIsUndefined(ctx, arguments[6]) || !JSValueIsNumber(ctx, arguments[6])) {
-                                                               ThrowMsg(ConversionException, "Argument is invalid");
-                                                       }
-                                                       if (!JSValueIsNull(ctx, arguments[6]))
+                                                       if (!JSValueIsUndefined(ctx, arguments[6]) && !JSValueIsNull(ctx, arguments[6]))
                                                                prop.milliseconds= converter.FromJSValueReftolong(arguments[6]);
                                                        if (argumentCount > 7) {
-                                                               if (JSValueIsUndefined(ctx, arguments[7]) ||  !JSValueIsString(ctx, arguments[7])) {
-                                                                       ThrowMsg(ConversionException, "Argument is invalid");
-                                                               }
-                                                               if (!JSValueIsNull(ctx, arguments[7]))
+                                                               if (!JSValueIsUndefined(ctx, arguments[7]) && !JSValueIsNull(ctx, arguments[7]))
                                                                        prop.timezone = converter.toString(arguments[7]);
                                                        }
                                                }
                                        }
                                }
                        }
-                       return createJSObject(global_context, prop);
+                       return createJSObject(ctx, prop);
                }
-               ThrowMsg(InvalidArgumentException, "Wrong TZDate argumentCount");
        } Catch(ConversionException) {
                LogDebug("Wrong conversion");
                *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -351,10 +327,9 @@ JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
        LogDebug("entered");
 
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -362,11 +337,6 @@ JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ITZDatePtr TZDate(privateObject->getObject());
                std::string timezone = TZDate->getTimezone();
                TimeUtilConverter converter(context);
@@ -374,7 +344,7 @@ JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRef(timezone);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -393,19 +363,17 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
 
-       TimeUtilConverter converter(context);
-
        Try {
-               if (argumentCount != 1) {
-                       LogError("Wrong TZDate parameters count");
-                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
-                       || !JSValueIsString(context, arguments[0])) {
-                       LogError("Wrong TZDate parameters");
-                       ThrowMsg(ConversionException, "Wrong TZDate parameters");
-               }
+               TimeUtilConverter converter(context);
+               std::string timezone;
+               if (argumentCount < 1)
+                       timezone = converter.toString(JSValueMakeUndefined(context));
+               else
+                       timezone = converter.toString(arguments[0]);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -413,17 +381,11 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               std::string timezone = converter.toString(arguments[0]);
                ITZDatePtr TZDate(privateObject->getObject());
-               return createJSObject(privateObject->getContext(), TZDate->toTimezone(timezone));
+               return createJSObject(context, TZDate->toTimezone(timezone));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -444,30 +406,22 @@ JSValueRef JSTZDate::toTimezone(JSContextRef context, JSObjectRef function,
 JSValueRef JSTZDate::diffTZDate(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
        LogDebug("entered");
 
-       TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
-       if (!privateObject) {
-               LogError("Private object is not set.");
-               ThrowMsg(NullPointerException, "Private object not initialized");
-       }
-
        AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-               privateObject->getContext(),
                TIMEUTIL_FUNCTION_API_READ_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       TimeUtilConverter converter(context);
-
-       if (argumentCount != 1) {
-               LogError("Wrong TZDate parameters count");
-               ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
-       }
-
-       if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
+       if ((argumentCount < 1) || JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])
                || !JSValueIsObjectOfClass(context, arguments[0], getClassRef())) {
                LogError("Wrong TZDate parameters");
                ThrowMsg(ConversionException, "Wrong TZDate parameters");
        }
 
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("Private object is not set.");
+               ThrowMsg(NullPointerException, "Private object not initialized");
+       }
+       TimeUtilConverter converter(context);
        ITZDatePtr TZDate(privateObject->getObject());
        long long cmpResult = TZDate->difference(converter.getPropertiesInTZDate(arguments[0]));
 
@@ -510,7 +464,7 @@ JSValueRef JSTZDate::difference(JSContextRef context, JSObjectRef function,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -533,7 +487,7 @@ JSValueRef JSTZDate::equalsTo(JSContextRef context, JSObjectRef function,
                return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EQUALSTO);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -558,7 +512,7 @@ JSValueRef JSTZDate::earlierThan(JSContextRef context, JSObjectRef function,
                return diffTZDate(context, thisObject, argumentCount,  arguments, exception, EARLIERTHAN);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -585,7 +539,7 @@ JSValueRef JSTZDate::laterThan(JSContextRef context, JSObjectRef function,
                return diffTZDate(context, thisObject, argumentCount,  arguments, exception, LATERTHAN);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -608,10 +562,17 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
 
        LogDebug("addDuration entered");
        Try {
-               if (argumentCount != 1) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               TimeUtilConverter converter(context);
+
+               DurationProperties duration;
+               if (argumentCount == 0)
+                       duration= converter.getDurationPropertis(JSValueMakeUndefined(context));
+               else
+                       duration= converter.getDurationPropertis(arguments[0]);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -619,21 +580,12 @@ JSValueRef JSTZDate::addDuration(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               TimeUtilConverter converter(context);
-
-               DurationProperties duration = converter.getDurationPropertis(arguments[0]);
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ITZDatePtr TZDate(privateObject->getObject());
                TZDateProperties result = TZDate->addDuration(duration);
-               return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
+               return (static_cast<JSValueRef>(createJSObject(context, result)));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -655,10 +607,9 @@ JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
 
        LogDebug("toUTC entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -666,17 +617,12 @@ JSValueRef JSTZDate::toUTC(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ITZDatePtr TZDate(privateObject->getObject());
                TZDateProperties result = TZDate->toUTC();
-               return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
+               return (static_cast<JSValueRef>(createJSObject(context, result)));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -696,10 +642,9 @@ JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
 
        LogDebug("toLocalTimezone entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -707,17 +652,12 @@ JSValueRef JSTZDate::toLocalTimezone(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ITZDatePtr TZDate(privateObject->getObject());
                TZDateProperties result = TZDate->toLocalTimezone();
-               return (static_cast<JSValueRef>(createJSObject(privateObject->getContext(), result)));
+               return (static_cast<JSValueRef>(createJSObject(context, result)));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -735,10 +675,9 @@ JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef functi
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -746,11 +685,6 @@ JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef functi
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -758,7 +692,7 @@ JSValueRef JSTZDate::toLocaleDateString(JSContextRef context, JSObjectRef functi
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -777,10 +711,9 @@ JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef functi
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -788,11 +721,6 @@ JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef functi
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -800,7 +728,7 @@ JSValueRef JSTZDate::toLocaleTimeString(JSContextRef context, JSObjectRef functi
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -819,10 +747,9 @@ JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -830,11 +757,6 @@ JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -842,7 +764,7 @@ JSValueRef JSTZDate::toLocaleString(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -861,10 +783,9 @@ JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -872,11 +793,6 @@ JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -884,7 +800,7 @@ JSValueRef JSTZDate::toDateString(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -903,10 +819,9 @@ JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -914,11 +829,6 @@ JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -926,7 +836,7 @@ JSValueRef JSTZDate::toTimeString(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -946,10 +856,9 @@ JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -957,11 +866,6 @@ JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -969,7 +873,7 @@ JSValueRef JSTZDate::toString(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRef(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1050,23 +954,17 @@ JSValueRef JSTZDate::getSeconds(JSContextRef context, JSObjectRef function, JSOb
 JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception,
         ITZDate::TZDateFields dateFields) {
        try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*> (JSObjectGetPrivate(thisObject));
 
                if (privateObject == NULL) {
                        LogError(">>> NULL Exception");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                ITZDatePtr tzDate(privateObject->getObject());
                long retVal = tzDate->get(dateFields);
 
@@ -1075,7 +973,7 @@ JSValueRef JSTZDate::getTZDateValue(JSContextRef context, JSObjectRef thisObject
                return converter.toJSValueRef(static_cast<int> (retVal));
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1100,7 +998,7 @@ JSValueRef JSTZDate::setDate(JSContextRef context, JSObjectRef function, JSObjec
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1128,7 +1026,7 @@ JSValueRef JSTZDate::setFullYear(JSContextRef context, JSObjectRef function, JSO
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1156,7 +1054,7 @@ JSValueRef JSTZDate::setHours(JSContextRef context, JSObjectRef function, JSObje
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1184,7 +1082,7 @@ JSValueRef JSTZDate::setMilliseconds(JSContextRef context, JSObjectRef function,
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1212,7 +1110,7 @@ JSValueRef JSTZDate::setMinutes(JSContextRef context, JSObjectRef function, JSOb
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1240,7 +1138,7 @@ JSValueRef JSTZDate::setMonth(JSContextRef context, JSObjectRef function, JSObje
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1268,7 +1166,7 @@ JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSOb
                setTZDateValue(context, thisObject, argumentCount, arguments, exception, dateFields);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1290,18 +1188,17 @@ JSValueRef JSTZDate::setSeconds(JSContextRef context, JSObjectRef function, JSOb
 JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
         JSValueRef * exception, ITZDate::TZDateFields dateFields) {
 
-       if (argumentCount != 1) {
-               LogError("Wrong parameters");
-               ThrowMsg(InvalidArgumentException, "argumentIndex is bigger than argumentCount");
-       }
+       AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+               TIMEUTIL_FUNCTION_API_READ_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        TimeUtilConverter converter(context);
 
-       if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
-               || (!JSValueIsNumber(context, arguments[0])))
-               ThrowMsg(ConversionException, "Invalid Argument");
-
-       int data = converter.toInt(arguments[0]);
+       int data =0;
+       if (argumentCount == 0)
+               data = converter.toInt(JSValueMakeUndefined(context));
+       else
+               data = converter.toInt(arguments[0]);
 
        if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
                ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
@@ -1310,14 +1207,9 @@ JSValueRef JSTZDate::setTZDateValue(JSContextRef context, JSObjectRef thisObject
 
        if (privateObject == NULL) {
                LogError(">>> NULL Exception");
-               ThrowMsg(UnknownException, "privateObject is NULL");
+               ThrowMsg(NullPointerException, "privateObject is NULL");
        }
 
-       AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-               privateObject->getContext(),
-               TIMEUTIL_FUNCTION_API_READ_FUNCS);
-       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
        ITZDatePtr tzDate(privateObject->getObject());
        tzDate->set(dateFields, static_cast<long> (data));
 
@@ -1375,10 +1267,9 @@ JSValueRef JSTZDate::getUTCSeconds(JSContextRef context, JSObjectRef function,
 JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, ITZDate::TZDateFields DateFields, JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -1386,11 +1277,6 @@ JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr TZDate(privateObject->getObject());
@@ -1399,7 +1285,7 @@ JSValueRef JSTZDate::getUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
                return converter.toJSValueRefLong(result);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1467,42 +1353,34 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
        size_t argumentCount, const JSValueRef arguments[], ITZDate::TZDateFields dateFields, JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
-               if (!privateObject) {
-                       LogError("Private object is not set.");
-                       ThrowMsg(NullPointerException, "Private object not initialized");
-               }
-
-               if (argumentCount != 1) {
-                       LogError("Wrong TZDate parameters count");
-                       ThrowMsg(InvalidArgumentException, "Wrong TZDate parameters count");
-               }
-                       
-               if (!JSValueIsNumber(context, arguments[0]))
-               {
-                       LogError("Wrong TZDate parameters");
-                       ThrowMsg(ConversionException, "Wrong TZDate parameters");
-               }
-
                AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
                        TIMEUTIL_FUNCTION_API_READ_FUNCS);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TimeUtilConverter converter(context);
                
-               long data = converter.FromJSValueReftolong(arguments[0]);
+               long data = 0;
+               if (argumentCount == 0)
+                       data = converter.toLong(JSValueMakeUndefined(context));
+               else
+                       data = converter.toLong(arguments[0]);
 
                if ((dateFields == ITZDate::TZDATE_YEAR) && (data < 0))
                        ThrowMsg(InvalidArgumentException, "Invalid Argument:Year can't be set to negative");
-       
+
+               TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!privateObject) {
+                       LogError("Private object is not set.");
+                       ThrowMsg(NullPointerException, "Private object not initialized");
+               }
+
                ITZDatePtr TZDate(privateObject->getObject());
                TZDate->setUTC(dateFields, data);
 
                return JSValueMakeNull(context);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1523,10 +1401,9 @@ JSValueRef JSTZDate::setUTCTZDateValue(JSContextRef context, JSObjectRef thisObj
 JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -1534,11 +1411,6 @@ JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef f
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr tzDate(privateObject->getObject());
@@ -1548,7 +1420,7 @@ JSValueRef JSTZDate::getTimezoneAbbreviation(JSContextRef context, JSObjectRef f
                return converter.toJSValueRef(tzDate->getTimezoneAbbreviation());
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1566,10 +1438,9 @@ JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function,
        LogDebug("entered");
 
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -1577,11 +1448,6 @@ JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr tzDate(privateObject->getObject());
@@ -1589,7 +1455,7 @@ JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function,
                return converter.toJSValueRefLong(tzDate->secondsFromUTC());
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1605,10 +1471,9 @@ JSValueRef JSTZDate::secondsFromUTC(JSContextRef context, JSObjectRef function,
 JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
@@ -1616,11 +1481,6 @@ JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectR
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
                TimeUtilConverter converter(context);
 
                ITZDatePtr tzDate(privateObject->getObject());
@@ -1628,7 +1488,7 @@ JSValueRef JSTZDate::isDST(JSContextRef context, JSObjectRef function, JSObjectR
                return converter.toJSValueRef(tzDate->isDST());
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1646,30 +1506,28 @@ JSValueRef JSTZDate::getPreviousDSTTransition(JSContextRef context, JSObjectRef
        LogDebug("entered");
 
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
+       
                TimeUtilConverter converter(context);
 
                ITZDatePtr tzDate(privateObject->getObject());
 
-               return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::PREV_TRANSITION));
+               TZDateProperties resultDate =  tzDate->getDSTTransition(ITZDate::PREV_TRANSITION);
+               if (resultDate.timezone == "")
+                       return JSValueMakeNull(context);
+       
+               return createJSObject(context, resultDate);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -1687,30 +1545,28 @@ JSValueRef JSTZDate::getNextDSTTransition(JSContextRef context, JSObjectRef func
        LogDebug("entered");
 
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(thisObject));
                if (!privateObject) {
                        LogError("Private object is not set.");
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
+       
                TimeUtilConverter converter(context);
 
                ITZDatePtr tzDate(privateObject->getObject());
 
-               return createJSObject(privateObject->getContext(), tzDate->getDSTTransition(ITZDate::NEXT_TRANSITION));
+               TZDateProperties resultDate =  tzDate->getDSTTransition(ITZDate::NEXT_TRANSITION);
+               if (resultDate.timezone == "")
+                       return JSValueMakeNull(context);
+       
+               return createJSObject(context, resultDate);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
index cfb1971..bc62448 100755 (executable)
@@ -18,7 +18,7 @@
 #include <string>
 #include <memory>
 #include <dpl/log/log.h>
-
+#include <cmath>
 #include <Commons/Exception.h>
 #include <CommonsJavaScript/Utils.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
@@ -36,6 +36,7 @@ namespace Tizen1_0 {
 
 using namespace DPL;
 using namespace TizenApis::Commons;
+using namespace TizenApis::Api::TimeUtil;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
@@ -100,10 +101,9 @@ void JSTimeDuration::initialize(JSContextRef context, JSObjectRef object)
        if (!JSObjectGetPrivate(object)) {
                LogDebug("Private object not set... setting it.");
                DurationProperties durations;
-               std::auto_ptr<DurationProperties> durationProps(new DurationProperties(
-                                                                  durations));
-               TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps.get());
-               durationProps.release();
+               DurationPropertiesPtr durationProps(new DurationProperties(durations));
+               TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps);
+
                if (!JSObjectSetPrivate(object, priv)) {
                        delete priv;
                }
@@ -157,35 +157,25 @@ bool JSTimeDuration::setProperty(JSContextRef context, JSObjectRef object,
                        ThrowMsg(NullPointerException, "Private object not initialized");
                }
 
-               DurationProperties *duration = privateObject->getObject();
+               DurationPropertiesPtr duration = privateObject->getObject();
                TimeUtilConverter convert(context);
 
-               if (JSValueIsNull(context, value) || JSValueIsUndefined(context, value)) {
-                       LogError("value is invald.");
-                       ThrowMsg(ConversionException, "value is invald.");
-               }
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_LENGTH)) {
-                       if (!JSValueIsNumber(context, value)) {
-                               LogError("value is invald.");
-                               ThrowMsg(ConversionException, "value is invald.");
-                       }
                        duration->length = static_cast<long long>(convert.toDouble(value));
+                       if (std::isnan(duration->length)  || std::isinf(duration->length))
+                               duration->length = 0;
                } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_TIMEDURATION_UNIT)) {
-                       if (!JSValueIsString(context, value)) {
-                               LogError("value is invald.");
-                               ThrowMsg(ConversionException, "value is invald.");
-                       }
                        short unit = convert.toDurationUnit(convert.toString(value));
                        if (unit == 0xff)
-                               ThrowMsg(InvalidArgumentException, "property doesn't exist.");
+                               ThrowMsg(ConversionException, "property doesn't exist.");
                        duration->unit = unit;
                } else
-                       ThrowMsg(InvalidArgumentException, "property doesn't exist.");
+                       return false;
 
                return true;
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -202,10 +192,9 @@ bool JSTimeDuration::setProperty(JSContextRef context, JSObjectRef object,
 JSObjectRef JSTimeDuration::createJSObject(JSContextRef context,
         const DurationProperties &durations)
 {
-    std::auto_ptr<DurationProperties> durationProps(new DurationProperties(
-                                                       durations));
-    TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps.get());
-    durationProps.release();
+    DurationPropertiesPtr durationProps(new DurationProperties(durations));
+    TimeDurationPrivObject *priv = new TimeDurationPrivObject(context, durationProps);
+
     if (!priv) {
         ThrowMsg(NullPointerException, "Can not new an object");
     }
@@ -216,33 +205,30 @@ JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructo
        LogDebug("entered");
        TimeUtilConverter convert(ctx);
        Try {
-               if ((argumentCount < 1) || (argumentCount > 2)) {
-                       LogError("Wrong argument count");
-                       ThrowMsg(InvalidArgumentException, "Wrong TimeDuration argumentCount");
-               }
-
                TimeDurationPrivObject* mainPriv = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(constructor));
                JSContextRef global_context = mainPriv ? mainPriv->getContext() : ctx;
 
                DurationProperties duration;
-               if (JSValueIsNull(ctx, arguments[0]) || JSValueIsUndefined(ctx, arguments[0]) || !JSValueIsNumber(ctx, arguments[0])) {
-                       ThrowMsg(ConversionException, "Argument(length) is invalid");
-               }
-               duration.length = convert.toDouble(arguments[0]);
-               if (argumentCount == 2) {
-                       if (JSValueIsUndefined(ctx, arguments[1]) || !JSValueIsString(ctx, arguments[1])) {
-                               ThrowMsg(ConversionException, "Argument(unit) is invalid");
-                       } else if (!JSValueIsNull(ctx, arguments[1])) {
+               if (argumentCount == 0)
+                       duration.length = convert.toDouble(JSValueMakeUndefined(ctx));
+               else
+                       duration.length = convert.toDouble(arguments[0]);
+
+               if (std::isnan(duration.length) || std::isinf(duration.length))
+                       duration.length = 0;
+
+               if (argumentCount > 1) {
+                       if (!JSValueIsUndefined(ctx, arguments[1]) && !JSValueIsNull(ctx, arguments[1])) {
                                std::string unit = convert.toString(arguments[1]);
                                duration.unit = convert.toDurationUnit(unit);
                                if (duration.unit == 0xff)
-                                       ThrowMsg(InvalidArgumentException, "Argument(unit) is invalid(wrong type unit)");
+                                       ThrowMsg(ConversionException, "Argument(unit) is invalid(wrong type unit)");
                        }
                }
-               return createJSObject(global_context, duration);
+               return createJSObject(ctx, duration);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                return NULL;
        } Catch(UnknownException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
@@ -274,33 +260,35 @@ bool JSTimeDuration::hasInstance(JSContextRef context,
 JSValueRef JSTimeDuration::diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type) {
        LogDebug("entered");
 
-               TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(thisObject));
+       AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+               TIMEUTIL_FUNCTION_API_READ_FUNCS);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if (argumentCount != 1) {
-                       LogError("Wrong parameters");
-                       ThrowMsg(InvalidArgumentException, "Wrong parameters");
-               }
+       TimeDurationPrivObject* privateObject = static_cast<TimeDurationPrivObject*>(JSObjectGetPrivate(thisObject));
+       if (!privateObject) {
+               LogError("Private object is not set.");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
-               TimeUtilConverter converter(privateObject->getContext());
-
-               DurationProperties first = converter.getDurationPropertis(thisObject);
-               DurationProperties second = converter.getDurationPropertis(arguments[0]);
-
-               DurationProperties diff;
-               if (first.unit > second.unit) {
-                       long long firstLength = converter.convertDurationLength(first, second.unit);
-                       diff.unit = second.unit;
-                       diff.length = firstLength - second.length;
-               } else {
-                       long long secondLength = converter.convertDurationLength(second, first.unit);
-                       diff.unit = first.unit;
-                       diff.length = first.length - secondLength;
-               }
+       TimeUtilConverter converter(context);
+
+       DurationProperties first = converter.getDurationPropertis(thisObject);
+       DurationProperties second;
+       if (argumentCount == 0)
+               second= converter.getDurationPropertis(JSValueMakeUndefined(context));
+       else
+               second= converter.getDurationPropertis(arguments[0]);
+
+       DurationProperties diff;
+       if (first.unit > second.unit) {
+               long long firstLength = converter.convertDurationLength(first, second.unit);
+               diff.unit = second.unit;
+               diff.length = firstLength - second.length;
+       } else {
+               long long secondLength = converter.convertDurationLength(second, first.unit);
+               diff.unit = first.unit;
+               diff.length = first.length - secondLength;
+       }
 
        switch (type) {
                case EQUALSTO:
index 797af9a..cfec5fe 100755 (executable)
@@ -27,7 +27,7 @@
 namespace TizenApis {
 namespace Tizen1_0 {
 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
-            TizenApis::Api::TimeUtil::DurationProperties*>::
+             TizenApis::Api::TimeUtil::DurationPropertiesPtr>::
     Type TimeDurationPrivObject;
 
 /**
index 0f7d6bc..c76cb2a 100755 (executable)
@@ -126,29 +126,23 @@ JSValueRef JSTimeUtil::getCurrentDateTime(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
-               
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
        
-               return JSTZDate::createJSObject(privateObject->getContext());
+               return JSTZDate::createJSObject(context);
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -166,32 +160,25 @@ JSValueRef JSTimeUtil::setCurrentDateTime(JSContextRef context,
 {
        LogDebug("entered");
 
-       if (argumentCount != 1) {
-               LogError("Wrong argument count");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-       }
-
-       TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
-       if (NULL == privateObject) {
-               LogError("private object is null");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
        AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-               privateObject->getContext(),
                TIMEUTIL_FUNCTION_API_SET_CURRENT_DATE_TIME);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
        
        Try {           
                TimeUtilConverter converter(context);   
                        
-               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) 
+               if ((argumentCount < 1) || JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0]) 
                        || (!JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef()))) {
                        LogError("Wrong event argument");
                        Throw(ConversionException);
                }
 
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-                
+               TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
+               if (NULL == privateObject) {
+                       LogError("private object is null");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               }
+
                ITimeUtilPtr TimeUtil(privateObject->getObject());
                
                TZDateProperties TZDate = converter.getPropertiesInTZDate(arguments[0]);
@@ -221,10 +208,9 @@ JSValueRef JSTimeUtil::getLocalTimezone(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
@@ -232,11 +218,6 @@ JSValueRef JSTimeUtil::getLocalTimezone(JSContextRef context,
                if (NULL == privateObject) {
                        ThrowMsg(NullPointerException, "Can not new an object");
                }
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
                ITimeUtilPtr TimeUtil(privateObject->getObject());
                std::string localTimezone = TimeUtil->getLocalTimezone();               
@@ -246,7 +227,7 @@ JSValueRef JSTimeUtil::getLocalTimezone(JSContextRef context,
                return converter.toJSValueRef(localTimezone);
        } Catch(NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -267,10 +248,9 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
 {
        LogDebug("entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);  
 
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
@@ -279,11 +259,6 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
                        ThrowMsg(NullPointerException, "Can not new an object");
                }
 
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);          
-
                TimeUtilConverter converter(context);   
        
                ITimeUtilPtr TimeUtil(privateObject->getObject());
@@ -304,7 +279,7 @@ JSValueRef JSTimeUtil::getAvailableTimezones(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR , "Not Support");
        } Catch (NullPointerException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -324,33 +299,25 @@ JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
 {
        LogDebug("entered");
        Try {
-               if (argumentCount > 1) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
-
-               TimeUtilPrivObject* privateObject = 
-                       static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
-                                                              thisObject));
-               bool b_shortFormat = true;
-               
-               if (NULL == privateObject) {
-                       Throw(WrtDeviceApis::Commons::Exception);
-               }       
-
                AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
                        TIMEUTIL_FUNCTION_API_READ_FUNCS);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
+               bool b_shortFormat = true;
+               
                TimeUtilConverter converter(context);   
-               if ((argumentCount == 0) || (JSValueIsNull(context, arguments[0]))) {
+               if ((argumentCount == 0) || (JSValueIsNull(context, arguments[0])) || JSValueIsUndefined(context, arguments[0])) {
                        b_shortFormat = false;
-               } else if (JSValueIsUndefined(context, arguments[0]) || !JSValueIsBoolean(context, arguments[0]))
-                       Throw(ConversionException);
-               else
+               } else
                        b_shortFormat = converter.toBool(arguments[0]);
 
+               TimeUtilPrivObject* privateObject = 
+                       static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
+                                                              thisObject));
+               if (NULL == privateObject) {
+                       ThrowMsg(NullPointerException, "Can not new an object");
+               }
+
                ITimeUtilPtr TimeUtil(privateObject->getObject());
                std::string dateformat = TimeUtil->getDateFormat(b_shortFormat);        
                
@@ -364,6 +331,9 @@ JSValueRef JSTimeUtil::getDateFormat(JSContextRef context,
        } Catch (UnsupportedException) {
                LogError("JSTimeUtil::hasInstance NotSupportedException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR , "Not Support");
+       } Catch (NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -382,35 +352,32 @@ JSValueRef JSTimeUtil::getTimeFormat(JSContextRef context,
 {
        LogDebug("entered");
        Try {
-               if (argumentCount != 0) {
-                       LogError("Wrong argument count");
-                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
-               }
+               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
+                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
                TimeUtilPrivObject* privateObject = 
                        static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(
                                                               thisObject));
                
                if (NULL == privateObject) {
-                       Throw(WrtDeviceApis::Commons::Exception);
+                       ThrowMsg(NullPointerException, "Can not new an object");
                }       
-
-               AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
-                       TIMEUTIL_FUNCTION_API_READ_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
                
                ITimeUtilPtr TimeUtil(privateObject->getObject());
-               std::string dateformat = TimeUtil->getTimeFormat();     
+               std::string timeFormat = TimeUtil->getTimeFormat();     
                TimeUtilConverter converter(context);
                
-               return converter.toJSValueRef(dateformat);
+               return converter.toJSValueRef(timeFormat);
        } Catch (InvalidArgumentException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (UnsupportedException) {
                LogError("JSTimeUtil::hasInstance NotSupportedException");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR , "Not Support");
+       } Catch (NullPointerException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -424,21 +391,17 @@ JSValueRef JSTimeUtil::isLeapYear(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("Entered");
        Try {
-               TimeUtilPrivObject* privateObject = static_cast<TimeUtilPrivObject*>(JSObjectGetPrivate(thisObject));
-
-               if (argumentCount != 1) {
-                       LogError("Wrong parameters");
-                       ThrowMsg(InvalidArgumentException, "Wrong parameters");
-               }
-
                AceSecurityStatus status = TIMEUTIL_CHECK_ACCESS(
-                       privateObject->getContext(),
                        TIMEUTIL_FUNCTION_API_READ_FUNCS);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-               
+
                TimeUtilConverter converter(context);
 
-               long year = converter.FromJSValueReftolong(arguments[0]);
+               long year = 0;
+               if (argumentCount < 1) {
+                       year = converter.toLong(JSValueMakeUndefined(context));
+               } else
+                       year = converter.toLong(arguments[0]);
                
                if (year % 4 != 0)
                        return converter.toJSValueRef(false);
index b226d60..5ab9bec 100755 (executable)
@@ -60,7 +60,7 @@ long TimeUtilConverter::FromJSValueReftolong(const JSValueRef& arg) {
 }
 
 TZDateProperties TimeUtilConverter::getPropertiesInTZDate(JSValueRef arg) {
-       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
+       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
                ThrowMsg(Commons::ConversionException,
                         "Message is JS null or JS undefined.");
        }
@@ -120,7 +120,7 @@ DurationProperties TimeUtilConverter::getDurationPropertis(JSValueRef value) {
 }
 
 long long TimeUtilConverter::getDurationLength(JSValueRef value) {
-       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
+       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value) || !JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
                ThrowMsg(Commons::ConversionException,
                         "Duration is JS null or JS undefined.");
        }
@@ -135,13 +135,13 @@ long long TimeUtilConverter::getDurationLength(JSObjectRef object) {
                ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
 
-       DurationProperties *duration = privateObject->getObject();
+       DurationPropertiesPtr duration = privateObject->getObject();
 
        return duration->length;
 }
 
 short TimeUtilConverter::getDurationUnit(JSValueRef value) {
-       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
+       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value) || !JSValueIsObjectOfClass(m_context, value, JSTimeDuration::getClassRef())) {
                ThrowMsg(Commons::ConversionException,
                         "Duration is JS null or JS undefined.");
        }
@@ -156,7 +156,7 @@ short TimeUtilConverter::getDurationUnit(JSObjectRef object) {
                ThrowMsg(Commons::ConversionException, "Private object not initialized");
        }
 
-       DurationProperties *duration = privateObject->getObject();
+       DurationPropertiesPtr duration = privateObject->getObject();
 
        return duration->unit;
 
@@ -223,7 +223,7 @@ long long TimeUtilConverter::convertDurationLength(DurationProperties duration,
 }
 
 std::time_t TimeUtilConverter::toTZDateTimeT(JSValueRef arg) {
-       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
+       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
                ThrowMsg(Commons::ConversionException,
                         "JSValueRef is JS null or JS undefined.");
        }
@@ -256,12 +256,48 @@ std::time_t TimeUtilConverter::toTZDateTimeT(JSObjectRef arg) {
        utcTm.tm_min=UTCProperties.minutes;
        utcTm.tm_sec= UTCProperties.seconds;
        utcTm.tm_isdst = 0;
-       return mktime(&utcTm);
-       
+       return timegm(&utcTm);
+}
+
+tm TimeUtilConverter::toTZDateTime(JSValueRef arg) {
+       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) || !JSValueIsObjectOfClass(m_context, arg, JSTZDate::getClassRef())) {
+               ThrowMsg(Commons::ConversionException,
+                        "JSValueRef is JS null or JS undefined.");
+       }
+       JSObjectRef obj = toJSObjectRef(arg);
+
+       return toTZDateTime(obj);
+}
+
+tm TimeUtilConverter::toTZDateTime(JSObjectRef arg) {
+       if (!arg) {
+               LogError("Object is null");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
+       }
+
+       TZDatePrivObject* privateObject = static_cast<TZDatePrivObject*>(JSObjectGetPrivate(arg));
+       if (!privateObject) {
+               LogError("Private object is not set.");
+               ThrowMsg(Commons::ConversionException, "Private object not initialized");
+       }
+
+       ITZDatePtr TZDate = privateObject->getObject();
+
+       TZDateProperties UTCProperties = TZDate->toUTC();
+       struct tm  utcTm;
+
+       utcTm.tm_year = UTCProperties.year - 1900;
+       utcTm.tm_mon = UTCProperties.month;
+       utcTm.tm_mday= UTCProperties.day;
+       utcTm.tm_hour= UTCProperties.hours;
+       utcTm.tm_min=UTCProperties.minutes;
+       utcTm.tm_sec= UTCProperties.seconds;
+       utcTm.tm_isdst = 0;
+       return utcTm;
 }
 
 JSObjectRef TimeUtilConverter::FromUTCTimeTToTZDate(std::time_t utcTime, const std::string &timezone) {
-       struct tm *tm = localtime(&utcTime);
+       struct tm *tm = gmtime(&utcTime);
        TZDateProperties props;
        props.year = tm->tm_year + 1900;
        props.month = tm->tm_mon;
index 04b4b74..c07e95d 100755 (executable)
@@ -60,6 +60,8 @@ class TimeUtilConverter : public Converter
        long long convertDurationLength(DurationProperties duration, short unit);
        std::time_t toTZDateTimeT(JSValueRef arg);
        std::time_t toTZDateTimeT(JSObjectRef arg);
+       tm toTZDateTime(JSValueRef arg);
+       tm toTZDateTime(JSObjectRef arg);
        JSObjectRef FromUTCTimeTToTZDate(std::time_t utcTime, const std::string &timezone);
 
 };
index 3ac5265..1b22437 100755 (executable)
@@ -28,12 +28,11 @@ namespace Tizen1_0 {
 
 DECLARE_FUNCTION_GETTER(TimeUtil);
 
-#define TIMEUTIL_CHECK_ACCESS(globalContext, functionName)                       \
+#define TIMEUTIL_CHECK_ACCESS(functionName)                       \
     aceCheckAccess<AceFunctionGetter, DefaultArgsVerifier<> >(                \
-        globalContext,                     \
         getTimeUtilFunctionData,             \
         functionName)
 }
 }
 
-#endif //  _TIMEUTIL_PLUGIN_CONFIG_H_
\ No newline at end of file
+#endif //  _TIMEUTIL_PLUGIN_CONFIG_H_
index 6c4a32f..981e205 100755 (executable)
  * distributed under the License is distributed on an AS IS BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
- * limitations under the License. 
+ * limitations under the License.
  */
 
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include "JSTimeUtil.h"
 #include "JSTZDate.h"
 #include "JSTimeDuration.h"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId) {
        LogDebug("[TIZEN1.0\\TimeUtil] on_widget_start_callback ("<<widgetId<<")");
     Try
     {
-        WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(
-            widgetId,
-            context,
-            interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper registration failed");
+        LogError("WrtAccess initialization failed");
     }
 }
 
@@ -41,23 +41,23 @@ void on_widget_stop_callback(int widgetId) {
        LogDebug("[TIZEN1.0\\TimeUtil] on_widget_stop_callback ("<<widgetId<<")");
     Try
     {
-        WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper removal failed");
+        LogError("WrtAccess deinitialization failed");
     }
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
-PLUGIN_CLASS_MAP_BEGIN 
+PLUGIN_CLASS_MAP_BEGIN
        PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN,
                "time",
                TizenApis::Tizen1_0::JSTimeUtil::getClassRef(),
-               NULL) 
+               NULL)
        PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN,
                "TZDate",
index faee11d..f3aa72f 100755 (executable)
@@ -11,6 +11,7 @@ include_directories(
 set(CMAKE_INSTALL_RPATH
   ${CMAKE_INSTALL_RPATH}
   ${CMAKE_INSTALL_PREFIX}/${DESTINATION_NAME}
+  ${CMAKE_INSTALL_PREFIX}/tizen-1.0-time
 )
 
 set(SRCS_IMPL
@@ -45,6 +46,7 @@ add_library(${TARGET_NAME} SHARED ${SRCS})
 
 target_link_libraries(${TARGET_NAME}
     ${TARGET_IMPL_NAME}
+    wrt-plugins-tizen-1.0-time-impl
 )
 
 INSTALL(TARGETS ${TARGET_NAME} ${TARGET_IMPL_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
index 314ed16..72d0158 100755 (executable)
@@ -167,7 +167,10 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsString = false;
+       bool js3rdParamIsValue = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(constructor));
@@ -180,7 +183,7 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(context, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 3)
+               if (argumentCount < 1)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsString(gContext, arguments[0]))
@@ -188,11 +191,21 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
 
                if (argumentCount >= 2)
                {
-                       if (!JSValueIsString(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
+                       if (JSValueIsString(gContext, arguments[1]))
+                               js2ndParamIsString = true;
+
+                       if (!js2ndParamIsString &&
+                                       !JSValueIsNull(gContext, arguments[1]) &&
+                                       !JSValueIsUndefined(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+               }
+
+               if (argumentCount >= 3)
+               {
+                       if (!JSValueIsNull(gContext, arguments[2]) && !JSValueIsUndefined(gContext, arguments[2]))
+                               js3rdParamIsValue = true;
                }
 
-               // 3rd argument can be any type.
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
@@ -204,7 +217,7 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
 
        std::string attributeName;
        MatchFlag matchFlag;
-       AnyPtr matchValue;
+       AnyPtr matchValue(NULL);
 
        Try {
                attributeName = converter->toString(arguments[0]);
@@ -215,12 +228,11 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               matchFlag = MATCH_EXACTLY;
-               if(argumentCount >= 2)
-               {
-                       if(JSValueIsString(gContext, arguments[1]))
-                               matchFlag = converter->toMatchFlag(arguments[1]);
-               }
+               if(js2ndParamIsString)
+                       matchFlag = converter->toMatchFlag(arguments[1]);
+               else
+                       matchFlag = MATCH_EXACTLY;
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -228,17 +240,10 @@ JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 3)
-               {
-                       if(JSValueIsNull(gContext, arguments[2]))
-                               matchValue = AnyPtr(new Any());
-                       else
-                               matchValue = converter->toAny(arguments[2]);
-               }
+               if(js3rdParamIsValue)
+                       matchValue = converter->toAny(arguments[2]);
                else
-               {
                        matchValue = AnyPtr(new Any());
-               }
 
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
index 4f68995..b92cd67 100755 (executable)
@@ -166,7 +166,10 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsValue = false;
+       bool js3rdParamIsValue = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(constructor));
@@ -179,25 +182,28 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
        Try {
-               if (argumentCount < 2 || argumentCount > 3)
+               if (argumentCount < 1)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsString(gContext, arguments[0]))
                        ThrowMsg(InvalidArgumentException, "1st argument is not string.");
 
                // 2nd and 3rd argument can be any type.
-               if (argumentCount == 2)
+               if (argumentCount >= 2)
                {
-                       if(JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+                       if(!JSValueIsUndefined(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+                               js2ndParamIsValue = true;
                }
 
-               if (argumentCount == 3)
+               if (argumentCount >= 3)
                {
-                       if(JSValueIsNull(gContext, arguments[1]) && JSValueIsNull(gContext, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+                       if(!JSValueIsUndefined(gContext, arguments[2]) && !JSValueIsNull(gContext, arguments[2]))
+                               js3rdParamIsValue = true;
                }
 
+               if (!js2ndParamIsValue && !js3rdParamIsValue)
+                       ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue are needed.");
+
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -207,8 +213,8 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
 
        std::string attributeName;
-       AnyPtr initialValue;
-       AnyPtr endValue;
+       AnyPtr initialValue(NULL);
+       AnyPtr endValue(NULL);
 
        Try {
                attributeName = converter->toString(arguments[0]);
@@ -219,7 +225,7 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 2)
+               if(js2ndParamIsValue)
                        initialValue = converter->toAny(arguments[1]);
                else
                        initialValue = AnyPtr(new Any());
@@ -231,7 +237,7 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 3)
+               if(js3rdParamIsValue)
                        endValue = converter->toAny(arguments[2]);
                else
                        endValue = AnyPtr(new Any());
index 2cad942..d4b1ec7 100755 (executable)
@@ -166,7 +166,9 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsObject = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(constructor));
@@ -179,7 +181,7 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 3)
+               if (argumentCount < 1)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsString(gContext, arguments[0]))
@@ -187,11 +189,14 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
 
                if (argumentCount >= 2)
                {
-                       if (!JSValueIsObject(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "2nd argument is not object.");
-               }
+                       if (JSValueIsObject(gContext, arguments[1]))
+                               js2ndParamIsObject = true;
 
-               // 3rd argument can be any type.
+                       if (!js2ndParamIsObject &&
+                                       !JSValueIsNull(gContext, arguments[1]) &&
+                                       !JSValueIsUndefined(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument is not array.");
+               }
 
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
@@ -202,7 +207,7 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
        FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
 
        FilterType type;
-       FilterArrayPtr filters;
+       FilterArrayPtr filters(NULL);
 
        Try {
                type = converter->toCompositeFilterType(arguments[0]);
@@ -213,13 +218,8 @@ JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 2)
-               {
-                       if(!JSValueIsNull(gContext, arguments[1]))
-                               filters = converter->toFilterArray(arguments[1]);
-                       else
-                               filters = FilterArrayPtr(new FilterArray());
-               }
+               if(js2ndParamIsObject)
+                       filters = converter->toFilterArray(arguments[1]);
                else
                        filters = FilterArrayPtr(new FilterArray());
 
index 17eb49d..fb2afe7 100755 (executable)
@@ -165,7 +165,7 @@ JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(constructor));
@@ -178,7 +178,7 @@ JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
        Try {
-               if (argumentCount != 2)
+               if (argumentCount < 2)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsNumber(gContext, arguments[0]))
@@ -213,7 +213,7 @@ JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context,
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
                return NULL;
        }
-       printf("latitude : %f\n\n", latitude);
+
        SimpleCoordinatesPtr simpleCoordinates(new SimpleCoordinates(latitude, longitude));
 
        JSObjectRef jsobject;
index 6e029cc..479e7bd 100755 (executable)
@@ -165,7 +165,9 @@ JSObjectRef JSSortMode::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsString = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(constructor));
@@ -178,7 +180,7 @@ JSObjectRef JSSortMode::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
        Try {
-               if (argumentCount < 1 || argumentCount > 2)
+               if (argumentCount < 1)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsString(gContext, arguments[0]))
@@ -186,12 +188,15 @@ JSObjectRef JSSortMode::constructor(JSContextRef context,
 
                if (argumentCount >= 2)
                {
-                       if (!JSValueIsString(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+                       if (JSValueIsString(gContext, arguments[1]))
+                               js2ndParamIsString = true;
+
+                       if (!js2ndParamIsString &&
+                                       !JSValueIsNull(gContext, arguments[1]) &&
+                                       !JSValueIsUndefined(gContext, arguments[1]))
                                ThrowMsg(InvalidArgumentException, "2nd argument is not string.");
                }
 
-               // 3rd argument can be any type.
-
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -212,12 +217,11 @@ JSObjectRef JSSortMode::constructor(JSContextRef context,
        }
 
        Try {
-               sortOrder = ASCENDING_SORT_ORDER;
-               if(argumentCount >= 2)
-               {
-                       if(JSValueIsString(gContext, arguments[1]))
-                               sortOrder = converter->toSortOrder(arguments[1]);
-               }
+               if(js2ndParamIsString)
+                       sortOrder = converter->toSortOrder(arguments[1]);
+               else
+                       sortOrder = ASCENDING_SORT_ORDER;
+
        } Catch(Exception) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
index 51e7803..2745cd1 100755 (executable)
@@ -26,8 +26,7 @@
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
-#include <Commons/WrtWrapper/IWrtWrapper.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <API/Filter/FilterTypes.h>
 #include <API/Filter/AnyType.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
@@ -99,24 +98,14 @@ void JSTizen::initialize(JSContextRef context, JSObjectRef object)
     if (priv) {
         delete priv;
     }
-    IWrtWrapperPtr wrapper;
-    Try
-    {
-        wrapper = WrtWrappersMgr::getInstance().getWrtWrapper(context);
-    }
-    Catch(WrtDeviceApis::Commons::InvalidArgumentException)
-    {
-        LogError("Cannot get WRT wrapper.");
-        LogError("You should register your wrapper in ON_WIDGET_START");
-        return;
-    }
 
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     PluginOnDemandPrivPtr privObject(
         new PluginOnDemandPriv(
-            wrapper,
                        PluginManagerFactory::getInstance().getPluginManager(
-                           wrapper->getWidgetId(),
+                           widgetId,
                            PLUGIN_NAME,
+                           object,
                            context)));
 
     priv = new TizenPrivate(context, privObject);
@@ -266,14 +255,13 @@ JSValueRef JSTizen::listAvailableFeatures(JSContextRef context, JSObjectRef obje
         const JSValueRef arguments[], JSValueRef* exception)
 {
     LogDebug("entered");
-    IWrtWrapperPtr wrapper;
 
     TizenPrivate* priv = static_cast<TizenPrivate*>(JSObjectGetPrivate(thisObject));
     assert(priv);
 
     /*
      * Current Tizen spec assures that tizen is always available
-    AccessStatus status = DEVICEAPIS_CHECK_ACCESS(priv->getContext(),
+    AccessStatus status = DEVICEAPIS_CHECK_ACCESS(
                                  DEVICEAPIS_FUNCTION_API_LIST_AVAIL_FEATURES);
 
     SYNC_ACCESS_STATUS_HANDLER(status, context, exception);
@@ -284,18 +272,16 @@ JSValueRef JSTizen::listAvailableFeatures(JSContextRef context, JSObjectRef obje
         if (!priv) {
             ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "No private object");
         }
-//        wrapper = priv->getObject();
            PluginOnDemandPrivPtr privObj = priv->getObject();
-           wrapper = privObj->getWrtWrapper();
     }
     catch(const WrtDeviceApis::Commons::Exception &ex)
     {
-        LogError("couldn't get wrapper, " << ex.GetMessage());
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
     WidgetDB::Api::Features features = widgetDB->getRegisteredFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);
@@ -323,27 +309,25 @@ JSValueRef JSTizen::listActivatedFeatures(JSContextRef context, JSObjectRef obje
 
     /*
      * Current Tizen spec assures that tizen is always available
-     AccessStatus status = DEVICEAPIS_CHECK_ACCESS(priv->getContext(),
+     AccessStatus status = DEVICEAPIS_CHECK_ACCESS(
                                  DEVICEAPIS_FUNCTION_API_LIST_ACTIV_FEATURES);
 
     SYNC_ACCESS_STATUS_HANDLER(status, context, exception);*/
-    IWrtWrapperPtr wrapper;
     try
     {
         if (!priv) {
             ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "No private object");
         }
         PluginOnDemandPrivPtr privObj = priv->getObject();
-        wrapper = privObj->getWrtWrapper();
     }
     catch(const WrtDeviceApis::Commons::Exception &ex)
     {
-        LogError("couldn't get wrapper, " << ex.GetMessage());
         return WrtDeviceApis::CommonsJavaScript::JSDOMExceptionFactory::UnknownException.make(context, exception);
     }
     JSObjectRef result = JSCreateArrayObject(context, 0, NULL);
+    int widgetId = WrtAccessSingleton::Instance().getWidgetId();
     WidgetDB::Api::IWidgetDBPtr widgetDB =
-        WidgetDB::Api::getWidgetDB(wrapper->getWidgetId());
+        WidgetDB::Api::getWidgetDB(widgetId);
     WidgetDB::Api::Features features = widgetDB->getWidgetFeatures();
     for (size_t i=0; i<features.size(); ++i) {
         JSFeaturePrivateObject *priv = new JSFeaturePrivateObject(context, features[i]);
index 5e20146..e283464 100755 (executable)
@@ -27,13 +27,9 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Tizen {
 
-using namespace WrtDeviceApis;
-using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::PluginManager::Api;
 
-PluginOnDemandPriv::PluginOnDemandPriv(const IWrtWrapperPtr &wrapper,
-                                       const IPluginManagerPtr &pluginManager) :
-    m_wrtWrapper(wrapper),
+PluginOnDemandPriv::PluginOnDemandPriv(const IPluginManagerPtr &pluginManager) :
     m_pluginManager(pluginManager)
 {
 }
@@ -42,11 +38,6 @@ PluginOnDemandPriv::~PluginOnDemandPriv()
 {
 }
 
-IWrtWrapperPtr PluginOnDemandPriv::getWrtWrapper() const
-{
-    return m_wrtWrapper;
-}
-
 IPluginManagerPtr PluginOnDemandPriv::getPluginManager() const
 {
     return m_pluginManager;
index 4ae66e2..34030bb 100755 (executable)
@@ -28,7 +28,6 @@
 #include <string>
 #include <dpl/shared_ptr.h>
 #include <JavaScriptCore/JavaScript.h>
-#include <Commons/WrtWrapper/IWrtWrapper.h>
 #include <PluginManager/IPluginManager.h>
 
 namespace TizenApis {
@@ -39,17 +38,13 @@ class PluginOnDemandPriv
 {
   public:
     PluginOnDemandPriv(
-        const WrtDeviceApis::Commons::IWrtWrapperPtr &wrapper,
         const WrtDeviceApis::PluginManager::Api::IPluginManagerPtr &pluginManager);
 
     virtual ~PluginOnDemandPriv();
 
-    WrtDeviceApis::Commons::IWrtWrapperPtr getWrtWrapper() const;
-
     WrtDeviceApis::PluginManager::Api::IPluginManagerPtr getPluginManager() const;
 
   private:
-    WrtDeviceApis::Commons::IWrtWrapperPtr m_wrtWrapper;
     WrtDeviceApis::PluginManager::Api::IPluginManagerPtr m_pluginManager;
 
 };
index f3d3bc3..877568d 100755 (executable)
@@ -23,7 +23,7 @@
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/WrtAccess/WrtAccess.h>
 #include <Commons/Exception.h>
 #include "JSTizen.h"
 #include "JSAttributeFilter.h"
 
 #define OBJECT_TIZEN "tizen"
 
-void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+
+void on_widget_start_callback(int widgetId)
 {
     LogDebug("[Tizen\\xxx] on_widget_start_callback ("<<widgetId<<")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(widgetId,context,interface);
+        WrtAccessSingleton::Instance().initialize(widgetId);
     }
-    Catch(WrtDeviceApis::Commons::Exception)
+    Catch(Commons::Exception)
     {
-        LogError("Wrt wrapper registration failed");
+        LogError("WrtAccess initialization failed");
     }
 }
 
@@ -54,14 +57,26 @@ void on_widget_stop_callback(int widgetId)
     LogDebug("[Tizen\\xxx] on_widget_stop_callback ("<<widgetId<<")");
     Try
     {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
+        WrtAccessSingleton::Instance().deinitialize(widgetId);
     }
     Catch(WrtDeviceApis::Commons::Exception)
     {
-        LogError("Wrt wrapper removal failed");
+        LogError("WrtAccess deinitialization failed");
     }
 }
 
+namespace Options {
+class_definition_options_t TizenOptions =
+{
+       JS_CLASS,
+       CREATE_INSTANCE,
+       NONE_NOTICE,
+       USE_OVERLAYED,
+       NULL,
+       NULL,
+};
+}
+
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
 PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
@@ -69,7 +84,7 @@ PLUGIN_CLASS_MAP_BEGIN
     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_GLOBAL,
                                OBJECT_TIZEN,
                                TizenApis::Tizen1_0::Tizen::JSTizen::getClassRef(),
-                               NULL)
+                               &Options::TizenOptions)
     PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
                                "AttributeFilter",
                                TizenApis::Tizen1_0::Tizen::JSAttributeFilter::getClassRef(),