Beta merge 2
authorKisub Song <kisubs.song@samsung.com>
Fri, 10 Feb 2012 11:48:28 +0000 (20:48 +0900)
committerKisub Song <kisubs.song@samsung.com>
Fri, 10 Feb 2012 11:48:28 +0000 (20:48 +0900)
436 files changed:
debian/control
src/platform/API/Account/AccountFactory.cpp
src/platform/API/Account/AccountFactory.h
src/platform/API/Account/AccountServiceFilterProperty.cpp [new file with mode: 0644]
src/platform/API/Account/AccountServiceFilterProperty.h [new file with mode: 0644]
src/platform/API/Account/AccountServiceProviderProperty.h
src/platform/API/Account/EventAccount.cpp
src/platform/API/Account/EventAccount.h
src/platform/API/Account/IAccountManager.cpp
src/platform/API/Account/IAccountManager.h
src/platform/API/Account/IEventFindAccounts.h
src/platform/API/Account/IEventFindProviders.h
src/platform/API/Account/IEventFindServiceTypes.h
src/platform/API/Account/IEventFindServices.h [new file with mode: 0644]
src/platform/API/Account/IEventGetServiceById.h [new file with mode: 0644]
src/platform/API/Account/IEventGetServiceByName.h [new file with mode: 0644]
src/platform/API/Account/config.cmake
src/platform/API/Application/ApplicationContext.cpp [new file with mode: 0755]
src/platform/API/Application/ApplicationContext.h [new file with mode: 0755]
src/platform/API/Application/ApplicationEvent.cpp
src/platform/API/Application/ApplicationEvent.h
src/platform/API/Application/ApplicationInformation.cpp
src/platform/API/Application/ApplicationInformation.h
src/platform/API/Application/ApplicationService.cpp [new file with mode: 0755]
src/platform/API/Application/ApplicationService.h [new file with mode: 0755]
src/platform/API/Application/ApplicationServiceData.cpp [new file with mode: 0755]
src/platform/API/Application/ApplicationServiceData.h [new file with mode: 0755]
src/platform/API/Application/EventGetApplication.h
src/platform/API/Application/EventInstalledApplicationChanged.h
src/platform/API/Application/EventLaunchService.h
src/platform/API/Application/EventListInstalledApplications.h
src/platform/API/Application/EventManageApplication.h [new file with mode: 0755]
src/platform/API/Application/IApplication.cpp
src/platform/API/Application/IApplication.h
src/platform/API/Application/config.cmake
src/platform/API/Calendar/CalendarEvent.cpp
src/platform/API/Calendar/CalendarEvent.h
src/platform/API/Calendar/EventAlarm.cpp
src/platform/API/Calendar/EventAlarm.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/ICalendarManager.cpp
src/platform/API/Calendar/ICalendarManager.h
src/platform/API/Calendar/IEventGet.h [new file with mode: 0755]
src/platform/API/Calendar/IEventGetCalendar.h [new file with mode: 0755]
src/platform/API/Call/CallFactory.cpp [new file with mode: 0755]
src/platform/API/Call/CallFactory.h [new file with mode: 0755]
src/platform/API/Call/CallHistoryEntryProperties.cpp
src/platform/API/Call/CallHistoryEntryProperties.h
src/platform/API/Call/CallHistoryFactory.cpp
src/platform/API/Call/CallHistoryFactory.h
src/platform/API/Call/CallServiceFilter.cpp [new file with mode: 0755]
src/platform/API/Call/CallServiceFilter.h [new file with mode: 0755]
src/platform/API/Call/CallServiceObject.cpp [new file with mode: 0755]
src/platform/API/Call/CallServiceObject.h [new file with mode: 0755]
src/platform/API/Call/EventCallHistoryListener.cpp [new file with mode: 0755]
src/platform/API/Call/EventCallHistoryListener.h [new file with mode: 0755]
src/platform/API/Call/EventFindCallHistory.cpp
src/platform/API/Call/EventFindCallHistory.h
src/platform/API/Call/EventGetCallService.cpp [new file with mode: 0755]
src/platform/API/Call/EventGetCallService.h [new file with mode: 0755]
src/platform/API/Call/EventLaunchDialer.cpp [new file with mode: 0755]
src/platform/API/Call/EventLaunchDialer.h [new file with mode: 0755]
src/platform/API/Call/EventRemoveAll.cpp [new file with mode: 0755]
src/platform/API/Call/EventRemoveAll.h [new file with mode: 0755]
src/platform/API/Call/EventSendUSSD.cpp [new file with mode: 0755]
src/platform/API/Call/EventSendUSSD.h [new file with mode: 0755]
src/platform/API/Call/ICallHistory.cpp
src/platform/API/Call/ICallHistory.h
src/platform/API/Call/ICallHistoryEntry.cpp [new file with mode: 0755]
src/platform/API/Call/ICallHistoryEntry.h [new file with mode: 0755]
src/platform/API/Call/ICallManager.cpp [new file with mode: 0755]
src/platform/API/Call/ICallManager.h [new file with mode: 0755]
src/platform/API/Call/ICallService.cpp [new file with mode: 0755]
src/platform/API/Call/ICallService.h [new file with mode: 0755]
src/platform/API/Call/RemoteParty.cpp [new file with mode: 0755]
src/platform/API/Call/RemoteParty.h [new file with mode: 0755]
src/platform/API/Call/config.cmake
src/platform/API/Filter/AnyType.cpp
src/platform/API/Filter/AnyType.h
src/platform/API/Filter/AttributeFilter.cpp
src/platform/API/Filter/AttributeFilter.h
src/platform/API/Filter/FilterFactory.cpp
src/platform/API/Filter/FilterFactory.h
src/platform/API/Filter/FilterTypes.h
src/platform/API/Filter/FilterValidator.cpp
src/platform/API/Filter/FilterValidator.h
src/platform/API/Filter/IFilterVisitor.h
src/platform/API/Filter/SimpleCoordinates.cpp [new file with mode: 0644]
src/platform/API/Filter/SimpleCoordinates.h [new file with mode: 0644]
src/platform/API/Filter/config.cmake
src/platform/API/Mediacontent/IEventAddAudioToPlaylist.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventDeleteAudioToPlaylist.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventDeletePlaylist.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventFindFolder.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventFindMedia.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventFindPlaylist.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventFolderFindMedia.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventGetMediacontent.h [new file with mode: 0644]
src/platform/API/Mediacontent/IEventUpdateMedia.h [new file with mode: 0644]
src/platform/API/Mediacontent/IMediacontent.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/IMediacontent.h [new file with mode: 0644]
src/platform/API/Mediacontent/IMediacontentManager.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/IMediacontentManager.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentAudio.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentAudio.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentFactory.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentFactory.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentFolder.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentFolder.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentImage.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentImage.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentLyrics.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentLyrics.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentMedia.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentMedia.h [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentVideo.cpp [new file with mode: 0644]
src/platform/API/Mediacontent/MediacontentVideo.h [new file with mode: 0644]
src/platform/API/Mediacontent/config.cmake [new file with mode: 0644]
src/platform/API/Messaging/AttachmentFactory.cpp
src/platform/API/Messaging/AttachmentFactory.h
src/platform/API/Messaging/ConversationFilterValidator.cpp
src/platform/API/Messaging/ConversationFilterValidator.h
src/platform/API/Messaging/ConversationFilterValidatorFactory.cpp
src/platform/API/Messaging/FolderFilterValidator.cpp
src/platform/API/Messaging/FolderFilterValidator.h
src/platform/API/Messaging/FolderFilterValidatorFactory.cpp
src/platform/API/Messaging/IAttachment.cpp
src/platform/API/Messaging/IEmail.h
src/platform/API/Messaging/IMessagingTypes.h
src/platform/API/Messaging/IMms.h
src/platform/API/Messaging/MessageFactory.cpp
src/platform/API/Messaging/MessageFactory.h
src/platform/API/Messaging/MessageFilterValidator.cpp
src/platform/API/Messaging/MessageFilterValidator.h
src/platform/API/Messaging/MessageFilterValidatorFactory.cpp
src/platform/API/Messaging/MessageStorageFactory.cpp [new file with mode: 0644]
src/platform/API/Messaging/MessageStorageFactory.h [new file with mode: 0644]
src/platform/API/Messaging/ReqReceiverMessage.cpp
src/platform/API/Messaging/StorageChangesConversationFilterValidator.cpp
src/platform/API/Messaging/StorageChangesConversationFilterValidator.h
src/platform/API/Messaging/StorageChangesConversationFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesConversationGenerator.cpp
src/platform/API/Messaging/StorageChangesConversationGenerator.h
src/platform/API/Messaging/StorageChangesFolderFilterValidator.cpp
src/platform/API/Messaging/StorageChangesFolderFilterValidator.h
src/platform/API/Messaging/StorageChangesFolderFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesFolderGenerator.cpp
src/platform/API/Messaging/StorageChangesFolderGenerator.h
src/platform/API/Messaging/StorageChangesMessageFilterValidator.cpp
src/platform/API/Messaging/StorageChangesMessageFilterValidator.h
src/platform/API/Messaging/StorageChangesMessageFilterValidatorFactory.cpp
src/platform/API/Messaging/StorageChangesMessageGenerator.cpp
src/platform/API/Messaging/StorageChangesMessageGenerator.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/config.cmake
src/platform/Tizen/Account/AccountManager.cpp
src/platform/Tizen/Account/AccountManager.h
src/platform/Tizen/Account/AccountWrapper.cpp
src/platform/Tizen/Account/AccountWrapper.h
src/platform/Tizen/Account/config.cmake
src/platform/Tizen/Account/old/AccountService.cpp [new file with mode: 0755]
src/platform/Tizen/Account/old/AccountService.h [new file with mode: 0755]
src/platform/Tizen/Application/Application.cpp
src/platform/Tizen/Application/Application.h
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/CalendarManager.h
src/platform/Tizen/Calendar/EventWrapper.cpp
src/platform/Tizen/Call/CallHistory.cpp
src/platform/Tizen/Call/CallHistory.h
src/platform/Tizen/Call/CallHistoryEntry.cpp [new file with mode: 0755]
src/platform/Tizen/Call/CallHistoryEntry.h [new file with mode: 0755]
src/platform/Tizen/Call/CallHistoryFilter.cpp
src/platform/Tizen/Call/CallHistoryFilter.h
src/platform/Tizen/Call/CallManager.cpp [new file with mode: 0755]
src/platform/Tizen/Call/CallManager.h [new file with mode: 0755]
src/platform/Tizen/Call/CallService.cpp [new file with mode: 0755]
src/platform/Tizen/Call/CallService.h [new file with mode: 0755]
src/platform/Tizen/Call/config.cmake
src/platform/Tizen/Contact/ContactFilterValidator.cpp
src/platform/Tizen/Contact/ContactSearchEngine.cpp
src/platform/Tizen/Contact/ContactSearchEngine.h
src/platform/Tizen/Mediacontent/MediaFilterValidator.cpp [new file with mode: 0755]
src/platform/Tizen/Mediacontent/MediaFilterValidator.h [new file with mode: 0755]
src/platform/Tizen/Mediacontent/MediaSearchVisitor.cpp [new file with mode: 0755]
src/platform/Tizen/Mediacontent/MediaSearchVisitor.h [new file with mode: 0755]
src/platform/Tizen/Mediacontent/MediaWrapper.cpp [new file with mode: 0644]
src/platform/Tizen/Mediacontent/MediaWrapper.h [new file with mode: 0644]
src/platform/Tizen/Mediacontent/Mediacontent.cpp [new file with mode: 0644]
src/platform/Tizen/Mediacontent/Mediacontent.h [new file with mode: 0644]
src/platform/Tizen/Mediacontent/MediacontentManager.cpp [new file with mode: 0644]
src/platform/Tizen/Mediacontent/MediacontentManager.h [new file with mode: 0644]
src/platform/Tizen/Mediacontent/config.cmake [new file with mode: 0644]
src/platform/Tizen/Messaging/Attachment.cpp
src/platform/Tizen/Messaging/Attachment.h
src/platform/Tizen/Messaging/Email.cpp
src/platform/Tizen/Messaging/Email.h
src/platform/Tizen/Messaging/FolderQueryGenerator.cpp
src/platform/Tizen/Messaging/FolderQueryGenerator.h
src/platform/Tizen/Messaging/MessageQueryGenerator.cpp
src/platform/Tizen/Messaging/MessageQueryGenerator.h
src/platform/Tizen/Messaging/Messaging.cpp
src/platform/Tizen/Messaging/MessagingServiceManager.cpp
src/platform/Tizen/Messaging/Mms.cpp
src/platform/Tizen/Messaging/Mms.h
src/platform/Tizen/Messaging/Sms.cpp
src/platform/Tizen/NFC/NFCManager.cpp
src/platform/Tizen/NFC/NFCUtil.cpp
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/Systeminfo/Systeminfo.cpp
src/platform/Tizen/config.cmake
src/standards/Tizen/Account/AccountConverter.cpp
src/standards/Tizen/Account/AccountConverter.h
src/standards/Tizen/Account/CMakeLists.txt
src/standards/Tizen/Account/JSAccount.cpp
src/standards/Tizen/Account/JSAccount.h
src/standards/Tizen/Account/JSAccountManager.cpp
src/standards/Tizen/Account/JSAccountManager.h
src/standards/Tizen/Account/JSAccountServices.cpp
src/standards/Tizen/Account/ResponseDispatcher.cpp
src/standards/Tizen/Account/old/JSAccountService.cpp [new file with mode: 0755]
src/standards/Tizen/Account/old/JSAccountService.h [new file with mode: 0755]
src/standards/Tizen/Account/plugin_config.cpp
src/standards/Tizen/Account/plugin_config.h
src/standards/Tizen/Account/plugin_initializer.cpp
src/standards/Tizen/Alarm/AlarmAbsolute.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmAbsolute.h [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmConverter.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmConverter.h [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmRecurrence.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmRecurrence.h [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmRelative.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/AlarmRelative.h [new file with mode: 0755]
src/standards/Tizen/Alarm/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAbstractAlarm.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAbstractAlarm.h [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmAbsolute.h [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmManager.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmManager.h [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmRecurrence.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmRecurrence.h [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmRelative.cpp [new file with mode: 0755]
src/standards/Tizen/Alarm/JSAlarmRelative.h [new file with mode: 0755]
src/standards/Tizen/Alarm/config.xml [new file with mode: 0755]
src/standards/Tizen/Alarm/plugin_initializer.cpp [new file with mode: 0755]
src/standards/Tizen/Application/ApplicationAnswerReceiver.cpp
src/standards/Tizen/Application/ApplicationAnswerReceiver.h
src/standards/Tizen/Application/ApplicationConverter.cpp
src/standards/Tizen/Application/ApplicationConverter.h
src/standards/Tizen/Application/ApplicationInformationEventCallback.h [new file with mode: 0755]
src/standards/Tizen/Application/ApplicationInformationEventPrivateData.h [new file with mode: 0755]
src/standards/Tizen/Application/ApplicationListener.cpp
src/standards/Tizen/Application/CMakeLists.txt
src/standards/Tizen/Application/JSApplication.cpp
src/standards/Tizen/Application/JSApplication.h
src/standards/Tizen/Application/JSApplicationContext.cpp [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationContext.h [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationContextArray.cpp [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationContextArray.h [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationInformation.cpp
src/standards/Tizen/Application/JSApplicationInformation.h
src/standards/Tizen/Application/JSApplicationService.cpp [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationService.h [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationServiceData.cpp [new file with mode: 0755]
src/standards/Tizen/Application/JSApplicationServiceData.h [new file with mode: 0755]
src/standards/Tizen/Application/LaunchServicePrivateData.cpp
src/standards/Tizen/Application/LaunchServicePrivateData.h
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/JSBluetoothServiceHandler.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/JSCalendar.cpp
src/standards/Tizen/Calendar/JSCalendar.h
src/standards/Tizen/Calendar/JSCalendarAlarm.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarAlarm.h [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarAttendee.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarAttendee.h [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarEvent.cpp
src/standards/Tizen/Calendar/JSCalendarEvent.h
src/standards/Tizen/Calendar/JSCalendarEventId.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarEventId.h [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarItem.cpp
src/standards/Tizen/Calendar/JSCalendarItem.h
src/standards/Tizen/Calendar/JSCalendarItemGeo.cpp
src/standards/Tizen/Calendar/JSCalendarItemGeo.h
src/standards/Tizen/Calendar/JSCalendarItemProperties.cpp
src/standards/Tizen/Calendar/JSCalendarItemProperties.h
src/standards/Tizen/Calendar/JSCalendarManager.cpp
src/standards/Tizen/Calendar/JSCalendarManager.h
src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp [new file with mode: 0755]
src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.h [new file with mode: 0755]
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/CallMultiCallback.cpp [new file with mode: 0755]
src/standards/Tizen/Call/CallMultiCallback.h [new file with mode: 0755]
src/standards/Tizen/Call/CallStaticController.cpp [new file with mode: 0755]
src/standards/Tizen/Call/CallStaticController.h [new file with mode: 0755]
src/standards/Tizen/Call/Converter.cpp
src/standards/Tizen/Call/Converter.h
src/standards/Tizen/Call/JSCallHistory.cpp
src/standards/Tizen/Call/JSCallHistory.h
src/standards/Tizen/Call/JSCallHistoryEntry.cpp
src/standards/Tizen/Call/JSCallHistoryEntry.h
src/standards/Tizen/Call/JSCallManager.cpp [new file with mode: 0755]
src/standards/Tizen/Call/JSCallManager.h [new file with mode: 0755]
src/standards/Tizen/Call/JSCallService.cpp [new file with mode: 0755]
src/standards/Tizen/Call/JSCallService.h [new file with mode: 0755]
src/standards/Tizen/Call/JSCellularCallService.cpp [new file with mode: 0755]
src/standards/Tizen/Call/JSCellularCallService.h [new file with mode: 0755]
src/standards/Tizen/Call/JSRemoteParty.cpp [new file with mode: 0755]
src/standards/Tizen/Call/JSRemoteParty.h [new file with mode: 0755]
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/JSGlobalContextFactory.cpp [new file with mode: 0644]
src/standards/Tizen/Common/JSGlobalContextFactory.h [new file with mode: 0644]
src/standards/Tizen/Contact/CMakeLists.txt
src/standards/Tizen/Filesystem/Converter.cpp
src/standards/Tizen/Filesystem/Converter.h
src/standards/Tizen/Filesystem/JSFilesystemManager.cpp
src/standards/Tizen/Filesystem/JSStorage.cpp
src/standards/Tizen/Log/CMakeLists.txt [new file with mode: 0644]
src/standards/Tizen/Log/JSTizenLog.cpp [new file with mode: 0755]
src/standards/Tizen/Log/JSTizenLog.h [new file with mode: 0644]
src/standards/Tizen/Log/config.xml [new file with mode: 0644]
src/standards/Tizen/Log/plugin_initializer.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/CMakeLists.txt [new file with mode: 0755]
src/standards/Tizen/Mediacontent/JSAudio.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSAudio.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSFolder.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSFolder.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSImage.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSImage.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMedia.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMedia.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediaLyrics.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediaLyrics.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediacontent.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediacontent.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediacontentManager.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSMediacontentManager.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSVideo.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/JSVideo.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/MediaConverter.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/MediaConverter.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/MediacontentController.cpp [new file with mode: 0644]
src/standards/Tizen/Mediacontent/MediacontentController.h [new file with mode: 0644]
src/standards/Tizen/Mediacontent/config.xml [new file with mode: 0644]
src/standards/Tizen/Mediacontent/plugin_initializer.cpp [new file with mode: 0644]
src/standards/Tizen/Messaging/CMakeLists.txt
src/standards/Tizen/Messaging/ConverterMessage.cpp
src/standards/Tizen/Messaging/JSConversation.cpp
src/standards/Tizen/Messaging/JSMessage.cpp
src/standards/Tizen/Messaging/JSMessage.h
src/standards/Tizen/Messaging/JSMessageAttachment.cpp
src/standards/Tizen/Messaging/JSMessageAttachment.h
src/standards/Tizen/Messaging/JSMessageFolder.cpp
src/standards/Tizen/Messaging/JSMessagingService.cpp
src/standards/Tizen/Messaging/JSMessagingStorage.cpp
src/standards/Tizen/Messaging/config.xml
src/standards/Tizen/Messaging/plugin_initializer.cpp
src/standards/Tizen/NFC/CMakeLists.txt
src/standards/Tizen/NFC/JSNFCManager.cpp
src/standards/Tizen/NFC/JSNFCManager.h
src/standards/Tizen/NFC/JSNFCTag.cpp
src/standards/Tizen/NFC/JSNFCTag.h
src/standards/Tizen/NFC/JSNFCTagMifareClassic.cpp
src/standards/Tizen/NFC/JSNFCTagMifareClassic.h
src/standards/Tizen/NFC/JSNFCTagMifareUltra.cpp
src/standards/Tizen/NFC/JSNFCTagMifareUltra.h
src/standards/Tizen/NFC/JSNFCTarget.cpp
src/standards/Tizen/NFC/JSNFCTarget.h
src/standards/Tizen/NFC/JSNdefMessage.cpp
src/standards/Tizen/NFC/JSNdefMessage.h
src/standards/Tizen/NFC/JSNdefRecord.cpp
src/standards/Tizen/NFC/JSNdefRecord.h
src/standards/Tizen/NFC/JSNdefRecordArray.cpp [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordArray.h [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordMedia.cpp [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordMedia.h [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordText.cpp [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordText.h [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordURI.cpp [new file with mode: 0755]
src/standards/Tizen/NFC/JSNdefRecordURI.h [new file with mode: 0755]
src/standards/Tizen/NFC/NFCConverter.cpp
src/standards/Tizen/NFC/NFCConverter.h
src/standards/Tizen/NFC/ResponseDispatcher.cpp
src/standards/Tizen/NFC/plugin_initializer.cpp
src/standards/Tizen/Sensors/JSSensorConnection.cpp
src/standards/Tizen/Systeminfo/JSSysteminfo.cpp
src/standards/Tizen/TimeUtil/JSTZDate.cpp
src/standards/Tizen/TimeUtil/JSTZDate.h
src/standards/Tizen/TimeUtil/JSTimeDuration.cpp
src/standards/Tizen/TimeUtil/JSTimeDuration.h
src/standards/Tizen/Tizen/CMakeLists.txt
src/standards/Tizen/Tizen/FilterConverter.cpp
src/standards/Tizen/Tizen/FilterConverter.h
src/standards/Tizen/Tizen/JSAbstractFilterArray.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSAbstractFilterArray.h [new file with mode: 0755]
src/standards/Tizen/Tizen/JSAttributeFilter.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSAttributeFilter.h [new file with mode: 0755]
src/standards/Tizen/Tizen/JSAttributeRangeFilter.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSAttributeRangeFilter.h [new file with mode: 0755]
src/standards/Tizen/Tizen/JSCompositeFilter.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSCompositeFilter.h [new file with mode: 0755]
src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSSimpleCoordinates.h [new file with mode: 0755]
src/standards/Tizen/Tizen/JSSortMode.cpp [new file with mode: 0755]
src/standards/Tizen/Tizen/JSSortMode.h [new file with mode: 0755]
src/standards/Tizen/Tizen/plugin_initializer.cpp

index 6959f64..124a01d 100755 (executable)
@@ -2,7 +2,7 @@ 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
+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>
 
 Package: wrt-plugins-tizen
index feaf310..41b3a1f 100755 (executable)
@@ -32,12 +32,12 @@ IAccountManagerPtr AccountFactory::createAccountManagerObject()
 }
 
 //TODO: which is right, account or accountservice?
-IAccountServicePtr AccountFactory::createAccountObject()
-{
-    LogDebug("entered");
-    IAccountServicePtr result(new AccountService());
-    return result;
-}
+//IAccountServicePtr AccountFactory::createAccountObject()
+//{
+//    LogDebug("entered");
+//    IAccountServicePtr result(new AccountService());
+//    return result;
+//}
 
 AccountFactory& AccountFactory::getInstance()
 {
index 78665fc..0bf0f61 100755 (executable)
@@ -42,10 +42,10 @@ class AccountFactory : private DPL::Noncopyable
   public:
     static AccountFactory& getInstance();
     IAccountManagerPtr    createAccountManagerObject();
-    IAccountServicePtr           createAccountObject();
+//    IAccountServicePtr           createAccountObject();
 };
 }
 }
 }
 
-#endif /* WRTPLUGINSCAMERAFACTORY_H_ */
\ No newline at end of file
+#endif /* WRTPLUGINSCAMERAFACTORY_H_ */
diff --git a/src/platform/API/Account/AccountServiceFilterProperty.cpp b/src/platform/API/Account/AccountServiceFilterProperty.cpp
new file mode 100644 (file)
index 0000000..4617f85
--- /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.
+ */
+
+/*
+ * 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
new file mode 100644 (file)
index 0000000..ebebeb5
--- /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.
+ */
+
+/*
+ * 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_ */
index 6fda807..7a6fff6 100755 (executable)
@@ -30,6 +30,7 @@
 
 #include <string>
 #include <dpl/shared_ptr.h>
+#include <vector>
 
 namespace TizenApis {
        namespace Api {
@@ -59,6 +60,9 @@ namespace TizenApis {
                        };
 
                        typedef DPL::SharedPtr<AccountServiceProviderProperty> AccountServiceProviderPropertyPtr;
+                       typedef std::vector<AccountServiceProviderPropertyPtr> AccountServiceProviderPropertyArray;
+                       typedef DPL::SharedPtr<AccountServiceProviderPropertyArray> AccountServiceProviderPropertyArrayPtr;
+
                } /* namespace Account */
        } /* namespace Api */
 } /* namespace TizenApis */
index 005b66c..78bde02 100755 (executable)
@@ -120,13 +120,13 @@ void EventAccount::setEnabled(bool &value)
     m_enabled = value;
 }
 
-unsigned long EventAccount::getCredentailId() const
+std::string EventAccount::getCredentailId() const
 {
     LogDebug("entered");
     return m_credentialId;
 }
 
-void EventAccount::setCredentailId(unsigned long &value)
+void EventAccount::setCredentailId(const std::string &value)
 {
     LogDebug("entered");
     m_credentialId = value;
@@ -140,7 +140,7 @@ std::string EventAccount::getSettings() const
 
 void EventAccount::setSettings(const std::string &value)
 {
-    LogDebug("entered");
+    LogDebug("<<< value:[" << value << "]");
     m_settings = value;
 }
 
index 968ed2d..f6369c5 100755 (executable)
@@ -64,8 +64,8 @@ class EventAccount
        bool getEnabled() const;
        void setEnabled(bool &value);
 
-       unsigned long getCredentailId() const;
-       void setCredentailId(unsigned long &value);
+       std::string getCredentailId() const;
+       void setCredentailId(const std::string &value);
 
        std::string getSettings() const;
        void setSettings(const std::string &value);
@@ -101,7 +101,7 @@ class EventAccount
        std::string m_iconPath;
        std::string m_providername;
        bool m_enabled;
-       unsigned long m_credentialId;
+       std::string m_credentialId;
        std::string m_settings;
 
        std::string m_serviceTypeId;
index 7b9febe..85df38b 100755 (executable)
@@ -28,7 +28,7 @@ namespace TizenApis {
 namespace Api {
 namespace Account{
 IAccountManager::IAccountManager() :
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetAccountServices >(WrtDeviceApis::Commons::ThreadEnum::ACCOUNT_THREAD),
+//    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),
@@ -37,7 +37,10 @@ IAccountManager::IAccountManager() :
     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< 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");
 }
@@ -48,11 +51,11 @@ IAccountManager::~IAccountManager()
 }
 
 
-void IAccountManager::getAccountServices(const IEventGetAccountServicesPtr &event)
-{
-    LogDebug("entered");
-    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountServices>::PostRequest(event);
-}
+//void IAccountManager::getAccountServices(const IEventGetAccountServicesPtr &event)
+//{
+//    LogDebug("entered");
+//    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetAccountServices>::PostRequest(event);
+//}
 
 void IAccountManager::addAccount(const IEventAddAccountPtr &event)
 {
@@ -72,6 +75,11 @@ void IAccountManager::findAccounts(const IEventFindAccountsPtr &event)
     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);
@@ -96,6 +104,18 @@ void IAccountManager::getServiceTypeById(const IEventGetServiceTypeByIdPtr &even
     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");
index f35a9df..c9f7cf2 100755 (executable)
 #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< IEventGetAccountServices >,
+class IAccountManager :
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventAddAccount > ,
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventDeleteAccount >,
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindAccounts >,
@@ -42,14 +45,17 @@ class IAccountManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEv
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetServiceTypeById >,
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetProviderById >,
        public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindProviders >,
-       public WrtDeviceApis::Commons::EventRequestReceiver< IEventFindServiceTypes >
+       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 getAccountServices(const IEventGetAccountServicesPtr &event);
 
        virtual void addAccount(const IEventAddAccountPtr &event);
 
@@ -57,6 +63,8 @@ class IAccountManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEv
 
        virtual void findAccounts(const IEventFindAccountsPtr &event);
 
+       virtual void findServices(const IEventFindServicesPtr &event);
+
        virtual void findServiceTypes(const IEventFindServiceTypesPtr &event);
 
        virtual void updateAccount(const IEventUpdateAccountPtr &event);
@@ -65,13 +73,16 @@ class IAccountManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEv
 
        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 IEventGetAccountServicesPtr &event) = 0;
 
        virtual void OnRequestReceived(const IEventAddAccountPtr &event) = 0;
 
@@ -91,6 +102,12 @@ class IAccountManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEv
 
        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;
index d4ac491..6c4241a 100755 (executable)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 /*
  * @author      Lukasz Marek (l.marek@samsung.com)
  * @version     0.1
 
 #include <vector>
 #include <Commons/IEvent.h>
-#include "EventAccount.h"
-#include "AccountFilter.h"
+
 #include <dpl/shared_ptr.h>
 
+#include "AccountServiceFilterProperty.h"
+
 namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventFindAccounts : public WrtDeviceApis::Commons::IEvent<IEventFindAccounts>
-{
-    /* user is responsible to free objects inside list */
-    std::vector<EventAccountPtr> m_events;
-    bool m_result;
-    AccountFilterPtr m_filter;
-    int m_firstEvent;
-    int m_lastEvent;
-  public:
-
-    void                        setFilter(AccountFilterPtr value)
-    {
-        m_filter = value;
-    }
-    AccountFilterPtr              getFilter() const
-    {
-        return m_filter;
-    }
-
-    void                        setFirstEvent(int value)
-    {
-        LogDebug("entered");
-        m_firstEvent = value;
-    }
-    int                         getFirstEvent() const
-    {
-        LogDebug("entered");
-        return m_firstEvent;
-    }
-    void                        setLastEvent(int value)
-    {
-        LogDebug("entered");
-        m_lastEvent = value;
-    }
-    int                         getLastEvent() const
-    {
-        LogDebug("entered");
-        return m_lastEvent;
-    }
-    void                        setResult(bool value)
-    {
-        LogDebug("entered");
-        m_result = value;
-    }
-    bool                        getResult() const
-    {
-        LogDebug("entered");
-        return m_result;
-    }
-    void                        addEvent(EventAccountPtr value)
-    {
-        LogDebug("entered");
-        m_events.push_back(value);
-    }
-    std::vector<EventAccountPtr> getEvents()
-    {
-        LogDebug("entered");
-        return m_events;
-    }
-    IEventFindAccounts() : m_result(false),
-        m_firstEvent(0),
-        m_lastEvent(-1)
-    {
-    }
-    ~IEventFindAccounts()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
-
-typedef DPL::SharedPtr<IEventFindAccounts> IEventFindAccountsPtr;
-}
-}
+       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_ */
index 581f6bc..40b35ea 100644 (file)
  */
 
 
-/*
- * @author      Lukasz Marek (l.marek@samsung.com)
- * @version     0.1
- * @brief
+/* IEventFindProviders.h
+ *
+ *  Created on: 2012. 2. 1.
+ *      Author: sangtai
  */
 
-#ifndef _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_H_
-#define _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_H_
+#ifndef IEVENTFINDPROVIDERS_H_
+#define IEVENTFINDPROVIDERS_H_
 
 #include <dpl/shared_ptr.h>
 #include <Commons/IEvent.h>
-#include "EventAccount.h"
 
 namespace TizenApis {
-namespace Api {
-namespace Account{
-class IEventFindProviders : public WrtDeviceApis::Commons::IEvent<IEventFindProviders>
-{
-    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;
-    }
-    IEventFindProviders() : m_event(NULL),
-        m_result(false)
-    {
-    }
-    ~IEventFindProviders()
-    {
-    }
-    virtual void clearOnCancel()
-    {
-    }
-};
+       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;
-}
-}
-}
-#endif /* _ABSTRACT_LAYER_IEVENT_FIND_PROVIDER_H_ */
+                       typedef DPL::SharedPtr<IEventFindProviders> IEventFindProvidersPtr;
 
+               } /* namespace Account */
+       } /* namespace Api */
+} /* namespace TizenApis */
+#endif /* IEVENTFINDPROVIDERS_H_ */
index 74cf326..bd3b991 100755 (executable)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 /*
  * IEventFindServiceTypes.h
  *
diff --git a/src/platform/API/Account/IEventFindServices.h b/src/platform/API/Account/IEventFindServices.h
new file mode 100644 (file)
index 0000000..d38faaf
--- /dev/null
@@ -0,0 +1,85 @@
+/*
+ * 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/IEventGetServiceById.h b/src/platform/API/Account/IEventGetServiceById.h
new file mode 100644 (file)
index 0000000..6fee772
--- /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.
+ */
+
+
+/*
+ * 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
new file mode 100644 (file)
index 0000000..d2b4ea7
--- /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.
+ */
+
+
+/*
+ * 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_ */
index bbc0820..5bbc2e5 100755 (executable)
@@ -8,6 +8,6 @@ set(SRCS_PLATFORM_API_ACCOUNT
   ${CURRENT_PATH}/AccountServices.cpp
   ${CURRENT_PATH}/AccountServiceTypeProperty.cpp
   ${CURRENT_PATH}/AccountServiceProviderProperty.cpp
-  
+  ${CURRENT_PATH}/AccountServiceFilterProperty.cpp
   PARENT_SCOPE
 )
diff --git a/src/platform/API/Application/ApplicationContext.cpp b/src/platform/API/Application/ApplicationContext.cpp
new file mode 100755 (executable)
index 0000000..38d4bac
--- /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.
+ */
+
+#include "ApplicationContext.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Application {        
+ApplicationContext::ApplicationContext()
+{
+}
+
+ApplicationContext::~ApplicationContext()
+{
+}
+
+std::string ApplicationContext::getAppId() const
+{
+       return m_appId;
+}
+void ApplicationContext::setAppId(const std::string &appId)
+{
+       m_appId = appId;
+}
+
+std::string ApplicationContext::getContextId() const
+{
+       return m_contextId;
+}
+void ApplicationContext::setContextId(const std::string &contextId)
+{
+       m_contextId = contextId;
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Application/ApplicationContext.h b/src/platform/API/Application/ApplicationContext.h
new file mode 100755 (executable)
index 0000000..67dca55
--- /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 TIZENAPIS_API_APPLICATION_CONTEXT_H_
+#define TIZENAPIS_API_APPLICATION_CONTEXT_H_
+
+#include <string>
+#include <vector>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+
+class ApplicationContext;
+typedef DPL::SharedPtr<ApplicationContext> ApplicationContextPtr;
+
+typedef std::vector<ApplicationContextPtr> ApplicationContextArray;
+typedef DPL::SharedPtr<ApplicationContextArray> ApplicationContextArrayPtr;
+
+class ApplicationContext
+{
+  public:
+    ApplicationContext();
+    ~ApplicationContext();
+
+       std::string getAppId() const;
+       void setAppId(const std::string &appId);
+       std::string getContextId() const;
+       void setContextId(const std::string &contextId);
+
+
+  private:
+    std::string        m_appId;
+    std::string        m_contextId;
+
+};
+}
+}
+}
+#endif
index 09286ea..60e8e4c 100755 (executable)
@@ -41,11 +41,23 @@ ApplicationInformationPtr ApplicationEvent::getApplicationInformation() const
 {
        return m_appinfo;
 }
+
 void ApplicationEvent::setApplicationInformation(const ApplicationInformationPtr &appinfo)
 {
        m_appinfo = appinfo;
 }
 
+ApplicationContextPtr ApplicationEvent::getApplicationContext() const
+{
+       return m_contextinfo;
+}
+
+void ApplicationEvent::setApplicationContext(const ApplicationContextPtr &contextinfo)
+{
+       m_contextinfo = contextinfo;
+}
+
+
 }
 }
 }
index b58d6bb..88d75a9 100755 (executable)
 #include <dpl/log/log.h>
 #include <dpl/shared_ptr.h>
 #include "ApplicationInformation.h"
-
-
-#define APPLICATON_EVENT_CODE_INSTALLED "INSTALLED"
-#define APPLICATON_EVENT_CODE_UNINSTALLED "UNINSTALLED"
-#define APPLICATON_EVENT_CODE_UPDATED "UPDATED"
-
+#include "ApplicationContext.h"
 
 namespace TizenApis {
 namespace Api {
@@ -48,9 +43,14 @@ class ApplicationEvent
 
        ApplicationInformationPtr getApplicationInformation() const;
        void setApplicationInformation(const ApplicationInformationPtr &appinfo);
+
+       ApplicationContextPtr getApplicationContext() const;
+       void setApplicationContext(const ApplicationContextPtr &contextinfo);
+
        
   private:
     ApplicationInformationPtr m_appinfo;
+       ApplicationContextPtr m_contextinfo;
        std::string m_code;
 };
 
index 9bfa9da..edfc672 100755 (executable)
@@ -36,13 +36,13 @@ void ApplicationInformation::setName(const std::string &name)
        m_name = name;
 }
 
-std::string ApplicationInformation::getPackage() const
+std::string ApplicationInformation::getAppId() const
 {
-       return m_package;
+       return m_appId;
 }
-void ApplicationInformation::setPackage(const std::string &package)
+void ApplicationInformation::setAppId(const std::string &appId)
 {
-       m_package = package;
+       m_appId = appId;
 }
 
 std::string ApplicationInformation::getIconPath() const
index 94f5a5b..25792a0 100755 (executable)
@@ -40,8 +40,8 @@ class ApplicationInformation
 
        std::string getName() const;
        void setName(const std::string &name);
-       std::string getPackage() const;
-       void setPackage(const std::string &package);
+       std::string getAppId() const;
+       void setAppId(const std::string &appId);
        std::string getIconPath() const;
        void setIconPath(const std::string &iconPath);
        std::string getVersion() const;
@@ -49,7 +49,7 @@ class ApplicationInformation
 
   private:
     std::string        m_name;
-    std::string        m_package;
+    std::string        m_appId;
     std::string        m_iconPath;
     std::string        m_version;      
 };
diff --git a/src/platform/API/Application/ApplicationService.cpp b/src/platform/API/Application/ApplicationService.cpp
new file mode 100755 (executable)
index 0000000..b3998ea
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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        ApplicationService.cpp
+ * @author      Youngkyeong Yun (yk.yun@samsung.com)
+ * @version     0.1
+ */
+
+
+#include "ApplicationService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+
+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, std::vector<ApplicationServiceDataPtr> &dataArray) :
+       m_service(NULL)
+{
+    LogDebug("entered");
+       m_operation = op;
+       m_uri = uri;
+       m_mime = mime;
+       m_serviceDataArray = dataArray;
+}
+
+ApplicationService::~ApplicationService()
+{
+    //nothing to do in destructor
+    LogDebug("entered");
+}
+
+std::string ApplicationService::getOperation() const
+{
+       return m_operation;
+}
+
+void ApplicationService::setOperation(const std::string &operation)
+{
+       m_operation = operation;
+}
+
+std::string ApplicationService::getUri() const
+{
+       return m_uri;
+}
+
+void ApplicationService::setUri(const std::string &uri)
+{
+       m_uri = uri;
+}
+
+std::string ApplicationService::getMime() const
+{
+       return m_mime;
+}
+
+void ApplicationService::setMime(const std::string &mime)
+{
+       m_mime = mime;
+}
+
+std::vector<ApplicationServiceDataPtr> ApplicationService::getServiceDataArray() const
+{
+       return m_serviceDataArray;
+}
+
+void ApplicationService::setServiceDataArray(std::vector<ApplicationServiceDataPtr> &dataArray)
+{
+       m_serviceDataArray = dataArray;
+}
+
+void ApplicationService::addServiceData(const ApplicationServiceDataPtr &data)
+{
+       m_serviceDataArray.push_back(data);
+       
+}
+
+service_h ApplicationService::getService_h() const
+{
+       return m_service;
+}
+void ApplicationService::setService_h(const service_h service)
+{
+       m_service = service;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Application/ApplicationService.h b/src/platform/API/Application/ApplicationService.h
new file mode 100755 (executable)
index 0000000..88ade61
--- /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 TIZENAPIS_API_APPLICATION_SERVICE_H_
+#define TIZENAPIS_API_APPLICATION_SERVICE_H_
+
+#include <string>
+#include <vector>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <app_service.h>
+#include "ApplicationServiceData.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+
+class ApplicationService;
+typedef DPL::SharedPtr<ApplicationService> ApplicationServicePtr;
+
+/* This object represents a single extra data for service request and reply */
+class ApplicationService
+{
+  public:
+    ApplicationService();
+       ApplicationService(const std::string &op, const std::string &uri, const std::string &mime, std::vector<ApplicationServiceDataPtr> &dataArray) ;
+    ~ApplicationService();
+
+       std::string getOperation() const;
+       void setOperation(const std::string &operation);
+
+       std::string getUri() const;
+       void setUri(const std::string &uri);
+
+       std::string getMime() const;
+       void setMime(const std::string &uri);
+
+       std::vector<ApplicationServiceDataPtr> getServiceDataArray() const;
+       void setServiceDataArray(std::vector<ApplicationServiceDataPtr> &dataArray);
+       void addServiceData(const ApplicationServiceDataPtr &data);
+
+       service_h getService_h() const;
+       void setService_h(const service_h service);  
+
+       
+  private:
+       std::string m_operation;
+       std::string m_uri;
+       std::string m_mime;
+       std::vector<ApplicationServiceDataPtr> m_serviceDataArray;
+       service_h m_service;
+};
+}
+}
+}
+#endif
diff --git a/src/platform/API/Application/ApplicationServiceData.cpp b/src/platform/API/Application/ApplicationServiceData.cpp
new file mode 100755 (executable)
index 0000000..66a491b
--- /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 "ApplicationServiceData.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+ApplicationServiceData::ApplicationServiceData()
+{
+    LogDebug("entered");
+}
+
+ApplicationServiceData::~ApplicationServiceData()
+{
+    //nothing to do in destructor
+    LogDebug("entered");
+}
+
+std::string ApplicationServiceData::getKey() const
+{
+       return m_key;
+}
+
+void ApplicationServiceData::setKey(const std::string &key)
+{
+       m_key = key;
+}
+
+std::vector<std::string> ApplicationServiceData::getValue() const
+{
+       return m_value;
+}
+void ApplicationServiceData::setValue(const std::vector<std::string> &value)
+{
+       m_value = value;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Application/ApplicationServiceData.h b/src/platform/API/Application/ApplicationServiceData.h
new file mode 100755 (executable)
index 0000000..486c969
--- /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 TIZENAPIS_API_APPLICATION_SERVICE_DATA_H_
+#define TIZENAPIS_API_APPLICATION_SERVICE_DATA_H_
+
+#include <string>
+#include <vector>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+
+class ApplicationServiceData;
+typedef DPL::SharedPtr<ApplicationServiceData> ApplicationServiceDataPtr;
+
+/* This object represents a single extra data for service request and reply */
+class ApplicationServiceData
+{
+  public:
+    ApplicationServiceData();
+    ~ApplicationServiceData();
+
+       std::string getKey() const;
+       void setKey(const std::string &key);
+
+       std::vector<std::string> getValue() const;
+       void setValue(const std::vector<std::string> &value);
+       
+  private:
+    std::string        m_key;
+       std::vector<std::string>        m_value;
+};
+}
+}
+}
+#endif
index ce631a6..9ca6dab 100755 (executable)
@@ -20,6 +20,7 @@
 #include <Commons/IEvent.h>
 #include <dpl/shared_ptr.h>
 #include "ApplicationInformation.h"
+#include "ApplicationContext.h"
 
 namespace TizenApis {
 namespace Api {
@@ -28,7 +29,15 @@ namespace Application {
 class EventGetApplication: public WrtDeviceApis::Commons::IEvent<EventGetApplication> {
 private:
        ApplicationInformationPtr m_appinfo;
-       std::string  m_package; 
+       ApplicationContextPtr m_contextinfo;
+       std::string  m_appId;
+       std::string  m_contextId;
+       int m_eventType;        
+
+public:
+       static const int APP_MANAGER_UNKNOWN = 0;
+       static const int APP_MANAGER_GET_INFORMATION = 1;
+       static const int APP_MANAGER_GET_CONTEXT = 2;
 
 public:
        void setApplicationInformation(const ApplicationInformationPtr appinfo)
@@ -40,20 +49,49 @@ public:
        {
                return m_appinfo;
        }
+
+       void setApplicationContext(const ApplicationContextPtr contextinfo)
+       {
+               m_contextinfo = contextinfo;
+       }
+
+       ApplicationContextPtr getApplicationContext() const 
+       {
+               return m_contextinfo;
+       }
        
-       void setPackage(std::string package)
+       void setAppId(std::string appId)
+       {
+               m_appId = appId;
+       }
+
+       std::string getAppId() const
+       {
+               return m_appId;
+       }
+
+       void setContextId(std::string contextId)
        {
-               m_package = package;
+               m_contextId = contextId;
        }
 
-       std::string getPackage() const
+       std::string getContextId() const
        {
-               return m_package;
+               return m_contextId;
        }
 
        EventGetApplication() 
        {
        }
+
+       void setEventType(int type){
+               m_eventType = type;
+       }
+
+       int getEventType(){
+               return m_eventType;
+       }       
+       
 };
 
 typedef DPL::SharedPtr<EventGetApplication> EventGetApplicationPtr;
@@ -62,4 +100,4 @@ typedef DPL::SharedPtr<EventGetApplication> EventGetApplicationPtr;
 } // Api
 } // TizenApis
 
-#endif
\ No newline at end of file
+#endif
index 2f7f2c8..8f90fbc 100755 (executable)
 #include "ApplicationInformation.h"
 #include "ApplicationEvent.h"
 
+#define APPLICATON_EVENT_CODE_INSTALLED "INSTALLED"
+#define APPLICATON_EVENT_CODE_UNINSTALLED "UNINSTALLED"
+#define APPLICATON_EVENT_CODE_UPDATED "UPDATED"
+
 namespace TizenApis {
 namespace Api {
 namespace Application {
index 57375a8..652c351 100755 (executable)
 
 #include <Commons/IEvent.h>
 #include <dpl/shared_ptr.h>
-#include "ApplicationServiceRequest.h"
-#include "ApplicationServiceReply.h"
-#include "ApplicationServiceExtraData.h"
+#include "ApplicationService.h"
+//#include "ApplicationServiceReply.h"
+#include "ApplicationServiceData.h"
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Api {
@@ -32,55 +33,73 @@ namespace Application {
 class EventLaunchService: public WrtDeviceApis::Commons::IEvent<EventLaunchService> {
 
 private:
-       ApplicationServiceRequestPtr m_request;
-       ApplicationServiceReplyPtr m_reply;
-       int callbackType;
+       ApplicationServicePtr m_service;
+       int callbackType;
+       int m_eventType;
 
 public:
-       /* EVENT TYPE */
+/* CALLBACK TYPE */
        static const int APPLICATION_SERVICE_UNKNOWN = 0;
        static const int APPLICATION_SERVICE_CALLBACK = 1;
        static const int APPLICATION_SERVICE_REPLY_SUCCESS_CALLBACK = 2;
        static const int APPLICATION_SERVICE_REPLY_FAIL_CALLBACK = 3;
-       static const int APPLICATION_SERVICE_REPLY_CANCEL_CALLBACK = 4; 
-public:        
-       void addExtraDataToReply(std::string &key, std::string &value){
+/* EVENT TYPE */       
+       static const int APPLICATION_SERVICE_LAUNCH = 4;
+       static const int APPLICATION_SERVICE_GET_REQUEST = 5;
+ public:       
+       void addServiceData(std::string &key, std::vector<std::string> &value) {
                
-               ApplicationServiceExtraDataPtr extraData(new ApplicationServiceExtraData());
-               extraData->setKey(key);
-               extraData->setValue(value);
+               ApplicationServiceDataPtr serviceData(new ApplicationServiceData());
+               serviceData->setKey(key);
+               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());
                        
-                       ApplicationServiceExtraDataArrayPtr extraDataArray(new ApplicationServiceExtraDataArray());
-                       reply->setExtraDataArray(extraDataArray);
-                       setServiceReply(reply);
+                       //ApplicationServiceDataPtr extraDataArray(new ApplicationServiceData());
+                       reply->setServiceDataArray(extraData);
+                       setService(reply);
                }
-               m_reply->addExtraData(extraData);
+               //m_reply->addExtraData(extraData);
+#endif         
        }
-       
-
-       void setServiceRequest(ApplicationServiceRequestPtr &appservice){
-               m_request = appservice;
+       void setService(ApplicationServicePtr &appservice){
+               m_service = appservice;
        }
 
-       ApplicationServiceRequestPtr getServiceRequest() const{
-               return m_request;
+       ApplicationServicePtr getService() const{
+               return m_service;
        }
 
-       void setServiceReply(ApplicationServiceReplyPtr &serviceReply){
-               m_reply = serviceReply;
-       }
-       ApplicationServiceReplyPtr getServiceReply() const{
-               return m_reply;
-       }
        void setCallbackType(int callbacktype){
                callbackType = callbacktype;
        }
+
        int getCallbackType() const{
                return callbackType;
+       }
+
+       void setEventType(int type){
+               m_eventType = type;
+       }
+
+       int getEventType(){
+               return m_eventType;
        }       
+       
        EventLaunchService() 
        {
        }               
index b9f1ec4..f76e4bb 100755 (executable)
@@ -20,6 +20,7 @@
 #include <Commons/IEvent.h>
 #include <dpl/shared_ptr.h>
 #include "ApplicationInformation.h"
+#include "ApplicationContext.h"
 
 namespace TizenApis {
 namespace Api {
@@ -28,6 +29,7 @@ namespace Application {
 class EventListInstalledApplications: public WrtDeviceApis::Commons::IEvent<EventListInstalledApplications> {
 private:
        ApplicationInformationArrayPtr m_appinfoArray;
+       ApplicationContextArrayPtr m_contextinfoArray;
        int m_eventType;
 public:
        static const int APPMANAGER_UNKNOWN = 0;
@@ -44,7 +46,7 @@ public:
                }
                m_appinfoArray->push_back(appinfo);
        }
-       
+
        const ApplicationInformationArrayPtr getApplicationInformationArray() const
        {
                return m_appinfoArray;
@@ -53,6 +55,25 @@ public:
        void setApplicationInformationArray(ApplicationInformationArrayPtr appinfoArray){
                m_appinfoArray = appinfoArray;
        }
+
+       void addApplicationContext(const ApplicationContextPtr contextinfo)
+       {
+               if( !m_contextinfoArray )
+               {
+                       ApplicationContextArrayPtr contextinfos(new ApplicationContextArray());
+                       setApplicationContextArray(contextinfos);
+               }
+               m_contextinfoArray->push_back(contextinfo);
+       }
+       
+       const ApplicationContextArrayPtr getApplicationContextArray() const
+       {
+               return m_contextinfoArray;
+       }
+
+       void setApplicationContextArray(ApplicationContextArrayPtr appcontextArray){
+               m_contextinfoArray = appcontextArray;
+       }       
        
        void setEventType(int type){
                m_eventType = type;
@@ -73,4 +94,4 @@ typedef DPL::SharedPtr<EventListInstalledApplications> EventListInstalledApplica
 } // Api
 } // TizenApis
 
-#endif
\ No newline at end of file
+#endif
diff --git a/src/platform/API/Application/EventManageApplication.h b/src/platform/API/Application/EventManageApplication.h
new file mode 100755 (executable)
index 0000000..c3bb0bc
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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_EVENT_MANAGE_APPLICATION_H_
+#define TIZENAPIS_API_EVENT_MANAGE_APPLICATION_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "ApplicationInformation.h"
+#include "ApplicationContext.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Application {
+
+class EventManageApplication: public WrtDeviceApis::Commons::IEvent<EventManageApplication> {
+private:
+       ApplicationInformationPtr       m_appinfo;
+       ApplicationContextPtr           m_contextinfo;
+       std::string                                     m_appId;
+       std::string                                     m_contextId;
+       std::string                                     m_argument;
+       int m_eventType;        
+
+public:
+       static const int APP_MANAGER_UNKNOWN = 0;
+       static const int APP_MANAGER_KILL_APPLICATION = 1;
+       static const int APP_MANAGER_HIDE_APPLICATION = 2;
+       static const int APP_MANAGER_LAUNCH_APPLICATION = 3;
+
+public:
+       void setApplicationInformation(const ApplicationInformationPtr appinfo)
+       {
+               m_appinfo = appinfo;
+       }
+
+       ApplicationInformationPtr getApplicationInformation() const 
+       {
+               return m_appinfo;
+       }
+
+       void setApplicationContext(const ApplicationContextPtr contextinfo)
+       {
+               m_contextinfo = contextinfo;
+       }
+
+       ApplicationContextPtr getApplicationContext() const 
+       {
+               return m_contextinfo;
+       }
+       
+       void setAppId(std::string appId)
+       {
+               m_appId = appId;
+       }
+
+       std::string getAppId() const
+       {
+               return m_appId;
+       }
+
+       void setContextId(std::string contextId)
+       {
+               m_contextId = contextId;
+       }
+
+       std::string getContextId() const
+       {
+               return m_contextId;
+       }
+
+       void setArgument(std::string argu)
+       {
+               m_argument = argu;
+       }
+
+       std::string getArgument() const
+       {
+               return m_argument;
+       }
+
+       EventManageApplication() 
+       {
+       }
+
+       void setEventType(int type){
+               m_eventType = type;
+       }
+
+       int getEventType(){
+               return m_eventType;
+       }       
+       
+};
+
+typedef DPL::SharedPtr<EventManageApplication> EventManageApplicationPtr;
+
+} // Application
+} // Api
+} // TizenApis
+
+#endif
index 32d6eec..a3357d9 100755 (executable)
@@ -24,6 +24,7 @@ using namespace WrtDeviceApis::Commons;
 
 IApplication::IApplication() :
                EventRequestReceiver<EventListInstalledApplications>(ThreadEnum::APPLICATION_THREAD),
+               EventRequestReceiver<EventManageApplication>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventGetApplication>(ThreadEnum::APPLICATION_THREAD),
                EventRequestReceiver<EventLaunchService>(ThreadEnum::APPLICATION_THREAD)
 {
index 0a155f7..496a195 100755 (executable)
@@ -20,6 +20,7 @@
 #include <dpl/shared_ptr.h>
 #include <Commons/ThreadPool.h>
 #include "EventListInstalledApplications.h"
+#include "EventManageApplication.h"
 #include "EventGetApplication.h"
 #include "EventInstalledApplicationChanged.h"
 #include "EventLaunchService.h"
@@ -29,25 +30,33 @@ namespace Api {
 namespace Application {
 
 class EventListInstalledApplications;
+class EventManageApplication;
 class EventGetApplication;
 class EventLaunchService;
 
 class IApplication: public WrtDeviceApis::Commons::EventRequestReceiver<EventListInstalledApplications>,
+       public WrtDeviceApis::Commons::EventRequestReceiver<EventManageApplication>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventGetApplication>,
        public WrtDeviceApis::Commons::EventRequestReceiver<EventLaunchService>
 {
 public:
        virtual ~IApplication();
+       virtual void launch(const EventManageApplicationPtr& event) = 0;
+       virtual void kill(const EventManageApplicationPtr& event) = 0;
+       virtual void exit() = 0;
+       virtual void hide(const EventManageApplicationPtr& event) = 0;
        virtual void listApplications(const EventListInstalledApplicationsPtr& event) = 0;
-       virtual void getApplicationInformation(const EventGetApplicationPtr& event) = 0;
-       virtual long addApplicationListChangeListener(const EventInstalledApplicationChangedEmitterPtr& emitter) = 0;
-       virtual void removeApplicationListChangeListener(const EventInstalledApplicationChangedEmitter::IdType id) = 0; 
+       virtual void getApplication(const EventGetApplicationPtr& event) = 0;
+       virtual long addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter) = 0;
+       virtual void removeApplicationInformationEventListener(const EventInstalledApplicationChangedEmitter::IdType id) = 0;   
        virtual void launchService(const EventLaunchServicePtr& event) = 0;
+       virtual void getApplicationService(const EventLaunchServicePtr& event) = 0;
 
  protected:
        IApplication();
 
        virtual void OnRequestReceived(const EventListInstalledApplicationsPtr& event) = 0;
+       virtual void OnRequestReceived(const EventManageApplicationPtr& event) = 0;
        virtual void OnRequestReceived(const EventGetApplicationPtr& event) = 0;
        virtual void OnRequestReceived(const EventLaunchServicePtr& event) = 0;
 
index ab2158f..dbd3b34 100755 (executable)
@@ -3,9 +3,9 @@ set(SRCS_PLATFORM_API_APPLICATION
   ${CURRENT_PATH}/ApplicationFactory.cpp
   ${CURRENT_PATH}/IApplication.cpp
   ${CURRENT_PATH}/ApplicationInformation.cpp
+  ${CURRENT_PATH}/ApplicationContext.cpp
   ${CURRENT_PATH}/ApplicationEvent.cpp
-  ${CURRENT_PATH}/ApplicationServiceExtraData.cpp
-  ${CURRENT_PATH}/ApplicationServiceRequest.cpp
-  ${CURRENT_PATH}/ApplicationServiceReply.cpp
+  ${CURRENT_PATH}/ApplicationService.cpp  
+  ${CURRENT_PATH}/ApplicationServiceData.cpp
   PARENT_SCOPE
 )
index 16a043c..76b7e52 100755 (executable)
@@ -25,16 +25,101 @@ namespace Calendar {
 
 CalendarEvent::CalendarEvent() :
     m_calendarId(UNDEFINED_CALENDAR_ID),
+    m_recurrence(new EventRecurrenceRule()),
     m_status(UNDEFINED_STATUS),
     m_categories(new CategoryList()),
     m_isAllDay(false),
     m_recurrenceId(0),
+    m_attendees(new EventAttendeeList()),
     m_isDetached(false),
+    m_attributesOfInterest(new AttributeList()),
     m_geolocation(new CalendarItemGeo()),
     m_calendarType(EVENT_TYPE)
 {
 }
 
+CalendarEvent::CalendarEvent(const CalendarEvent &original)
+{
+    LogDebug("Copy constructor called.");
+
+    m_id = original.getId();
+    m_calendarId = original.getCalendarId();
+    m_description = original.getDescription();
+    m_subject = original.getSubject();
+    m_startTime = original.getStartTime();
+    m_endTime = original.getEndTime();
+    m_location = original.getLocation();
+
+    EventRecurrenceRulePtr recurrenceRulePtr( new EventRecurrenceRule() );
+    m_recurrence = recurrenceRulePtr;
+    m_recurrence->setFrequency(original.getRecurrenceRule()->getFrequency());
+    m_recurrence->setInterval(original.getRecurrenceRule()->getInterval());
+    m_recurrence->setEndDate(original.getRecurrenceRule()->getEndDate());
+    m_recurrence->setOccurrenceCount(original.getRecurrenceRule()->getOccurrenceCount());
+    m_recurrence->setDaysOfTheMonth(original.getRecurrenceRule()->getDaysOfTheMonth());
+    m_recurrence->setDaysOfTheWeek(original.getRecurrenceRule()->getDaysOfTheWeek());
+    m_recurrence->setDaysOfTheYear(original.getRecurrenceRule()->getDaysOfTheYear());
+    m_recurrence->setWeeksOfTheYear(original.getRecurrenceRule()->getWeeksOfTheYear());
+    m_recurrence->setSetPosition(original.getRecurrenceRule()->getSetPosition());
+    m_recurrence->setExceptions(original.getRecurrenceRule()->getExceptions());
+    m_recurrence->setTimeZone(original.getRecurrenceRule()->getTimeZone());
+
+    m_status = original.getStatus();
+    m_alarmsTick = original.getAlarmsTick();
+    m_alarmsType = original.getAlarmsType();
+    m_alarmsDescription = original.getAlarmsDescription();
+
+    CategoryListPtr categoriesPtr( new CategoryList() );
+    m_categories = categoriesPtr;
+    *m_categories = *(original.getCategories());
+
+    m_isAllDay = original.getIsAllDay();
+    m_organizer = original.getOrganizer();
+    m_lastModifiedDate = original.getLastModifiedDate();
+    m_visibility = original.getVisibility();
+    m_availability = original.getAvailability();
+    m_uid = original.getUId();
+    m_recurrenceId = original.getRecurrenceId();
+
+    LogDebug("Copying attendees...");
+    EventAttendeeListPtr attendeesPtr( new EventAttendeeList() );
+    m_attendees = attendeesPtr;
+    for( unsigned int i=0; i<original.getAttendees()->size(); i++) {
+        EventAttendeePtr attendeePtr( new EventAttendee() );
+        attendeePtr->setName(original.getAttendees()->at(i)->getName());
+        attendeePtr->setURI(original.getAttendees()->at(i)->getURI());
+        attendeePtr->setRole(original.getAttendees()->at(i)->getRole());
+        attendeePtr->setStatus(original.getAttendees()->at(i)->getStatus());
+        attendeePtr->setRSVP(original.getAttendees()->at(i)->getRSVP());
+        attendeePtr->setType(original.getAttendees()->at(i)->getType());
+        attendeePtr->setGroup(original.getAttendees()->at(i)->getGroup());
+        attendeePtr->setDelegatorURI(original.getAttendees()->at(i)->getDelegatorURI());
+        attendeePtr->setDelegateURI(original.getAttendees()->at(i)->getDelegateURI());
+        attendeePtr->setPersonId(original.getAttendees()->at(i)->getPersonId());
+        m_attendees->push_back(attendeePtr);
+    }
+
+    m_isDetached = original.getIsDetached();
+
+    AttributeListPtr attributesPtr( new AttributeList() );
+    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_timeZone = original.getTimeZone();
+    m_priority = original.getPriority();
+    m_createdDate = original.getCreatedDate();
+    m_completedDate = original.getCompletedDate();
+    m_progress = original.getProgress();
+    m_calendarType = original.getCalendarType();
+
+    LogDebug("Copying done.");
+}
+
 CalendarEvent::~CalendarEvent()
 {
 }
@@ -159,6 +244,16 @@ void CalendarEvent::setAlarmsType(std::vector<EventAlarmType> &value)
     m_alarmsType = value;
 }
 
+std::vector<std::string> CalendarEvent::getAlarmsDescription() const
+{
+    return m_alarmsDescription;
+}
+
+void CalendarEvent::setAlarmsDescription(std::vector<std::string> &value)
+{
+    m_alarmsDescription = value;
+}
+
 CategoryListPtr CalendarEvent::getCategories() const
 {
     return m_categories;
index 59fb856..c5f2ccf 100755 (executable)
@@ -110,6 +110,7 @@ class CalendarEvent
 
 
     CalendarEvent();
+    CalendarEvent(const CalendarEvent &original); // copy constructor for clone operation
     virtual ~CalendarEvent();
 
     int getId() const;
@@ -147,6 +148,9 @@ class CalendarEvent
     std::vector<EventAlarmType> getAlarmsType() const;
     void setAlarmsType(std::vector<EventAlarmType> &value);
 
+    std::vector<std::string> getAlarmsDescription() const;
+    void setAlarmsDescription(std::vector<std::string> &value);
+
     CategoryListPtr getCategories() const;
     void setCategories(const CategoryListPtr &value);
 
@@ -216,6 +220,7 @@ class CalendarEvent
     EventStatus m_status;
     std::vector<long> m_alarmsTick;
     std::vector<EventAlarmType> m_alarmsType;
+    std::vector<std::string> m_alarmsDescription;
     CategoryListPtr m_categories;
     bool m_isAllDay;
     std::string m_organizer;
index ee0f089..828adbb 100755 (executable)
@@ -66,6 +66,15 @@ void EventAlarm::setTimeZone(const std::string &value)
     m_timeZone = value;
 }
 
+std::string EventAlarm::getDescription() const
+{
+    return m_description;
+}
+void EventAlarm::setDescription(const std::string &value)
+{
+    m_description = value;
+}
+
 }
 }
 }
index 89b7962..ae74c5f 100755 (executable)
@@ -47,10 +47,14 @@ class EventAlarm
     std::string getTimeZone() const;
     void setTimeZone(const std::string &value);
 
+    std::string getDescription() const;
+    void setDescription(const std::string &value);
+
   protected:
     std::time_t m_absoluteDate;
     TizenApis::Api::TimeUtil::DurationProperties m_duration;
     std::vector<CalendarEvent::EventAlarmType> m_methods;
+    std::string m_description;
     std::string m_timeZone;
 };
 
index 49b968b..3966379 100755 (executable)
@@ -60,14 +60,9 @@ void EventRecurrenceRule::setInterval(const int &value)
     m_interval = value;
 }
 
-bool EventRecurrenceRule::isEndDateSet() const
-{
-    return !m_endDate.IsNull();
-}
-
 time_t EventRecurrenceRule::getEndDate() const
 {
-    return *m_endDate;
+    return m_endDate;
 }
 
 void EventRecurrenceRule::setEndDate(time_t value)
@@ -75,11 +70,6 @@ void EventRecurrenceRule::setEndDate(time_t value)
     m_endDate = value;
 }
 
-void EventRecurrenceRule::resetEndDate()
-{
-    m_endDate = DPL::Optional<time_t>();
-}
-
 long EventRecurrenceRule::getOccurrenceCount() const
 {
     return m_occurrenceCount;
index f8b4e3c..6f9e513 100755 (executable)
@@ -21,7 +21,6 @@
 #include <string>
 #include <vector>
 #include <dpl/shared_ptr.h>
-#include <dpl/optional.h>
 
 namespace TizenApis {
 namespace Api {
@@ -53,10 +52,8 @@ class EventRecurrenceRule
     int getInterval() const;
     void setInterval(const int &value);
 
-    bool isEndDateSet() const;
     time_t getEndDate() const;
     void setEndDate(time_t value);
-    void resetEndDate();
 
     long getOccurrenceCount() const;
     void setOccurrenceCount(long value);
@@ -85,7 +82,7 @@ class EventRecurrenceRule
   protected:
     EventRecurrence m_frequency;
     int m_interval;
-    DPL::Optional<time_t> m_endDate;
+    time_t m_endDate;
     long m_occurrenceCount;
     std::vector<int> m_daysOfTheMonth;
     std::vector<std::string> m_daysOfTheWeek;
index 22e058f..c5d44e2 100755 (executable)
@@ -36,6 +36,7 @@ ICalendar::ICalendar() :
     WrtDeviceApis::Commons::EventRequestReceiver<IEventWatchChanges>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventClearWatch>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
     m_accountId(0),
     m_type(CalendarEvent::EVENT_TYPE)
 {
@@ -110,6 +111,11 @@ void ICalendar::expandEventRecurrence(IEventExpandEventRecurrencePtr &event)
     WrtDeviceApis::Commons::EventRequestReceiver<IEventExpandEventRecurrence>::PostRequest(event);
 }
 
+void ICalendar::get(IEventGetPtr &event)
+{
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGet>::PostRequest(event);
+}
+
 }
 }
 }
index d78a018..d9e1b24 100755 (executable)
@@ -37,6 +37,7 @@
 #include "IEventWatchChanges.h"
 #include "IEventClearWatch.h"
 #include "IEventExpandEventRecurrence.h"
+#include "IEventGet.h"
 #include "OnAddEventsChanged.h"
 #include "OnUpdateEventsChanged.h"
 #include "OnDeleteEventsChanged.h"
@@ -58,7 +59,8 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventExportEventToString >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventWatchChanges >,
     public WrtDeviceApis::Commons::EventRequestReceiver< IEventClearWatch >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventExpandEventRecurrence >
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventExpandEventRecurrence >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventGet >
 {
   public:
     ICalendar();
@@ -76,6 +78,7 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     virtual void                watchChanges(IEventWatchChangesPtr &event);
     virtual void                clearWatch(IEventClearWatchPtr &event);
        virtual void                            expandEventRecurrence(IEventExpandEventRecurrencePtr &event);
+       virtual void                            get(IEventGetPtr &event);
 
     virtual std::string         getName() const
     {
@@ -176,6 +179,7 @@ class ICalendar : public WrtDeviceApis::Commons::EventRequestReceiver< IEventAdd
     virtual void OnRequestReceived(const IEventWatchChangesPtr &event) = 0;
     virtual void OnRequestReceived(const IEventClearWatchPtr &event) = 0;
     virtual void OnRequestReceived(const IEventExpandEventRecurrencePtr &event) = 0;
+    virtual void OnRequestReceived(const IEventGetPtr &event) = 0;
 };
 
 typedef DPL::SharedPtr<ICalendar> ICalendarPtr;
index e56ad7e..c0145fe 100755 (executable)
@@ -24,7 +24,8 @@ namespace Calendar {
 
 ICalendarManager::ICalendarManager() :
     WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
-    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD)
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD),
+    WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD)
 {
 }
 
@@ -44,6 +45,12 @@ void ICalendarManager::getDefaultCalendar(const IEventGetDefaultCalendarPtr &eve
     WrtDeviceApis::Commons::EventRequestReceiver<IEventGetDefaultCalendar>::PostRequest(event);
 }
 
+void ICalendarManager::getCalendar(const IEventGetCalendarPtr &event)
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetCalendar>::PostRequest(event);
+}
+
 }
 }
 }
index 1fdfb1f..8a3da93 100755 (executable)
@@ -21,6 +21,7 @@
 #include "ICalendar.h"
 #include "IEventGetCalendars.h"
 #include "IEventGetDefaultCalendar.h"
+#include "IEventGetCalendar.h"
 #include <dpl/shared_ptr.h>
 
 namespace TizenApis {
@@ -28,16 +29,19 @@ namespace Api {
 namespace Calendar {
 
 class ICalendarManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendars >,
-    public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetDefaultCalendar >,
+    public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetCalendar >
 {
   public:
     ICalendarManager();
     virtual ~ICalendarManager();
     virtual void getCalendars(const IEventGetCalendarsPtr &event);
     virtual void getDefaultCalendar(const IEventGetDefaultCalendarPtr &event);
+    virtual void getCalendar(const IEventGetCalendarPtr &event);
   protected:
     virtual void OnRequestReceived(const IEventGetCalendarsPtr &event) = 0;
     virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event) = 0;
+    virtual void OnRequestReceived(const IEventGetCalendarPtr &event) = 0;
 };
 
 typedef DPL::SharedPtr<ICalendarManager> ICalendarManagerPtr;
diff --git a/src/platform/API/Calendar/IEventGet.h b/src/platform/API/Calendar/IEventGet.h
new file mode 100755 (executable)
index 0000000..2513b30
--- /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 _ABSTRACT_LAYER_IEVENT_GET_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_H_
+
+#include <vector>
+#include <string>
+#include <Commons/IEvent.h>
+#include "ICalendar.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Calendar {
+
+class IEventGet : public WrtDeviceApis::Commons::IEvent<IEventGet>
+{
+    CalendarEventPtr m_item; // output parameter
+    bool m_result;
+    EventIdPtr m_itemId; // input parameter
+
+  public:
+    bool getResult() const
+    {
+        return m_result;
+    }
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+
+    EventIdPtr getItemId() const
+    {
+        return m_itemId;
+    }
+    void setItemId(EventIdPtr value)
+    {
+        m_itemId = value;
+    }
+
+    CalendarEventPtr getItem() const
+    {
+        return m_item;
+    }
+    void setItem(CalendarEventPtr value)
+    {
+        m_item = value;
+    }
+
+    IEventGet() : m_result(false)
+    {
+    }
+    ~IEventGet()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventGet> IEventGetPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_H_ */
diff --git a/src/platform/API/Calendar/IEventGetCalendar.h b/src/platform/API/Calendar/IEventGetCalendar.h
new file mode 100755 (executable)
index 0000000..b185f72
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * 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_GET_CALENDAR_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_CALENDAR_H_
+
+#include <vector>
+#include <string>
+#include <Commons/IEvent.h>
+#include "ICalendar.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Calendar {
+
+class IEventGetCalendar : public WrtDeviceApis::Commons::IEvent<IEventGetCalendar>
+{
+    ICalendarPtr     m_calendar; // output parameter
+    bool m_result;
+    std::string m_id; // input parameter
+    CalendarEvent::CalendarType m_type;
+
+  public:
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool getResult() const
+    {
+        return m_result;
+    }
+
+    void setType(CalendarEvent::CalendarType value)
+    {
+        m_type = value;
+    }
+    CalendarEvent::CalendarType getType() const
+    {
+        return m_type;
+    }
+
+    void setId(std::string &value)
+    {
+        m_id = value;
+    }
+    std::string getId() const
+    {
+        return m_id;
+    }
+
+    void setCalendar(ICalendarPtr value)
+    {
+        m_calendar = value;
+    }
+    ICalendarPtr getCalendar() const
+    {
+        return m_calendar;
+    }
+
+    IEventGetCalendar() : m_result(false)
+    {
+    }
+    ~IEventGetCalendar()
+    {
+    }
+};
+
+typedef DPL::SharedPtr<IEventGetCalendar> IEventGetCalendarPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_CALENDAR_H_ */
diff --git a/src/platform/API/Call/CallFactory.cpp b/src/platform/API/Call/CallFactory.cpp
new file mode 100755 (executable)
index 0000000..370f2d6
--- /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. 
+ */
+#include "CallFactory.h"
+#include <Call/CallManager.h>
+#include <Call/CallService.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+CallFactory& CallFactory::getInstance()
+{
+    static CallFactory theInstance;
+    return theInstance;
+}
+
+ICallManagerPtr CallFactory::getCallObject()
+{
+       ICallManagerPtr result(new Platform::Call::CallManager()); 
+       return result;
+}
+
+ICallServicePtr CallFactory::getCallServiceObject()
+{
+       ICallServicePtr result(new Platform::Call::CallService()); 
+       return result;
+}
+
+CallFactory::CallFactory()
+{
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Call/CallFactory.h b/src/platform/API/Call/CallFactory.h
new file mode 100755 (executable)
index 0000000..1aa6fc7
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_CALL_FACTORY_H_
+#define _ABSTRACT_LAYER_CALL_FACTORY_H_
+
+#include <dpl/noncopyable.h>
+#include "ICallManager.h"
+#include "ICallService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+class CallFactory : public DPL::Noncopyable
+{
+protected:
+       CallFactory();
+public:
+       static CallFactory& getInstance();
+       ICallManagerPtr getCallObject();
+       ICallServicePtr getCallServiceObject();
+};
+
+}
+}
+}
+
+#endif
\ No newline at end of file
index bb5437a..9c2f17d 100755 (executable)
@@ -21,23 +21,20 @@ namespace Api {
 namespace Call {
 CallHistoryEntryProperties::CallHistoryEntryProperties() :
                m_entryId(0),
-               m_accountId(""),
+               m_serviceId(""),
                m_callType(""),
-               m_remoteParty(""),
-               m_contactId(""),
-               m_contactDetails(""),
-               m_forwardedFrom(""),
                m_startTime(0),
                m_duration(0),
                m_endReason(""),
-               m_kind(""),
                m_direction(""),
                m_cost(0),
                m_currency(""),
                m_filterMark(false)
 {
-       m_usedCapabilities = stringArrayPtr(new stringArray());
-       m_recording = stringArrayPtr(new stringArray());
+       m_tags = StringArrayPtr(new StringArray());
+       m_remoteParties = RemotePartyListPtr(new RemotePartyList());
+       m_forwardedFrom = RemotePartyPtr(new RemoteParty());
+       m_recording = StringArrayPtr(new StringArray());
 }
 
 void CallHistoryEntryProperties::setEntryId(const unsigned long EntryId)
@@ -45,9 +42,9 @@ void CallHistoryEntryProperties::setEntryId(const unsigned long EntryId)
        m_entryId = EntryId;
 }
 
-void CallHistoryEntryProperties::setAccountId(const std::string AccountId)
+void CallHistoryEntryProperties::setServiceId(const std::string ServiceId)
 {
-       m_accountId = AccountId;
+       m_serviceId = ServiceId;
 }
 
 void CallHistoryEntryProperties::setCallType(const std::string CallType)
@@ -55,22 +52,17 @@ void CallHistoryEntryProperties::setCallType(const std::string CallType)
        m_callType = CallType;
 }
 
-void CallHistoryEntryProperties::setRemoteParty(const std::string RemoteParty)
+void CallHistoryEntryProperties::setTags(const StringArrayPtr &Tags)
 {
-       m_remoteParty = RemoteParty;
+       m_tags = Tags;
 }
 
-void CallHistoryEntryProperties::setContactId(const std::string ContactId)
+void CallHistoryEntryProperties::setRemoteParties(const RemotePartyListPtr &RemoteParties)
 {
-       m_contactId = ContactId;
+       m_remoteParties = RemoteParties;
 }
 
-void CallHistoryEntryProperties::setContactDetails(const std::string ContactDetails)
-{
-       m_contactDetails = ContactDetails;
-}
-
-void CallHistoryEntryProperties::setForwardedFrom(const std::string ForwardedFrom)
+void CallHistoryEntryProperties::setForwardedFrom(const RemotePartyPtr &ForwardedFrom)
 {
        m_forwardedFrom = ForwardedFrom;
 }
@@ -90,22 +82,12 @@ void CallHistoryEntryProperties::setEndReason(const std::string EndReason)
        m_endReason = EndReason;
 }
 
-void CallHistoryEntryProperties::setUsedCapabilities(const stringArrayPtr &UsedCapabilities)
-{
-       m_usedCapabilities = UsedCapabilities;
-}
-
-void CallHistoryEntryProperties::setKind(const std::string Kind)
-{
-       m_kind = Kind;
-}
-
 void CallHistoryEntryProperties::setDirection(const std::string Direction)
 {
        m_direction = Direction;
 }
 
-void CallHistoryEntryProperties::setRecording(const stringArrayPtr &Recording)
+void CallHistoryEntryProperties::setRecording(const StringArrayPtr &Recording)
 {
        m_recording = Recording;
 }
@@ -131,9 +113,9 @@ unsigned long CallHistoryEntryProperties::getEntryId() const
        return m_entryId;
 }
 
-std::string CallHistoryEntryProperties::getAccountId() const
+std::string CallHistoryEntryProperties::getServiceId() const
 {
-       return m_accountId;
+       return m_serviceId;
 }
 
 std::string CallHistoryEntryProperties::getCallType() const
@@ -141,22 +123,17 @@ std::string CallHistoryEntryProperties::getCallType() const
        return m_callType;
 }
 
-std::string CallHistoryEntryProperties::getRemoteParty() const
+StringArrayPtr CallHistoryEntryProperties::getTags() const
 {
-       return m_remoteParty;
+       return m_tags;
 }
 
-std::string CallHistoryEntryProperties::getContactId() const
+RemotePartyListPtr CallHistoryEntryProperties::getRemoteParties() const
 {
-       return m_contactId;
+       return m_remoteParties;
 }
 
-std::string CallHistoryEntryProperties::getContactDetails() const
-{
-       return m_contactDetails;
-}
-
-std::string CallHistoryEntryProperties::getForwardedFrom() const
+RemotePartyPtr CallHistoryEntryProperties::getForwardedFrom() const
 {
        return m_forwardedFrom;
 }
@@ -176,22 +153,12 @@ std::string CallHistoryEntryProperties::getEndReason() const
        return m_endReason;
 }
 
-stringArrayPtr CallHistoryEntryProperties::getUsedCapabilities() const
-{
-       return m_usedCapabilities;
-}
-
-std::string CallHistoryEntryProperties::getKind() const
-{
-       return m_kind;
-}
-
 std::string CallHistoryEntryProperties::getDirection() const
 {
        return m_direction;
 }
 
-stringArrayPtr CallHistoryEntryProperties::getRecording() const
+StringArrayPtr CallHistoryEntryProperties::getRecording() const
 {
        return m_recording;
 }
index 5c623a7..171118b 100755 (executable)
@@ -21,6 +21,7 @@
 #include <dpl/shared_ptr.h>
 #include <string>
 #include <vector>
+#include "RemoteParty.h"
 
 namespace TizenApis {
 namespace Api {
@@ -29,26 +30,23 @@ class CallHistoryEntryProperties;
 typedef DPL::SharedPtr<CallHistoryEntryProperties> CallHistoryEntryPropertiesPtr;
 typedef std::vector<CallHistoryEntryPropertiesPtr> CallHistoryEntryList;
 typedef DPL::SharedPtr<CallHistoryEntryList> CallHistoryEntryListPtr;
-typedef std::vector<std::string> stringArray;
-typedef DPL::SharedPtr<stringArray> stringArrayPtr;
+typedef std::vector<std::string> StringArray;
+typedef DPL::SharedPtr<StringArray> StringArrayPtr;
 
 class CallHistoryEntryProperties
 {
 private:
        unsigned long m_entryId;
-       std::string m_accountId;
+       std::string m_serviceId;
        std::string m_callType;
-       std::string m_remoteParty;
-       std::string m_contactId;
-       std::string m_contactDetails;
-       std::string m_forwardedFrom;
+       StringArrayPtr m_tags;
+       RemotePartyListPtr m_remoteParties;
+       RemotePartyPtr m_forwardedFrom;
        time_t m_startTime;
        unsigned long m_duration;
        std::string m_endReason;
-       stringArrayPtr m_usedCapabilities;
-       std::string m_kind;
        std::string m_direction;
-       stringArrayPtr m_recording;
+       StringArrayPtr m_recording;
        unsigned long m_cost;
        std::string m_currency;
 
@@ -56,37 +54,31 @@ private:
 
 public:
        void setEntryId(const unsigned long EntryId);
-       void setAccountId(const std::string AccountId);
+       void setServiceId(const std::string ServiceId);
        void setCallType(const std::string CallType);
-       void setRemoteParty(const std::string RemoteParty);
-       void setContactId(const std::string ContactId);
-       void setContactDetails(const std::string ContactDetails);
-       void setForwardedFrom(const std::string ForwardedFrom);
+       void setTags(const StringArrayPtr &Tags);
+       void setRemoteParties(const RemotePartyListPtr &RemoteParties);
+       void setForwardedFrom(const RemotePartyPtr &ForwardedFrom);
        void setStartTime(const time_t StartTime);
        void setDuration(const unsigned long Duration);
        void setEndReason(const std::string EndReason);
-       void setUsedCapabilities(const stringArrayPtr &UsedCapabilities);
-       void setKind(const std::string Kind);
        void setDirection(const std::string Direction);
-       void setRecording(const stringArrayPtr &Recording);
+       void setRecording(const StringArrayPtr &Recording);
        void setCost(const unsigned long Cost);
        void setCurrency(const std::string Currency);
        void setFilterMark(const bool mark);
 
        unsigned long getEntryId() const;
-       std::string getAccountId() const;
+       std::string getServiceId() const;
        std::string getCallType() const;
-       std::string getRemoteParty() const;
-       std::string getContactId() const;
-       std::string getContactDetails() const;
-       std::string getForwardedFrom() const;
+       StringArrayPtr getTags() const;
+       RemotePartyListPtr getRemoteParties() const;
+       RemotePartyPtr getForwardedFrom() const;
        time_t getStartTime() const;
        unsigned long getDuration() const;
        std::string getEndReason() const;
-       stringArrayPtr getUsedCapabilities() const;
-       std::string getKind() const;
        std::string getDirection() const;
-       stringArrayPtr getRecording() const;
+       StringArrayPtr getRecording() const;
        unsigned long getCost() const;
        std::string getCurrency() const;
        bool getFilterMark() const;
index 06f4932..43122a9 100755 (executable)
@@ -16,6 +16,7 @@
 
  
 #include <Call/CallHistory.h>
+#include <Call/CallHistoryEntry.h>
 #include "CallHistoryFactory.h"
 
 namespace TizenApis {
@@ -32,6 +33,13 @@ ICallHistoryPtr CallHistoryFactory::getCallHistoryObject()
        ICallHistoryPtr result(new Platform::Call::CallHistory()); 
        return result;
 }
+
+ICallHistoryEntryPtr CallHistoryFactory::getCallHistoryEntryObject()
+{
+       ICallHistoryEntryPtr result(new Platform::Call::CallHistoryEntry()); 
+       return result;
+}
+
 CallHistoryFactory::CallHistoryFactory()
 {
 }
index 6190a98..9372046 100755 (executable)
@@ -20,6 +20,7 @@
 
 #include <dpl/noncopyable.h>
 #include "ICallHistory.h"
+#include "ICallHistoryEntry.h"
 
 namespace TizenApis {
 namespace Api {
@@ -28,9 +29,9 @@ namespace Call {
 class CallHistoryFactory : public DPL::Noncopyable
 {
 public:
-
        static CallHistoryFactory& getInstance();
        ICallHistoryPtr getCallHistoryObject();
+       ICallHistoryEntryPtr getCallHistoryEntryObject();
 
 protected:
        CallHistoryFactory();
diff --git a/src/platform/API/Call/CallServiceFilter.cpp b/src/platform/API/Call/CallServiceFilter.cpp
new file mode 100755 (executable)
index 0000000..87559df
--- /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 "CallServiceFilter.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+CallServiceFilter::CallServiceFilter() :
+               m_serviceTypeId(""),
+               m_serviceName(""),
+               m_providerId("")
+{
+       m_tags = StringArrayPtr(new StringArray());
+}
+
+void CallServiceFilter::setServiceTypeId(const std::string serviceTypeId)
+{
+       m_serviceTypeId = serviceTypeId;
+}
+
+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::getServiceTypeId() const
+{
+       return m_serviceTypeId;
+}
+
+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
new file mode 100755 (executable)
index 0000000..fcd381a
--- /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 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_serviceTypeId;
+       StringArrayPtr m_tags;
+       std::string m_serviceName;
+       std::string m_providerId;
+
+public:
+       void setServiceTypeId(const std::string serviceTypeId);
+       void setTags(const StringArrayPtr tags);
+       void setServiceName(const std::string serviceName);
+       void setProviderId(const std::string providerId);
+
+       std::string getServiceTypeId() 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/CallServiceObject.cpp b/src/platform/API/Call/CallServiceObject.cpp
new file mode 100755 (executable)
index 0000000..cd806a8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 "CallServiceObject.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+using namespace WrtDeviceApis::Commons;
+
+
+CallServiceObject::CallServiceObject(const Api::Account::AccountServices &accountServices, ICallServicePtr iCallServicePtr) :
+       Api::Account::AccountServices(accountServices),
+       m_ICallServicePtr(iCallServicePtr)
+{
+}
+
+CallServiceObject::~CallServiceObject()
+{
+}
+
+ICallServicePtr CallServiceObject::getICallService()
+{
+       return m_ICallServicePtr;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/CallServiceObject.h b/src/platform/API/Call/CallServiceObject.h
new file mode 100755 (executable)
index 0000000..5d54070
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * 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_CALLSERVICEOBJECT_H_
+#define TIZENAPIS_API_CALLSERVICEOBJECT_H_
+
+#include <dpl/shared_ptr.h>
+#include <API/Account/AccountServices.h>
+#include "ICallService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call{
+
+class CallServiceObject : public Api::Account::AccountServices
+{
+private:
+       ICallServicePtr m_ICallServicePtr;
+public:
+       CallServiceObject(const Api::Account::AccountServices &accountServices, ICallServicePtr iCallServicePtr);
+       ~CallServiceObject();
+       ICallServicePtr getICallService();
+};
+
+typedef DPL::SharedPtr<CallServiceObject> CallServiceObjectPtr;
+
+}
+}
+}
+
+#endif
diff --git a/src/platform/API/Call/EventCallHistoryListener.cpp b/src/platform/API/Call/EventCallHistoryListener.cpp
new file mode 100755 (executable)
index 0000000..39a3669
--- /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. 
+ */
+#include "EventCallHistoryListener.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+EventCallHistoryListener::EventCallHistoryListener()
+{
+}
+
+void EventCallHistoryListener::setResultState(const ResultStates state)
+{
+       m_resultState = state;
+}
+
+void EventCallHistoryListener::setResult (const CallHistoryEntryListPtr &entryList) 
+{
+       m_entryList = entryList;
+}
+
+EventCallHistoryListener::ResultStates EventCallHistoryListener::getResultState() const
+{
+       return m_resultState;
+}
+
+CallHistoryEntryListPtr EventCallHistoryListener::getResult() const 
+{
+       return m_entryList;
+}
+
+}
+}
+}
+
diff --git a/src/platform/API/Call/EventCallHistoryListener.h b/src/platform/API/Call/EventCallHistoryListener.h
new file mode 100755 (executable)
index 0000000..c0155f6
--- /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. 
+ */
+
+#ifndef TIZENAPIS_API_CALL_EVENT_CALLHISTORY_LISTENER_H_
+#define TIZENAPIS_API_CALL_EVENT_CALLHISTORY_LISTENER_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/ListenerEvent.h>
+#include <Commons/ListenerEventEmitter.h>
+#include "CallHistoryEntryProperties.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+class EventCallHistoryListener : public WrtDeviceApis::Commons::ListenerEvent<EventCallHistoryListener>
+{
+public:
+       typedef enum {
+               ADDED,
+               CHANGED
+       } ResultStates;
+
+private:
+       ResultStates m_resultState;
+       Api::Call::CallHistoryEntryListPtr m_entryList;
+
+public:
+       void setResultState(const ResultStates state);
+       void setResult(const Api::Call::CallHistoryEntryListPtr &entryList);
+       ResultStates getResultState() const;
+       Api::Call::CallHistoryEntryListPtr getResult() const;
+
+       EventCallHistoryListener();
+};
+
+typedef DPL::SharedPtr<EventCallHistoryListener> EventCallHistoryListenerPtr;
+typedef WrtDeviceApis::Commons::ListenerEventEmitter<EventCallHistoryListener> EventCallHistoryListenerEmitter;
+typedef DPL::SharedPtr<EventCallHistoryListenerEmitter> EventCallHistoryListenerEmitterPtr;
+
+}
+}
+}
+
+#endif
\ No newline at end of file
index 01838a0..7cf837f 100755 (executable)
@@ -35,7 +35,7 @@ void EventFindCallHistory::setFilter(const FilterPtr &filter)
        m_filterIsSet = true;
 }
 
-void EventFindCallHistory::setSortMode(const SortModeArrayPtr &sortMode)
+void EventFindCallHistory::setSortMode(const SortModePtr &sortMode)
 {
        m_sortModes = sortMode;
        m_sortModesIsSet = true;
@@ -67,7 +67,7 @@ FilterPtr EventFindCallHistory::getFilter() const
        return m_filter;
 }
 
-SortModeArrayPtr EventFindCallHistory::getSortMode() const
+SortModePtr EventFindCallHistory::getSortMode() const
 {
        return m_sortModes;
 }
index 25327c6..da7d608 100755 (executable)
@@ -33,7 +33,7 @@ class EventFindCallHistory : public WrtDeviceApis::Commons::IEvent<EventFindCall
   private:
        CallHistoryEntryListPtr m_callEntries;
        Tizen::FilterPtr m_filter;
-       Tizen::SortModeArrayPtr m_sortModes;
+       Tizen::SortModePtr m_sortModes;
        unsigned long m_limit;
        unsigned long m_offset;
        bool m_filterIsSet;
@@ -43,13 +43,13 @@ class EventFindCallHistory : public WrtDeviceApis::Commons::IEvent<EventFindCall
 
   public:
        void setFilter(const Tizen::FilterPtr &filter);
-       void setSortMode(const Tizen::SortModeArrayPtr &sortMode);
+       void setSortMode(const Tizen::SortModePtr &sortMode);
        void setLimit(const unsigned long limit);
        void setOffset(const unsigned long offset);
        void setResult(const CallHistoryEntryListPtr &callEntries);
 
        Tizen::FilterPtr getFilter() const;
-       Tizen::SortModeArrayPtr getSortMode() const;
+       Tizen::SortModePtr getSortMode() const;
        unsigned long getLimit() const;
        unsigned long getOffset() const;
        bool getFilterIsSet() const;
diff --git a/src/platform/API/Call/EventGetCallService.cpp b/src/platform/API/Call/EventGetCallService.cpp
new file mode 100755 (executable)
index 0000000..e589f77
--- /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. 
+ */
+
+#include "EventGetCallService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+EventGetCallService::EventGetCallService()
+{
+}
+
+void EventGetCallService::setFilter(const CallServiceFilterPtr &filter)
+{
+       m_filter = filter;
+}
+
+void EventGetCallService::setResult(const Api::Account::AccountServicesArrayPtr &result)
+{
+       m_result = result;
+}
+
+
+CallServiceFilterPtr EventGetCallService::getFilter() const
+{
+       return m_filter;
+}
+
+Api::Account::AccountServicesArrayPtr EventGetCallService::getResult() const
+{
+       return m_result;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/EventGetCallService.h b/src/platform/API/Call/EventGetCallService.h
new file mode 100755 (executable)
index 0000000..3e5ce1f
--- /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 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
diff --git a/src/platform/API/Call/EventLaunchDialer.cpp b/src/platform/API/Call/EventLaunchDialer.cpp
new file mode 100755 (executable)
index 0000000..dadacae
--- /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. 
+ */
+
+#include "EventLaunchDialer.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+EventLaunchDialer::EventLaunchDialer()
+{
+}
+
+void EventLaunchDialer::setRemoteParty(const std::string remoteParty)
+{
+       m_remoteParty = remoteParty;
+}
+
+void EventLaunchDialer::setExtension(const std::string extension)
+{
+       m_extension = extension;
+}
+
+
+std::string EventLaunchDialer::getRemoteParty() const
+{
+       return m_remoteParty;
+}
+
+std::string EventLaunchDialer::getExtension() const
+{
+       return m_extension;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/EventLaunchDialer.h b/src/platform/API/Call/EventLaunchDialer.h
new file mode 100755 (executable)
index 0000000..ecd8f4b
--- /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 TIZENAPIS_API_CALL_EVENT_LAUNCHDIALER_H_
+#define TIZENAPIS_API_CALL_EVENT_LAUNCHDIALER_H_
+
+#include <string>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+class EventLaunchDialer : public WrtDeviceApis::Commons::IEvent<EventLaunchDialer>
+{
+private:
+       std::string m_remoteParty;
+       std::string m_extension;
+
+public:
+       void setRemoteParty(const std::string remoteParty);
+       void setExtension(const std::string extension);
+       std::string getRemoteParty() const;
+       std::string getExtension() const;
+
+       EventLaunchDialer();
+};
+
+typedef DPL::SharedPtr<EventLaunchDialer> EventLaunchDialerPtr;
+}
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/platform/API/Call/EventRemoveAll.cpp b/src/platform/API/Call/EventRemoveAll.cpp
new file mode 100755 (executable)
index 0000000..d576eed
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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 "EventRemoveAll.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+EventRemoveAll::EventRemoveAll()
+{
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/EventRemoveAll.h b/src/platform/API/Call/EventRemoveAll.h
new file mode 100755 (executable)
index 0000000..6dd2fb1
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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_REMOVE_ALL_H_
+#define TIZENAPIS_API_CALL_EVENT_REMOVE_ALL_H_
+
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+class EventRemoveAll : public WrtDeviceApis::Commons::IEvent<EventRemoveAll>
+{
+public:
+       EventRemoveAll();
+};
+
+typedef DPL::SharedPtr<EventRemoveAll> EventRemoveAllPtr;
+}
+}
+}
+
+#endif
\ No newline at end of file
diff --git a/src/platform/API/Call/EventSendUSSD.cpp b/src/platform/API/Call/EventSendUSSD.cpp
new file mode 100755 (executable)
index 0000000..c945eda
--- /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. 
+ */
+
+#include "EventSendUSSD.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+EventSendUSSD::EventSendUSSD()
+{
+}
+
+void EventSendUSSD::setCommand(const std::string command)
+{
+       m_command = command;
+}
+
+void EventSendUSSD::setResult(const std::string result)
+{
+       m_result = result;
+}
+
+
+std::string EventSendUSSD::getCommand() const
+{
+       return m_command;
+}
+
+std::string EventSendUSSD::getResult() const
+{
+       return m_result;
+}
+}
+}
+}
\ No newline at end of file
diff --git a/src/platform/API/Call/EventSendUSSD.h b/src/platform/API/Call/EventSendUSSD.h
new file mode 100755 (executable)
index 0000000..5e4d68e
--- /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 TIZENAPIS_API_CALL_EVENT_SENDUSSD_H_
+#define TIZENAPIS_API_CALL_EVENT_SENDUSSD_H_
+
+#include <string>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.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();
+};
+
+typedef DPL::SharedPtr<EventSendUSSD> EventSendUSSDPtr;
+}
+}
+}
+
+#endif
index 48b7550..9bffc03 100755 (executable)
@@ -25,7 +25,8 @@ using namespace WrtDeviceApis::Commons;
 
 ICallHistory::ICallHistory()  :
                EventRequestReceiver<EventFindCallHistory>(ThreadEnum::CALLHISTORY_THREAD),
-               EventRequestReceiver<EventRemoveBatch>(ThreadEnum::CALLHISTORY_THREAD)
+               EventRequestReceiver<EventRemoveBatch>(ThreadEnum::CALLHISTORY_THREAD),
+               EventRequestReceiver<EventRemoveAll>(ThreadEnum::CALLHISTORY_THREAD)
 {
 }
 
index 0ec4540..44caa48 100755 (executable)
 #include <Commons/ThreadPool.h>
 #include "EventFindCallHistory.h"
 #include "EventRemoveBatch.h"
+#include "EventRemoveAll.h"
+#include "EventCallHistoryListener.h"
 
 namespace TizenApis {
 namespace Api {
 namespace Call{
 
 class ICallHistory : public WrtDeviceApis::Commons::EventRequestReceiver<EventFindCallHistory>,
-    public WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveBatch>
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveBatch>,
+    public WrtDeviceApis::Commons::EventRequestReceiver<EventRemoveAll>
 {
 public:
        virtual ~ICallHistory();
@@ -39,10 +42,17 @@ public:
 
        virtual void removeBatch(const EventRemoveBatchPtr& event) = 0;
 
+       virtual void removeAll(const EventRemoveAllPtr& event) = 0;
+
+       virtual long addListener(const EventCallHistoryListenerEmitterPtr& emitter) = 0;
+
+       virtual void removeListener(const EventCallHistoryListenerEmitter::IdType id) = 0;
+
 protected:
        ICallHistory();
        virtual void OnRequestReceived(const EventFindCallHistoryPtr& event) = 0;
        virtual void OnRequestReceived(const EventRemoveBatchPtr& event) = 0;
+       virtual void OnRequestReceived(const EventRemoveAllPtr& event) = 0;
 };
 typedef DPL::SharedPtr<ICallHistory> ICallHistoryPtr;
 }
diff --git a/src/platform/API/Call/ICallHistoryEntry.cpp b/src/platform/API/Call/ICallHistoryEntry.cpp
new file mode 100755 (executable)
index 0000000..3c33c42
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 "ICallHistoryEntry.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+using namespace WrtDeviceApis::Commons;
+
+ICallHistoryEntry::ICallHistoryEntry()
+{
+}
+
+ICallHistoryEntry::~ICallHistoryEntry()
+{
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/ICallHistoryEntry.h b/src/platform/API/Call/ICallHistoryEntry.h
new file mode 100755 (executable)
index 0000000..a88ee8b
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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_ICALLHISTORYENTRY_H_
+#define TIZENAPIS_API_ICALLHISTORYENTRY_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/ThreadPool.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Call{
+
+class ICallHistoryEntry
+{
+public:
+       virtual ~ICallHistoryEntry();
+
+       virtual void setMarkSeen(const unsigned long entryId) = 0;
+
+protected:
+       ICallHistoryEntry();
+};
+typedef DPL::SharedPtr<ICallHistoryEntry> ICallHistoryEntryPtr;
+}
+}
+}
+
+#endif
diff --git a/src/platform/API/Call/ICallManager.cpp b/src/platform/API/Call/ICallManager.cpp
new file mode 100755 (executable)
index 0000000..29c1bde
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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 "ICallManager.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+using namespace WrtDeviceApis::Commons;
+
+ICallManager::ICallManager()
+       :EventRequestReceiver<EventGetCallService>(ThreadEnum::TELEPHONY_THREAD)
+{
+}
+
+ICallManager::~ICallManager()
+{
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/ICallManager.h b/src/platform/API/Call/ICallManager.h
new file mode 100755 (executable)
index 0000000..df6d516
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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_ICALLMANAGER_H_
+#define TIZENAPIS_API_ICALLMANAGER_H_
+
+#include <string>
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include <Commons/ThreadPool.h>
+#include "EventGetCallService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call{
+
+typedef std::vector<std::string> StringList;
+typedef DPL::SharedPtr<StringList> StringListPtr;
+
+class ICallManager
+       :public WrtDeviceApis::Commons::EventRequestReceiver<EventGetCallService>
+{
+public:
+       ICallManager();
+       virtual ~ICallManager();
+
+       /**
+        * Tell whether is there is a call going on.
+        * @return true if there is at least one call in the following states:
+        * 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;
+
+}
+}
+}
+
+#endif
diff --git a/src/platform/API/Call/ICallService.cpp b/src/platform/API/Call/ICallService.cpp
new file mode 100755 (executable)
index 0000000..af337d7
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * 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 "ICallService.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+
+using namespace WrtDeviceApis::Commons;
+
+ICallService::ICallService() : 
+       EventRequestReceiver<EventLaunchDialer>(ThreadEnum::TELEPHONY_THREAD),
+       EventRequestReceiver<EventSendUSSD>(ThreadEnum::TELEPHONY_THREAD)
+{
+}
+
+ICallService::~ICallService()
+{
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/ICallService.h b/src/platform/API/Call/ICallService.h
new file mode 100755 (executable)
index 0000000..b9cc86c
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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
diff --git a/src/platform/API/Call/RemoteParty.cpp b/src/platform/API/Call/RemoteParty.cpp
new file mode 100755 (executable)
index 0000000..ff57efc
--- /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 "RemoteParty.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+RemoteParty::RemoteParty() :
+               m_remoteParty(""),
+               m_displayName(""),
+               m_contactId("")
+{
+}
+
+void RemoteParty::setRemoteParty(const std::string remoteParty)
+{
+       m_remoteParty = remoteParty;
+}
+
+void RemoteParty::setDisplayName(const std::string displayName)
+{
+       m_displayName = displayName;
+}
+
+void RemoteParty::setContactId(const std::string contactId)
+{
+       m_contactId = contactId;
+}
+
+std::string RemoteParty::getRemoteParty() const
+{
+       return m_remoteParty;
+}
+
+std::string RemoteParty::getDisplayName() const
+{
+       return m_displayName;
+}
+
+std::string RemoteParty::getContactId() const
+{
+       return m_contactId;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Call/RemoteParty.h b/src/platform/API/Call/RemoteParty.h
new file mode 100755 (executable)
index 0000000..6257c3d
--- /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 TIZENAPIS_API_REMOTEPARTY_H_
+#define TIZENAPIS_API_REMOTEPARTY_H_
+
+#include <dpl/shared_ptr.h>
+#include <string>
+#include <vector>
+
+namespace TizenApis {
+namespace Api {
+namespace Call {
+class RemoteParty;
+typedef DPL::SharedPtr<RemoteParty> RemotePartyPtr;
+typedef std::vector<RemotePartyPtr> RemotePartyList;
+typedef DPL::SharedPtr<RemotePartyList> RemotePartyListPtr;
+
+class RemoteParty
+{
+private:
+       std::string m_remoteParty;
+       std::string m_displayName;
+       std::string m_contactId;
+
+public:
+       void setRemoteParty(const std::string remoteParty);
+       void setDisplayName(const std::string displayName);
+       void setContactId(const std::string contactId);
+
+       std::string getRemoteParty() const;
+       std::string getDisplayName() const;
+       std::string getContactId() const;
+       
+       RemoteParty();
+};
+}
+}
+}
+
+#endif
\ No newline at end of file
index 5a991ef..fe16aab 100755 (executable)
@@ -1,9 +1,21 @@
 get_current_path()
 set(SRCS_PLATFORM_API_CALL
-  ${CURRENT_PATH}/ICallHistory.cpp
+  ${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}/CallHistoryEntryProperties.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 5602043..ce47733 100644 (file)
  * @brief       Declaration of the JSFilter class
  */
 
-#include "AnyType.h"
+#include <limits>
+#include <sstream>
 #include <Commons/Exception.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include "AnyType.h"
 
 namespace TizenApis {
 namespace Api {
@@ -31,214 +34,334 @@ namespace Tizen {
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
-AnyTypeConverter::AnyTypeConverter(JSContextRef context) :
-               Converter(context)
+
+Any::Any()
 {
+       m_type = PrimitiveType_Null;
+       m_value.i = 0;
+       m_json = "null";
+       m_priv = NULL;
 }
 
-AnyTypeConverter::~AnyTypeConverter()
+Any::Any(bool value)
 {
+       m_type = PrimitiveType_Boolean;
+       m_value.b = value;
+       m_json = value?"true":"false";
+       m_priv = NULL;
 }
 
-JSValueRef AnyTypeConverter::toJSValueRef(const AnyPtr& arg)
+Any::Any(double value, std::string json)
 {
-       PrimitiveType type = arg->getType();
-
-       if(type == PrimitiveType_Boolean)
-               return DPL::DynamicPointerCast< Any_T<bool> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_Char)
-               return DPL::DynamicPointerCast< Any_T<char> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_UChar)
-               return DPL::DynamicPointerCast< Any_T<unsigned char> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_Int)
-               return DPL::DynamicPointerCast< Any_T<int> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_UInt)
-               return DPL::DynamicPointerCast< Any_T<unsigned int> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_Long)
-               return DPL::DynamicPointerCast< Any_T<long> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_ULong)
-               return DPL::DynamicPointerCast< Any_T<unsigned long> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_Double)
-               return DPL::DynamicPointerCast< Any_T<double> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_String)
-               return DPL::DynamicPointerCast< Any_T<std::string> >(arg)->toJSValueRef(m_context);
-       else if(type == PrimitiveType_Time)
-               return DPL::DynamicPointerCast< Any_T<tm> >(arg)->toJSValueRef(m_context);
-       else
-               return DPL::DynamicPointerCast< Any_T<std::string> >(arg)->toJSValueRef(m_context);
+       m_type = PrimitiveType_Double;
+       m_value.d = value;
+       m_json = json;
+       m_priv = NULL;
+
+       if(value == (double)((char)value))
+               m_type |= PrimitiveType_Char;
+       if(value == (double)((unsigned char)value))
+               m_type |= PrimitiveType_UChar;
+       if(value == (double)((int)value))
+               m_type |= PrimitiveType_Int;
+       if(value == (double)((unsigned int)value))
+               m_type |= PrimitiveType_UInt;
+       if(value == (double)((long)value))
+               m_type |= PrimitiveType_Long;
+       if(value == (double)((unsigned long)value))
+               m_type |= PrimitiveType_ULong;
 }
 
-AnyPtr AnyTypeConverter::toAny(const JSValueRef &value, const PrimitiveType preferredNumberType)
+Any::Any(std::string value)
 {
-       JSType jstype = JSValueGetType(m_context, value);
+       m_type = PrimitiveType_String;
+       m_value.s = new std::string(value);
+       m_json = "\"" + value + "\"";
+       m_priv = NULL;
+}
 
-       if(jstype == kJSTypeBoolean)
-               return toAny(Converter::toBool(value));
-       else if(jstype == kJSTypeNumber)
+Any::Any(std::tm value, std::string json)
+{
+       m_type = PrimitiveType_Time;
+       m_value.t = value;
+       m_json = json;
+       m_priv = NULL;
+}
+
+Any::Any(void * priv, std::string json)
+{
+       m_type = PrimitiveType_Object;
+       m_value.i = 0;
+       m_json = json;
+       m_priv = priv;
+}
+
+Any::~Any()
+{
+       if(m_type == PrimitiveType_String)
+               delete m_value.s;
+}
+
+std::string Any::toString() const
+{
+       std::stringstream oss;
+
+       if(m_type == PrimitiveType_Undefined || m_type == PrimitiveType_Null)
+               return "";
+       else if(m_type == PrimitiveType_Boolean)
+               return m_json;
+       else if(m_type == PrimitiveType_String)
+               return *m_value.s;
+       else if(m_type == PrimitiveType_Object)
+               return m_json;
+       else if(m_type | PrimitiveType_Number)
        {
-               if(preferredNumberType == PrimitiveType_Char)
-                       return toAny(Converter::toChar(value));
-               else if(preferredNumberType == PrimitiveType_UChar)
-                       return toAny(Converter::toUChar(value));
-               else if(preferredNumberType == PrimitiveType_Int)
-                       return toAny(Converter::toInt(value));
-               else if(preferredNumberType == PrimitiveType_UInt)
-                       return toAny(static_cast<unsigned int>(Converter::toULong(value)));
-               else if(preferredNumberType == PrimitiveType_Long)
-                       return toAny(Converter::toLong(value));
-               else if(preferredNumberType == PrimitiveType_ULong)
-                       return toAny(Converter::toULong(value));
-               else if(preferredNumberType == PrimitiveType_Double)
-                       return toAny(Converter::toDouble(value));
+               if(m_type | PrimitiveType_ULong)
+                       oss << (unsigned long)m_value.d;
+               else if(m_type | PrimitiveType_Long)
+                       oss << (long)m_value.d;
                else
-                       return toAny(Converter::toDouble(value));
+               {
+                       oss << std::setprecision(std::numeric_limits<double>::digits10);
+                       oss << std::setiosflags(std::ios::fixed);
+                       oss << m_value.d;
+               }
+
+               return oss.str();
+       }
+       else if(m_type == PrimitiveType_Time)
+       {
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(4) << (m_value.t.tm_year + 1900);
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << (m_value.t.tm_mon + 1);
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_mday;
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_hour;
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_min;
+               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.t.tm_sec;
+
+               return oss.str();
        }
-       else if(jstype == kJSTypeString)
-               return toAny(Converter::toString(value));
-       else if(isDate(value))
-               return toAny(Converter::toDateTm(value));
        else
-               return toAny(Converter::toString(value));
+               return m_json;
 }
 
-AnyPtr AnyTypeConverter::toAny(const bool &value)
+std::string Any::toJSON() const
 {
-       AnyPtr ptr(new Any_T<bool>(value));
-       return ptr;
+       return m_json;
 }
 
-AnyPtr AnyTypeConverter::toAny(const char &value)
+unsigned int Any::getType() const
 {
-       AnyPtr ptr(new Any_T<char>(value));
-       return ptr;
+       return m_type;
 }
 
-AnyPtr AnyTypeConverter::toAny(const unsigned char &value)
+bool Any::isType(PrimitiveType type) const
 {
-       AnyPtr ptr(new Any_T<unsigned char>(value));
-       return ptr;
+       return (bool)(m_type & type);
 }
 
-AnyPtr AnyTypeConverter::toAny(const int &value)
+bool Any::getBool() const
 {
-       AnyPtr ptr(new Any_T<int>(value));
-       return ptr;
+       if(m_type != PrimitiveType_Boolean)
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return m_value.b;
 }
 
-AnyPtr AnyTypeConverter::toAny(const unsigned int &value)
+char Any::getChar() const
 {
-       AnyPtr ptr(new Any_T<unsigned int>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_Char))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (char)m_value.d;
 }
 
-AnyPtr AnyTypeConverter::toAny(const long &value)
+unsigned char Any::getUChar() const
 {
-       AnyPtr ptr(new Any_T<long>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_UChar))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (unsigned char)m_value.d;
 }
 
-AnyPtr AnyTypeConverter::toAny(const unsigned long &value)
+int Any::getInt() const
 {
-       AnyPtr ptr(new Any_T<unsigned long>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_Int))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (int)m_value.d;
 }
 
-AnyPtr AnyTypeConverter::toAny(const double &value)
+unsigned int Any::getUInt() const
 {
-       AnyPtr ptr(new Any_T<double>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_UInt))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (unsigned int)m_value.d;
 }
 
-AnyPtr AnyTypeConverter::toAny(const std::string &value)
+long Any::getLong() const
 {
-       AnyPtr ptr(new Any_T<std::string>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_Long))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (long)m_value.d;
 }
 
-AnyPtr AnyTypeConverter::toAny(const tm &value)
+unsigned long Any::getULong() const
 {
-       AnyPtr ptr(new Any_T<tm>(value));
-       return ptr;
+       if(!(m_type & PrimitiveType_ULong))
+               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+
+       return (unsigned long)m_value.d;
 }
 
-bool AnyTypeConverter::toBool(const AnyPtr& arg)
+double Any::getDouble() const
 {
-       if(arg->getType() != PrimitiveType_Boolean)
+       if(!(m_type & PrimitiveType_Double))
                ThrowMsg(InvalidArgumentException, "Type mismatch.");
 
-       return DPL::DynamicPointerCast< Any_T<bool> >(arg)->getValue();
+       return m_value.d;
 }
 
-char AnyTypeConverter::toChar(const AnyPtr& arg)
+std::string Any::getString() const
 {
-       if(arg->getType() != PrimitiveType_Char)
+       if(m_type != PrimitiveType_String)
                ThrowMsg(InvalidArgumentException, "Type mismatch.");
 
-       return DPL::DynamicPointerCast< Any_T<char> >(arg)->getValue();
+       return *m_value.s;
 }
 
-unsigned char AnyTypeConverter::toUChar(const AnyPtr& arg)
+std::tm Any::getDateTm() const
 {
-       if(arg->getType() != PrimitiveType_UChar)
+       if(m_type != PrimitiveType_Time)
                ThrowMsg(InvalidArgumentException, "Type mismatch.");
 
-       return DPL::DynamicPointerCast< Any_T<unsigned char> >(arg)->getValue();
+       return m_value.t;
 }
 
-int AnyTypeConverter::toInt(const AnyPtr& arg)
+std::time_t Any::getTimeT() const
 {
-       if(arg->getType() != PrimitiveType_Int)
+       if(m_type != PrimitiveType_Time)
                ThrowMsg(InvalidArgumentException, "Type mismatch.");
 
-       return DPL::DynamicPointerCast< Any_T<int> >(arg)->getValue();
+       std::tm *time = const_cast<std::tm*>(&(m_value.t));
+       return std::mktime(time);
 }
 
-unsigned int AnyTypeConverter::toUInt(const AnyPtr& arg)
+AnyTypeConverter::AnyTypeConverter(JSContextRef context) :
+               Converter(context)
 {
-       if(arg->getType() != PrimitiveType_UInt)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+}
 
-       return DPL::DynamicPointerCast< Any_T<unsigned int> >(arg)->getValue();
+AnyTypeConverter::~AnyTypeConverter()
+{
 }
 
-long AnyTypeConverter::toLong(const AnyPtr& arg)
+JSValueRef AnyTypeConverter::toJSValueRef(const AnyPtr& arg)
 {
-       if(arg->getType() != PrimitiveType_Long)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       if(arg->isType(PrimitiveType_Undefined))
+               return JSValueMakeUndefined(m_context);
+       else if(arg->isType(PrimitiveType_Null))
+               return JSValueMakeNull(m_context);
+       else if(arg->isType(PrimitiveType_Boolean))
+               return toJSValueRef(arg->getBool());
+       else if(arg->isType(PrimitiveType_Number))
+               return toJSValueRef(arg->getDouble());
+       else if(arg->isType(PrimitiveType_String))
+               return toJSValueRef(arg->getString());
+       else if(arg->isType(PrimitiveType_Time))
+               return toJSValueRef(arg->getDateTm());
+       else if(arg->isType(PrimitiveType_Object))
+       {
+               ScopedJSStringRef json(JSStringCreateWithUTF8CString(arg->toJSON().c_str()));
+               return JSValueMakeFromJSONString(m_context, json.get());
+       }
 
-       return DPL::DynamicPointerCast< Any_T<long> >(arg)->getValue();
+       return JSValueMakeUndefined(m_context);
 }
 
-unsigned long AnyTypeConverter::toULong(const AnyPtr& arg)
+AnyPtr AnyTypeConverter::toAny(const JSValueRef &value)
 {
-       if(arg->getType() != PrimitiveType_ULong)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       JSType jstype = JSValueGetType(m_context, value);
+       ScopedJSStringRef json(JSValueCreateJSONString(m_context, value, 0, NULL));
 
-       return DPL::DynamicPointerCast< Any_T<unsigned long> >(arg)->getValue();
+       if(jstype == kJSTypeBoolean)
+               return AnyPtr(new Any(Converter::toBool(value)));
+       else if(jstype == kJSTypeNumber)
+               return AnyPtr(new Any(Converter::toDouble(value), toString(json.get())));
+       else if(jstype == kJSTypeString)
+               return AnyPtr(new Any(Converter::toString(value)));
+       else if(jstype == kJSTypeObject)
+       {
+               if(isDate(value))
+                       return AnyPtr(new Any(Converter::toDateTm(value), toString(json.get())));
+               else
+               {
+                       void *priv = NULL;
+                       JSObjectRef object = JSValueToObject(m_context, value, NULL);
+                       if (object)
+                               priv = JSObjectGetPrivate(object);
+
+                       return AnyPtr(new Any(priv, toString(json.get())));
+               }
+       }
+       else
+               return AnyPtr(new Any());
 }
 
-double AnyTypeConverter::toDouble(const AnyPtr& arg)
+bool AnyTypeConverter::toBool(const AnyPtr& arg)
 {
-       if(arg->getType() != PrimitiveType_Double)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       return arg->getBool();
+}
 
-       return DPL::DynamicPointerCast< Any_T<double> >(arg)->getValue();
+char AnyTypeConverter::toChar(const AnyPtr& arg)
+{
+       return arg->getChar();
 }
 
-std::string AnyTypeConverter::toString(const AnyPtr& arg)
+unsigned char AnyTypeConverter::toUChar(const AnyPtr& arg)
 {
-       if(arg->getType() != PrimitiveType_String)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       return arg->getUChar();
+}
 
-       return DPL::DynamicPointerCast< Any_T<std::string> >(arg)->getValue();
+int AnyTypeConverter::toInt(const AnyPtr& arg)
+{
+       return arg->getInt();
+}
+
+unsigned int AnyTypeConverter::toUInt(const AnyPtr& arg)
+{
+       return arg->getUInt();
+}
+
+long AnyTypeConverter::toLong(const AnyPtr& arg)
+{
+       return arg->getLong();
+}
+
+unsigned long AnyTypeConverter::toULong(const AnyPtr& arg)
+{
+       return arg->getULong();
+}
+
+double AnyTypeConverter::toDouble(const AnyPtr& arg)
+{
+       return arg->getDouble();
+}
+
+std::string AnyTypeConverter::toString(const AnyPtr& arg)
+{
+       return arg->getString();
 }
 
 tm AnyTypeConverter::toDateTm(const AnyPtr& arg)
 {
-       if(arg->getType() != PrimitiveType_Time)
-               ThrowMsg(InvalidArgumentException, "Type mismatch.");
+       return arg->getDateTm();
+}
 
-       return DPL::DynamicPointerCast< Any_T<tm> >(arg)->getValue();
+time_t AnyTypeConverter::toTimeT(const AnyPtr& arg)
+{
+       return arg->getTimeT();
 }
 
 bool AnyTypeConverter::isDate(const JSValueRef& arg)
index 9669934..4ba78e0 100644 (file)
@@ -34,21 +34,25 @@ namespace TizenApis {
 namespace Api {
 namespace Tizen {
 
-#define _PT_NOTYPE     (0)
-#define _PT_BOOLEAN    (1 << 0)
-#define _PT_CHAR       (1 << 1)
-#define _PT_UCHAR      (1 << 2)
-#define _PT_INT                (1 << 3)
-#define _PT_UINT       (1 << 4)
-#define _PT_LONG       (1 << 5)
-#define _PT_ULONG      (1 << 6)
-#define _PT_DOUBLE     (1 << 7)
-#define _PT_STRING     (1 << 8)
-#define _PT_TIME       (1 << 9)
-#define _PT_OTHER      (1 << 10)
+
+#define _PT_UNDEFINED  (0)
+#define _PT_NULL               (1 << 0)
+#define _PT_BOOLEAN            (1 << 1)
+#define _PT_CHAR               (1 << 2)
+#define _PT_UCHAR              (1 << 3)
+#define _PT_INT                        (1 << 4)
+#define _PT_UINT               (1 << 5)
+#define _PT_LONG               (1 << 6)
+#define _PT_ULONG              (1 << 7)
+#define _PT_DOUBLE             (1 << 8)
+#define _PT_STRING             (1 << 9)
+#define _PT_TIME               (1 << 10)
+#define _PT_OBJECT             (1 << 11)
 
 enum PrimitiveType {
-       PrimitiveType_Notype    = _PT_NOTYPE,
+       PrimitiveType_NoType    = 0,
+       PrimitiveType_Undefined = _PT_UNDEFINED,
+       PrimitiveType_Null              = _PT_NULL,
        PrimitiveType_Boolean   = _PT_BOOLEAN,
        PrimitiveType_Char              = _PT_CHAR,
        PrimitiveType_UChar             = _PT_UCHAR,
@@ -59,234 +63,67 @@ enum PrimitiveType {
        PrimitiveType_Double    = _PT_DOUBLE,
        PrimitiveType_String    = _PT_STRING,
        PrimitiveType_Time              = _PT_TIME,
-       PrimitiveType_Other             = _PT_OTHER,
+       PrimitiveType_Object    = _PT_OBJECT,
        PrimitiveType_Number    = (_PT_CHAR | _PT_UCHAR | _PT_INT | _PT_UINT |
                                                                _PT_LONG | _PT_ULONG | _PT_DOUBLE),
+       PrimitiveType_Integer   = (_PT_CHAR | _PT_UCHAR | _PT_INT | _PT_UINT |
+                                                               _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_OTHER )
+                                                               _PT_STRING | _PT_TIME | _PT_OBJECT )
 };
 
 class Any
 {
-public:
-       virtual std::string toString() const = 0;
-       virtual PrimitiveType getType() const = 0;
-};
-
-typedef DPL::SharedPtr<Any> AnyPtr;
-
-template<typename T>
-class Any_Common : public Any
-{
-protected:
-       T       m_value;
-
-public:
-       explicit Any_Common(const T& value) { m_value = value; };
-       virtual ~Any_Common() {}
-
-       virtual T getValue() const { return m_value; }
-       virtual void setValue(const T& value) { m_value = value; }
-
-       virtual JSValueRef toJSValueRef(JSContextRef context) const
-       {
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-               return converter.toJSValueRef(m_value);
-       }
-};
-
-template<typename T>
-class Any_Common<T*> : public Any
-{
-protected:
-       T*      m_value;
-
-public:
-       explicit Any_Common(const T* value) { m_value = value; }
-       virtual ~Any_Common() {}
-
-       T* getValue() const { return m_value; }
-       void setValue(const T* value) { m_value = value; }
-
-       virtual std::string toString() const = 0;
-
-       virtual JSValueRef toJSValueRef(JSContextRef context) const
-       {
-               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
-
-               return converter.toJSValueRef(&m_value);
-       }
-};
-
-template<typename T>
-class Any_T : public Any_Common<T>
-{
-public:
-       explicit Any_T(const T& value) : Any_Common<T>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Other; }
-
-       virtual std::string toString() const
+private:
+       union AnyTypeUnion
        {
-               return "";
-       }
-};
+               bool b;
+               double d;
+               std::tm t;
+               std::string* s;
+               int i;
+       };
 
-template<>
-class Any_T<bool> : public Any_Common<bool>
-{
-public:
-       explicit Any_T(const bool& value) : Any_Common<bool>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Boolean; }
+       unsigned int m_type;
 
-       virtual std::string toString() const
-       {
-               if(m_value)
-                       return "true";
-               else
-                       return "false";
-       }
-};
+       AnyTypeUnion m_value;
 
-template<>
-class Any_T<char> : public Any_Common<char>
-{
-public:
-       explicit Any_T(const char& value) : Any_Common<char>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Char; }
+       std::string m_json;
 
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
+       void * m_priv;
 
-template<>
-class Any_T<unsigned char> : public Any_Common<unsigned char>
-{
 public:
-       explicit Any_T(const unsigned char& value) : Any_Common<unsigned char>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_UChar; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
+       Any();
+       Any(bool value);
+       Any(double value, std::string json);
+       Any(std::string value);
+       Any(std::tm value, std::string json);
+       Any(void * priv, std::string json);
+       virtual ~Any();
+
+       virtual std::string toString() const;
+       std::string toJSON() const;
+
+       unsigned int getType() const;
+       bool isType(PrimitiveType type) const;
+
+       bool getBool() const;
+       char getChar() const;
+       unsigned char getUChar() const;
+       int getInt() const;
+       unsigned int getUInt() const;
+       long getLong() const;
+       unsigned long getULong() const;
+       double getDouble() const;
+       std::string getString() const;
+       std::tm getDateTm() const;
+       std::time_t getTimeT() const;
 };
+typedef DPL::SharedPtr<Any> AnyPtr;
 
-template<>
-class Any_T<int> : public Any_Common<int>
-{
-public:
-       explicit Any_T(const int& value) : Any_Common<int>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Int; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
-
-template<>
-class Any_T<unsigned int> : public Any_Common<unsigned int>
-{
-public:
-       explicit Any_T(const unsigned int& value) : Any_Common<unsigned int>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_UChar; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
-
-template<>
-class Any_T<long> : public Any_Common<long>
-{
-public:
-       explicit Any_T(const long& value) : Any_Common<long>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Long; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
-
-template<>
-class Any_T<unsigned long> : public Any_Common<unsigned long>
-{
-public:
-       explicit Any_T(const unsigned long& value) : Any_Common<unsigned long>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_ULong; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
-
-template<>
-class Any_T<double> : public Any_Common<double>
-{
-public:
-       explicit Any_T(const double& value) : Any_Common<double>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Double; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-               oss << m_value;
-               return oss.str();
-       }
-};
-
-template<>
-class Any_T<std::string> : public Any_Common<std::string>
-{
-public:
-       explicit Any_T(const std::string& value) : Any_Common<std::string>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_String; }
-
-       virtual std::string toString() const
-       {
-               return m_value;
-       }
-};
-
-template<>
-class Any_T<tm> : public Any_Common<tm>
-{
-public:
-       explicit Any_T(const tm& value) : Any_Common<tm>(value) {}
-       virtual PrimitiveType getType() const { return PrimitiveType_Time; }
-
-       virtual std::string toString() const
-       {
-               std::stringstream oss;
-
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(4) << (m_value.tm_year + 1900);
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << (m_value.tm_mon + 1);
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.tm_mday;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.tm_hour;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.tm_min;
-               oss << std::setfill('0') << std::setiosflags(std::ios::right) << std::setw(2) << m_value.tm_sec;
-
-               return oss.str();
-       }
-};
+typedef std::vector<AnyPtr> AnyArray;
+typedef DPL::SharedPtr<AnyArray> AnyArrayPtr;
 
 class AnyTypeConverter : public WrtDeviceApis::CommonsJavaScript::Converter
 {
@@ -295,18 +132,7 @@ public:
        virtual ~AnyTypeConverter();
 
        JSValueRef toJSValueRef(const AnyPtr& arg);
-       AnyPtr toAny(const JSValueRef &value, const PrimitiveType preferredNumberType=PrimitiveType_Double);
-
-       AnyPtr toAny(const bool &value);
-       AnyPtr toAny(const char &value);
-       AnyPtr toAny(const unsigned char &value);
-       AnyPtr toAny(const int &value);
-       AnyPtr toAny(const unsigned int &value);
-       AnyPtr toAny(const long &value);
-       AnyPtr toAny(const unsigned long &value);
-       AnyPtr toAny(const double &value);
-       AnyPtr toAny(const std::string &value);
-       AnyPtr toAny(const tm &value);
+       AnyPtr toAny(const JSValueRef &value);
 
        bool toBool(const AnyPtr& arg);
        char toChar(const AnyPtr& arg);
@@ -318,6 +144,7 @@ public:
        double toDouble(const AnyPtr& arg);
        std::string toString(const AnyPtr& arg);
        tm toDateTm(const AnyPtr& arg);
+       time_t toTimeT(const AnyPtr& arg);
 
        using WrtDeviceApis::CommonsJavaScript::Converter::toJSValueRef;
        using WrtDeviceApis::CommonsJavaScript::Converter::toString;
@@ -328,10 +155,6 @@ protected:
 };
 
 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<AnyTypeConverter> AnyTypeConverterFactory;
-// TODO How about processing Any types with JSON???
-
-typedef std::vector<AnyPtr> AnyArray;
-typedef DPL::SharedPtr<AnyArray> AnyArrayPtr;
 
 } // Tizen
 } // Api
index 532c6fd..ddd02f0 100644 (file)
@@ -30,13 +30,11 @@ namespace Tizen {
 using namespace std;
 
 AttributeFilter::AttributeFilter(const string attributeName,
-               const AnyArrayPtr& matchValues,
-        const string& matchFlag,
-        const bool caseSensitive) :
+        const MatchFlag& matchFlag,
+               const AnyArrayPtr& matchValues) :
        m_attributeName(attributeName),
-       m_matchValues(matchValues),
        m_matchFlag(matchFlag),
-       m_caseSensitive(caseSensitive)
+       m_matchValues(matchValues)
 {
 }
 
@@ -56,12 +54,12 @@ void AttributeFilter::setAttributeName(const string &value)
 
 bool AttributeFilter::validate(FilterValidatorPtr& validator, int depth)
 {
-       return validator->validateAttribute(m_attributeName, m_matchValues, m_matchFlag, m_caseSensitive, depth);
+       return validator->validateAttribute(m_attributeName, m_matchFlag, m_matchValues, depth);
 }
 
 void AttributeFilter::travel(IFilterVisitorPtr& visitor, int depth)
 {
-       visitor->visitAttribute(m_attributeName, m_matchValues, m_matchFlag, m_caseSensitive, depth);
+       visitor->visitAttribute(m_attributeName, m_matchFlag, m_matchValues, depth);
 }
 
 AnyArrayPtr AttributeFilter::getMatchValues() const
@@ -74,26 +72,16 @@ void AttributeFilter::setMatchValues(const AnyArrayPtr &value)
        m_matchValues = value;
 }
 
-string AttributeFilter::getMatchFlag() const
+MatchFlag AttributeFilter::getMatchFlag() const
 {
        return m_matchFlag;
 }
 
-void AttributeFilter::setMatchFlag(const string& value)
+void AttributeFilter::setMatchFlag(const MatchFlag& value)
 {
        m_matchFlag = value;
 }
 
-bool AttributeFilter::getCaseSensitive() const
-{
-       return m_caseSensitive;
-}
-
-void AttributeFilter::setCaseSensitive(const bool& value)
-{
-       m_caseSensitive = value;
-}
-
 } // Tizen
 } // Api
 } // TizenApis
index a1cf8ed..caa3beb 100644 (file)
@@ -46,17 +46,12 @@ private: // fields
        /**
         * match value object.
         */
-       AnyArrayPtr  m_matchValues;
+       MatchFlag  m_matchFlag;
 
        /**
         * match value object.
         */
-       std::string  m_matchFlag;
-
-       /**
-        * match value object.
-        */
-       bool  m_caseSensitive;
+       AnyArrayPtr  m_matchValues;
 
 protected:
 
@@ -66,9 +61,8 @@ public: // methods
         * constructor of abstraction filter
         */
        explicit AttributeFilter(const std::string attributeName,
-                       const AnyArrayPtr& matchValues,
-               const std::string& matchFlag,
-               const bool caseSensitive);
+               const MatchFlag& matchFlag,
+                       const AnyArrayPtr& matchValues);
 
        virtual ~AttributeFilter();
 
@@ -92,11 +86,8 @@ public: // methods
        AnyArrayPtr getMatchValues() const;
        void setMatchValues(const AnyArrayPtr &value);
 
-       std::string getMatchFlag() const;
-       void setMatchFlag(const std::string& value);
-
-       bool getCaseSensitive() const;
-       void setCaseSensitive(const bool &value);
+       MatchFlag getMatchFlag() const;
+       void setMatchFlag(const MatchFlag& value);
 };
 
 typedef DPL::SharedPtr<AttributeFilter> AttributeFilterPtr;
index c143cc4..5d2aa8f 100644 (file)
@@ -37,11 +37,10 @@ CompositeFilterPtr FilterFactory::createCompositeFilterObject(const FilterType&
 }
 
 AttributeFilterPtr FilterFactory::createAttributeFilterObject(const string& attributeName,
-               const AnyArrayPtr& matchValues,
-               const string& matchFlag,
-               const bool caseSensitive)
+               const MatchFlag& matchFlag,
+               const AnyArrayPtr& matchValues)
 {
-       AttributeFilterPtr result(new AttributeFilter(attributeName, matchValues, matchFlag, caseSensitive));
+       AttributeFilterPtr result(new AttributeFilter(attributeName, matchFlag, matchValues));
     return result;
 }
 
index d119096..d7ee360 100644 (file)
@@ -49,9 +49,8 @@ public:
                        const FilterArrayPtr& filters);
 
        AttributeFilterPtr createAttributeFilterObject(const std::string& attributeName,
-                       const AnyArrayPtr& matchValues,
-                       const std::string& matchFlag,
-                       const bool caseSensitive);
+                       const MatchFlag& matchFlag,
+                       const AnyArrayPtr& matchValues);
 
        AttributeRangeFilterPtr createAttributeRangeFilterObject(const std::string& attributeName,
                        const AnyPtr& initialValue,
index 9892745..45f05f8 100644 (file)
@@ -39,12 +39,13 @@ enum FilterType
 
 enum MatchFlag
 {
-       MATCH_NONE = 0,
-       MATCH_EXACTLY = 1 << 0,
-       MATCH_CONTAINS = 1 << 1,
-       MATCH_STARTSWITH = 1 << 2,
-       MATCH_ENDSWIDTH = 1 << 3,
-       MATCH_EXISTS = 1 << 4
+       MATCH_NONE,
+       MATCH_EXACTLY,
+       MATCH_FULLSTRING,
+       MATCH_CONTAINS,
+       MATCH_STARTSWITH,
+       MATCH_ENDSWITH,
+       MATCH_EXISTS
 };
 
 enum SortOrder
index 2a22c0e..a0a65be 100644 (file)
@@ -30,24 +30,20 @@ namespace Tizen {
 
 using namespace std;
 
-FilterValidator::FilterValidator(PropertyStructArray properties,
-               MatchFlagStrArray matchFlags)
+FilterValidator::FilterValidator(PropertyStructArray properties)
 {
        int i;
        for(i=0; properties[i].attributeName != 0 ; i++)
                m_properties[properties[i].attributeName] =
                                PropertyPtr(new Property(properties[i].type));
-
-       for(i=0; matchFlags[i] != 0; i++)
-               m_matchFlags[matchFlags[i]] = true;
 }
 
 FilterValidator::~FilterValidator()
 {
 }
 
-bool FilterValidator::validateAttribute(std::string& attrName, AnyArrayPtr& values,
-               std::string& matchFlag, bool caseSensitive, int depth)
+bool FilterValidator::validateAttribute(std::string& attrName,
+               MatchFlag& matchFlag, AnyArrayPtr& values, int depth)
 {
        if(m_properties[attrName] == NULL)
                return false;
@@ -62,9 +58,6 @@ bool FilterValidator::validateAttribute(std::string& attrName, AnyArrayPtr& valu
                                return false;
        }
 
-       if(m_matchFlags[matchFlag] == false)
-               return false;
-
        return true;
 }
 
@@ -76,6 +69,9 @@ bool FilterValidator::validateAttributeRange(std::string& attrName,
 
        PropertyPtr prop = m_properties[attrName];
 
+       if(initialValue == NULL && endValue == NULL)
+               return false;
+
        if(prop->type != initialValue->getType())
                return false;
 
index 7d3c589..c5459a4 100644 (file)
@@ -28,6 +28,7 @@
 #include <vector>
 #include <string>
 #include <dpl/shared_ptr.h>
+#include <API/Filter/FilterTypes.h>
 #include "AnyType.h"
 
 namespace TizenApis {
@@ -46,8 +47,6 @@ struct PropertyStruct
 };
 typedef PropertyStruct PropertyStructArray[];
 
-typedef const char *MatchFlagStrArray[];
-
 // GoF Visitor Pattern
 class FilterValidator
 {
@@ -61,20 +60,17 @@ private:
        };
        typedef DPL::SharedPtr<Property> PropertyPtr;
        typedef std::map<std::string, PropertyPtr> PropertyMap;
-       typedef std::map<std::string, bool> MatchFlagList;
 
        PropertyMap                             m_properties;
-       MatchFlagList                   m_matchFlags;
 
 public:
-       FilterValidator(PropertyStructArray properties,
-                       MatchFlagStrArray matchFlag);
+       FilterValidator(PropertyStructArray properties);
 
        virtual ~FilterValidator();
 
        // validate AttributeFilter
-       virtual bool validateAttribute(std::string& attrName, AnyArrayPtr& values,
-                       std::string& matchFlag, bool caseSensitive, int depth=0);
+       virtual bool validateAttribute(std::string& attrName,
+                       MatchFlag& matchFlag, AnyArrayPtr& values, int depth=0);
 
        // validate AttributeRangeFilter
        virtual bool validateAttributeRange(std::string& attrName,
index 38a048f..cefd2a0 100644 (file)
@@ -50,7 +50,7 @@ public:
        virtual void visitInComposite(FilterType& type, int depth) = 0;
        virtual void visitPostComposite(FilterType& type, int depth) = 0;
        virtual void visitAttribute(std::string& attrName,
-                       AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth) = 0;
+                       MatchFlag& matchFlag, AnyArrayPtr& values, int depth) = 0;
        virtual void visitAttributeRange(std::string& attrName, AnyPtr& initialValue, AnyPtr& endValue, int depth) = 0;
 };
 
diff --git a/src/platform/API/Filter/SimpleCoordinates.cpp b/src/platform/API/Filter/SimpleCoordinates.cpp
new file mode 100644 (file)
index 0000000..ccc441b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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       SimpleCoordinates.cpp
+ * @author     Kisub Song (kisubs.song@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#include "SimpleCoordinates.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Tizen {
+
+using namespace std;
+
+SimpleCoordinates::SimpleCoordinates(const double latitude,
+        const double longitude) :
+       m_latitude(latitude),
+       m_longitude(longitude)
+{
+}
+
+SimpleCoordinates::~SimpleCoordinates()
+{
+}
+
+double SimpleCoordinates::getLatitude() const
+{
+       return m_latitude;
+}
+
+void SimpleCoordinates::setLatitude(const double value)
+{
+       m_latitude = value;
+}
+
+double SimpleCoordinates::getLongitude() const
+{
+       return m_longitude;
+}
+
+void SimpleCoordinates::setLongitude(const double value)
+{
+       m_longitude = value;
+}
+
+} // Tizen
+} // Api
+} // TizenApis
diff --git a/src/platform/API/Filter/SimpleCoordinates.h b/src/platform/API/Filter/SimpleCoordinates.h
new file mode 100644 (file)
index 0000000..926944e
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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       SimpleCoordinates.h
+ * @author     Kisub Song (kisubs.song@samsung.com)
+ * @version    0.1
+ * @brief
+ */
+
+#ifndef _API_SIMPLE_CORDINATES_H_
+#define _API_SIMPLE_CORDINATES_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Tizen {
+
+class SimpleCoordinates
+{
+private: // fields
+
+       /**
+        * attribute latitude object
+        */
+       double  m_latitude;
+
+       /**
+        * match value object.
+        */
+       double  m_longitude;
+
+protected:
+
+public: // methods
+
+       /**
+        * constructor of SimpleCoorindates
+        */
+       explicit SimpleCoordinates(const double latitude,
+                       const double longitude);
+
+       virtual ~SimpleCoordinates();
+
+       double getLatitude() const;
+       void setLatitude(const double value);
+
+       double getLongitude() const;
+       void setLongitude(const double value);
+};
+
+typedef DPL::SharedPtr<SimpleCoordinates> SimpleCoordinatesPtr;
+
+} // Tizen
+} // Api
+} // TizenApis
+
+#endif // _API_SIMPLE_CORDINATES_H_
index 723e635..67ac58d 100755 (executable)
@@ -9,5 +9,6 @@ set(SRCS_PLATFORM_API_FILTER
   ${CURRENT_PATH}/SortMode.cpp
   ${CURRENT_PATH}/IFilterVisitor.cpp
   ${CURRENT_PATH}/FilterValidator.cpp
+  ${CURRENT_PATH}/SimpleCoordinates.cpp
   PARENT_SCOPE
 )
diff --git a/src/platform/API/Mediacontent/IEventAddAudioToPlaylist.h b/src/platform/API/Mediacontent/IEventAddAudioToPlaylist.h
new file mode 100644 (file)
index 0000000..ba33b20
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+* 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_ADD_AUDIO_TO_PLAYLIST_H_
+#define _ABSTRACT_LAYER_IEVENT_ADD_AUDIO_TO_PLAYLIST_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentPlaylist.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventAddAudioToPlaylist : public WrtDeviceApis::Commons::IEvent<IEventAddAudioToPlaylist>
+{
+
+       public:
+       IEventAddAudioToPlaylist():m_result(false), m_playlistId(NULL), m_mediaUID(NULL)
+    {
+        LogDebug("entered");
+    }
+       ~IEventAddAudioToPlaylist(){}
+       
+
+    void setPlaylistId(string& value)
+    {
+        m_playlistId = value;
+    }
+
+       string getPlaylistId()
+       {       
+               return m_playlistId; 
+       }
+
+    void setMediaUID(string& value)
+    {
+        m_mediaUID = value;
+    }
+
+       string getMediaUID()
+       {       
+               return m_mediaUID; 
+       }
+       
+
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool getResult() const
+    {
+        return m_result;
+    }
+
+
+       private:
+       bool m_result;
+       string m_playlistId;           //OUTPUT: result list
+       string m_mediaUID;
+};
+
+typedef DPL::SharedPtr<IEventAddAudioToPlaylist> IEventAddAudioToPlaylistPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_ADD_AUDIO_TO_PLAYLIST_H_ */
diff --git a/src/platform/API/Mediacontent/IEventDeleteAudioToPlaylist.h b/src/platform/API/Mediacontent/IEventDeleteAudioToPlaylist.h
new file mode 100644 (file)
index 0000000..40bf99d
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+* 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_DELETE_AUDIO_TO_PLAYLIST_H_
+#define _ABSTRACT_LAYER_IEVENT_DELETE_AUDIO_TO_PLAYLIST_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentPlaylist.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventDeleteAudioToPlaylist : public WrtDeviceApis::Commons::IEvent<IEventDeleteAudioToPlaylist>
+{
+
+       public:
+       IEventDeleteAudioToPlaylist():m_result(false), m_playlistId(NULL), m_mediaUID(NULL)
+    {
+        LogDebug("entered");
+    }
+       ~IEventDeleteAudioToPlaylist(){}
+       
+
+    void setPlaylistId(string& value)
+    {
+        m_playlistId = value;
+    }
+
+       string getPlaylistId()
+       {       
+               return m_playlistId; 
+       }
+
+    void setMediaUID(string& value)
+    {
+        m_mediaUID = value;
+    }
+
+       string getMediaUID()
+       {       
+               return m_mediaUID; 
+       }
+       
+
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool getResult() const
+    {
+        return m_result;
+    }
+
+
+       private:
+       bool m_result;
+       string m_playlistId;           //OUTPUT: result list
+       string m_mediaUID;
+};
+
+typedef DPL::SharedPtr<IEventDeleteAudioToPlaylist> IEventDeleteAudioToPlaylistPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_DELETE_AUDIO_TO_PLAYLIST_H_ */
diff --git a/src/platform/API/Mediacontent/IEventDeletePlaylist.h b/src/platform/API/Mediacontent/IEventDeletePlaylist.h
new file mode 100644 (file)
index 0000000..d77e37e
--- /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. 
+*/
+
+
+#ifndef _ABSTRACT_LAYER_IEVENT_DELETE_PLAYLIST_H_
+#define _ABSTRACT_LAYER_IEVENT_DELETE_PLAYLIST_H_
+
+#include <vector>
+#include <string>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentPlaylist.h"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventDeletePlaylist : public WrtDeviceApis::Commons::IEvent<IEventDeletePlaylist>
+{
+
+       public:
+       IEventDeletePlaylist()//:m_result(false), m_playlistID(NULL)
+    {
+        LogDebug("entered");
+    }
+       ~IEventDeletePlaylist(){}
+       
+
+    void setPlaylistId(const string& value)
+    {
+        m_playlistID = value;
+    }
+
+       string getPlaylistId()
+       {       
+               return m_playlistID; 
+       }
+       
+
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool getResult() const
+    {
+        return m_result;
+    }
+
+
+       private:
+       bool m_result;
+       string m_playlistID;
+};
+
+typedef DPL::SharedPtr<IEventDeletePlaylist> IEventDeletePlaylistPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_DELETE_PLAYLIST_H_ */
diff --git a/src/platform/API/Mediacontent/IEventFindFolder.h b/src/platform/API/Mediacontent/IEventFindFolder.h
new file mode 100644 (file)
index 0000000..bc9dbc1
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+* 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_FIND_FOLDER_H_
+#define _ABSTRACT_LAYER_IEVENT_FIND_FOLDER_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include <API/Filter/IFilter.h>
+#include <API/Filter/SortMode.h>
+#include "MediacontentFolder.h"
+
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventFindFolder : public WrtDeviceApis::Commons::IEvent<IEventFindFolder>
+{
+       public:
+       IEventFindFolder()
+       {       
+               m_result = false;
+               m_filterIsSet = false;
+               m_sortModesIsSet = false;
+               m_limitIsSet = false;
+               m_offsetIsSet = false;
+               
+       }
+       ~IEventFindFolder(){}           
+       
+       void addFolder(MediacontentFolderPtr value)
+       { 
+               m_folder.push_back(value);
+       }
+       
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       vector<MediacontentFolderPtr> getFolder()
+       {
+               return m_folder; 
+       }
+
+       void setLimit(const unsigned long value)
+       {
+               m_limitIsSet = true;
+               m_limit = value;
+       }
+       void setOffset(const unsigned long value)
+       {
+               m_offsetIsSet = true;
+               m_offset = value;
+       }
+
+       void setFilter(const Tizen::FilterPtr &value)
+       {
+               m_filter = value;
+               m_filterIsSet = true;
+       }
+
+       void setSortModes(const Tizen::SortModeArrayPtr &value)
+       {
+               m_sortModes = value;
+               m_sortModesIsSet = true;
+       }
+
+       bool getLimitIsSet() const
+       {
+               return m_limitIsSet;
+       }
+       
+       bool getOffsetIsSet() const
+       {
+               return m_offsetIsSet;
+       }
+
+       bool getResult()const
+       {
+               return m_result; 
+       }
+
+       bool getFilterIsSet()const
+       {
+               return m_filterIsSet; 
+       }
+       
+       bool getSortModesIsSet()const
+       {
+               return m_sortModesIsSet; 
+       }
+
+       unsigned long getLimit() const
+       {
+               return m_limit;
+       }
+       
+       unsigned long getOffset() const
+       {
+               return m_offset;
+       }       
+
+       FilterPtr getFilter() const
+       {
+               return m_filter;
+       }
+       
+       SortModeArrayPtr getSortModes() const
+       {
+               return m_sortModes;
+       }
+
+
+
+       virtual void clearOnCancel(){;}
+
+
+       private:
+       bool m_filterIsSet;
+       bool m_sortModesIsSet;
+
+       bool m_result;                                  //OUTPUT: operation result
+       bool m_limitIsSet;
+       bool m_offsetIsSet;
+
+
+       unsigned long m_limit;
+       unsigned long m_offset;
+       FilterPtr m_filter;
+       SortModeArrayPtr m_sortModes;
+       vector<MediacontentFolderPtr> m_folder;           //OUTPUT: result list
+
+
+       
+};
+
+typedef DPL::SharedPtr<IEventFindFolder> IEventFindFolderPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FIND_FOLDER_H_ */
diff --git a/src/platform/API/Mediacontent/IEventFindMedia.h b/src/platform/API/Mediacontent/IEventFindMedia.h
new file mode 100644 (file)
index 0000000..d410186
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+* 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_FIND_MEDIA_H_
+#define _ABSTRACT_LAYER_IEVENT_FIND_MEDIA_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <API/Filter/IFilter.h>
+#include <API/Filter/SortMode.h>
+
+#include <dpl/shared_ptr.h>
+#include "MediacontentMedia.h"
+
+using namespace TizenApis::Api::Tizen;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventFindMedia : public WrtDeviceApis::Commons::IEvent<IEventFindMedia>
+{
+
+       public:
+               
+       IEventFindMedia()
+       {
+               m_result = false;
+               m_filterIsSet = false;
+               m_sortModesIsSet = false;
+               m_limitIsSet = false;
+               m_offsetIsSet = false;
+
+       }
+       
+               
+       virtual ~IEventFindMedia(){}
+
+       void addMedia(MediacontentMedia *value)
+       {
+               MediacontentMediaPtr mediaItem(value);
+               m_media.push_back(mediaItem);   
+       }
+
+       vector<MediacontentMediaPtr> getMedia()
+       {       
+               return m_media; 
+       }
+       
+
+       void setLimit(const unsigned long value)
+       {
+               m_limitIsSet = true;
+               m_limit = value;
+       }
+       void setOffset(const unsigned long value)
+       {
+               m_offsetIsSet = true;
+               m_offset = value;
+       }
+
+       void setFilter(const Tizen::FilterPtr &value)
+       {
+               m_filter = value;
+               m_filterIsSet = true;
+       }
+
+       void setSortModes(const Tizen::SortModeArrayPtr &value)
+       {
+               m_sortModes = value;
+               m_sortModesIsSet = true;
+       }
+
+       void setResult(bool value)
+       {
+               m_result = value;
+       }
+
+       bool getLimitIsSet() const
+       {
+               return m_limitIsSet;
+       }
+       
+       bool getOffsetIsSet() const
+       {
+               return m_offsetIsSet;
+       }
+
+       bool getResult()const
+       {
+               return m_result; 
+       }
+
+       bool getFilterIsSet()const
+       {
+               return m_filterIsSet; 
+       }
+       
+       bool getSortModesIsSet()const
+       {
+               return m_sortModesIsSet; 
+       }
+
+       unsigned long getLimit() const
+       {
+               return m_limit;
+       }
+       
+       unsigned long getOffset() const
+       {
+               return m_offset;
+       }       
+
+       FilterPtr getFilter() const
+       {
+               return m_filter;
+       }
+       
+       SortModeArrayPtr getSortModes() const
+       {
+               return m_sortModes;
+       }
+
+
+       private:
+       bool m_filterIsSet;
+       bool m_sortModesIsSet;
+
+       bool m_result;                                                                  //OUTPUT: operation result
+       bool m_limitIsSet;
+       bool m_offsetIsSet;
+
+       unsigned long m_limit;
+       unsigned long m_offset;
+       FilterPtr m_filter;
+       SortModeArrayPtr m_sortModes;
+
+       vector<MediacontentMediaPtr> m_media;  
+
+};
+
+typedef DPL::SharedPtr<IEventFindMedia> IEventFindMediaPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FIND_MEDIA_H_ */
diff --git a/src/platform/API/Mediacontent/IEventFindPlaylist.h b/src/platform/API/Mediacontent/IEventFindPlaylist.h
new file mode 100644 (file)
index 0000000..b5b9d0d
--- /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 _ABSTRACT_LAYER_IEVENT_FIND_PLAYLIST_H_
+#define _ABSTRACT_LAYER_IEVENT_FIND_PLAYLIST_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentPlaylist.h"
+
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventFindPlaylist : public WrtDeviceApis::Commons::IEvent<IEventFindPlaylist>
+{
+       public:
+       IEventFindPlaylist():m_result(false){}
+       ~IEventFindPlaylist(){ }                
+       void addPlaylist(MediacontentPlaylistPtr value){ m_playlist.push_back(value);}
+       void setResult(bool value){m_result = value;}
+       bool getResult()const {return m_result; }
+       vector<MediacontentPlaylistPtr> getPlaylist(){return m_playlist; }
+
+       virtual void clearOnCancel(){;}
+
+
+       private:
+       vector<MediacontentPlaylistPtr> m_playlist;           //OUTPUT: result list
+       bool m_result;                                  //OUTPUT: operation result
+};
+
+typedef DPL::SharedPtr<IEventFindPlaylist> IEventFindPlaylistPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FIND_PLAYLIST_H_ */
diff --git a/src/platform/API/Mediacontent/IEventFolderFindMedia.h b/src/platform/API/Mediacontent/IEventFolderFindMedia.h
new file mode 100644 (file)
index 0000000..5d27e46
--- /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 _ABSTRACT_LAYER_IEVENT_FOLDER_FIND_MEDIA_H_
+#define _ABSTRACT_LAYER_IEVENT_FOLDER_FIND_MEDIA_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include "MediacontentMedia.h"
+#include "MediacontentFolder.h"
+#include <dpl/shared_ptr.h>
+
+namespace WrtPlugins {
+namespace Api {
+
+class IEventFolderFindMedia : public WrtDeviceApis::Commons::IEvent<IEventFolderFindMedia>
+{
+       public:
+                       IEventFolderFindMedia():m_result(false){}
+                       ~IEventFolderFindMedia(){ }             
+
+       MediacontentFolderPtr getFolder(){ return m_folder;}
+       std::vector<MediacontentMediaPtr> getMedia(){   return m_media; }
+
+       void            addMedia(MediacontentMediaPtr value){ m_media.push_back(value); }
+       void            setResult(bool value) { m_result = value; }
+       bool            getResult()const { return m_result; }
+       void            setFolder(MediacontentFolderPtr folder){ m_folder = folder;}
+
+       virtual void    clearOnCancel(){;}
+
+
+       private:
+       MediacontentFolderPtr m_folder;
+       std::vector<MediacontentMediaPtr> m_media;     
+       bool m_result;                                 
+};
+
+typedef DPL::SharedPtr<IEventFolderFindMedia> IEventFolderFindMediaPtr;
+
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_FOLDER_FIND_MEDIA_H_ */
diff --git a/src/platform/API/Mediacontent/IEventGetMediacontent.h b/src/platform/API/Mediacontent/IEventGetMediacontent.h
new file mode 100644 (file)
index 0000000..d1cf5b4
--- /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 _ABSTRACT_LAYER_IEVENT_GET_MEDIACONTENT_H_
+#define _ABSTRACT_LAYER_IEVENT_GET_MEDIACONTENT_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include "IMediacontent.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventGetMediacontent : public WrtDeviceApis::Commons::IEvent<IEventGetMediacontent>
+{
+       public:
+               IEventGetMediacontent():m_result(false){}
+               ~IEventGetMediacontent(){}
+
+               IMediacontentPtr getMediacontent() const 
+               { 
+                       return m_mediacontent;
+               }
+               
+               void setMediacontent(IMediacontentPtr value)
+               {
+                       m_mediacontent = value;
+               }
+               
+               void setResult(bool value)
+               { 
+                       m_result = value; 
+               }
+               bool getResult() const
+               { 
+                       return m_result; 
+               }
+
+       public:
+               bool    m_result;
+               IMediacontentPtr     m_mediacontent;
+};
+typedef DPL::SharedPtr<IEventGetMediacontent> IEventGetMediacontentPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_GET_MEDIACONTENT_H_ */
diff --git a/src/platform/API/Mediacontent/IEventUpdateMedia.h b/src/platform/API/Mediacontent/IEventUpdateMedia.h
new file mode 100644 (file)
index 0000000..df951a1
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+* 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_UPDATE_ITEM_H_
+#define _ABSTRACT_LAYER_IEVENT_UPDATE_ITEM_H_
+
+#include <vector>
+#include <Commons/IEvent.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentMedia.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IEventUpdateMedia : public WrtDeviceApis::Commons::IEvent<IEventUpdateMedia>
+{
+
+       public:
+       IEventUpdateMedia():m_result(false), m_media(NULL)
+    {
+        LogDebug("entered");
+    }
+       ~IEventUpdateMedia(){}
+       
+
+    void setMediaItem(MediacontentMediaPtr value)
+    {
+       LogDebug("setMediaItem11");
+        m_media = value;
+    }
+
+       MediacontentMediaPtr getMediaItem()
+       {       
+               return m_media; 
+       }
+       
+
+    void setResult(bool value)
+    {
+        m_result = value;
+    }
+    bool getResult() const
+    {
+        return m_result;
+    }
+
+
+       private:
+       bool m_result;
+       MediacontentMediaPtr m_media;           //OUTPUT: result list
+};
+
+typedef DPL::SharedPtr<IEventUpdateMedia> IEventUpdateMediaPtr;
+
+}
+}
+}
+#endif /* _ABSTRACT_LAYER_IEVENT_UPDATE_ITEM_H_ */
diff --git a/src/platform/API/Mediacontent/IMediacontent.cpp b/src/platform/API/Mediacontent/IMediacontent.cpp
new file mode 100644 (file)
index 0000000..4b5f4a5
--- /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 "IMediacontent.h"
+#include <Commons/ThreadPool.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+
+IMediacontent::IMediacontent():
+       WrtDeviceApis::Commons::EventRequestReceiver<IEventFindMedia>(WrtDeviceApis::Commons::ThreadEnum::GALLERY_THREAD),
+       WrtDeviceApis::Commons::EventRequestReceiver<IEventFindFolder>(WrtDeviceApis::Commons::ThreadEnum::GALLERY_THREAD),
+       WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateMedia>(WrtDeviceApis::Commons::ThreadEnum::GALLERY_THREAD)
+       // TODO TO be changed to MEDIACONTENT_THREAD
+{
+       LogDebug("IMediacontent::Constructure entered");
+}
+
+IMediacontent::~IMediacontent()
+{
+}
+
+void IMediacontent::findMedia(IEventFindMediaPtr &ptr)
+{
+       LogDebug("IMediacontent::called findItems");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindMedia>::PostRequest(ptr);
+}
+
+void IMediacontent::findFolder(IEventFindFolderPtr &ptr)
+{
+       LogDebug("IMediacontent::called findFolders");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventFindFolder>::PostRequest(ptr);
+}
+
+void IMediacontent::updateMedia(IEventUpdateMediaPtr &ptr)
+{
+       LogDebug("IMediacontent::called updateMedia");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateMedia>::PostRequest(ptr);
+}
+
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/IMediacontent.h b/src/platform/API/Mediacontent/IMediacontent.h
new file mode 100644 (file)
index 0000000..7bb9414
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+* 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_IMEDIACONTENT_H_
+#define _ABSTRACT_LAYER_IMEDIACONTENT_H_
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include "IEventFindMedia.h"
+#include "IEventFindFolder.h"
+#include "IEventUpdateMedia.h"
+
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IMediacontent : 
+        public WrtDeviceApis::Commons::EventRequestReceiver<IEventFindMedia>,
+        public WrtDeviceApis::Commons::EventRequestReceiver<IEventFindFolder>,
+        public WrtDeviceApis::Commons::EventRequestReceiver<IEventUpdateMedia>
+               
+{
+       public:
+
+       typedef enum
+       {
+               MEDIACONTENT_IMAGE,
+               MEDIACONTENT_VIDEO,
+               MEDIACONTENT_AUDIO
+       } MediacontentType;
+
+       IMediacontent();
+       virtual ~IMediacontent();
+       virtual void findMedia(IEventFindMediaPtr &ptr);
+       virtual void findFolder(IEventFindFolderPtr &ptr);      
+       virtual void updateMedia(IEventUpdateMediaPtr &ptr);
+
+       virtual void OnRequestReceived(const IEventFindMediaPtr &value) = 0;
+       virtual void OnRequestReceived(const IEventFindFolderPtr &value) = 0;
+       virtual void OnRequestReceived(const IEventUpdateMediaPtr &value) = 0;
+
+};
+
+typedef DPL::SharedPtr<IMediacontent> IMediacontentPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_ICALENDAR_H_ */
diff --git a/src/platform/API/Mediacontent/IMediacontentManager.cpp b/src/platform/API/Mediacontent/IMediacontentManager.cpp
new file mode 100644 (file)
index 0000000..5b9aa49
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* 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/ThreadPool.h>
+#include "IMediacontentManager.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+IMediacontentManager::IMediacontentManager() :
+       WrtDeviceApis::Commons::EventRequestReceiver< IEventGetMediacontent >(WrtDeviceApis::Commons::ThreadEnum::CALENDAR_THREAD)
+{
+}
+
+IMediacontentManager::~IMediacontentManager()
+{
+}
+
+void IMediacontentManager::getMediacontent( const IEventGetMediacontentPtr &event )
+{
+    LogDebug("entered");
+    WrtDeviceApis::Commons::EventRequestReceiver<IEventGetMediacontent>::PostRequest(event);
+}
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/IMediacontentManager.h b/src/platform/API/Mediacontent/IMediacontentManager.h
new file mode 100644 (file)
index 0000000..0840f43
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+* 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_IMEDIACONTENT_MANAGER_H_
+#define _ABSTRACT_LAYER_IMEDIACONTENT_MANAGER_H_
+
+#include "IMediacontent.h"
+#include "IEventGetMediacontent.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class IMediacontentManager : public WrtDeviceApis::Commons::EventRequestReceiver< IEventGetMediacontent >
+{
+    public:
+       IMediacontentManager();
+       virtual ~IMediacontentManager();
+       virtual void getMediacontent(const IEventGetMediacontentPtr &event );
+       
+       protected:
+       virtual void OnRequestReceived(const IEventGetMediacontentPtr &event) = 0;
+};
+
+typedef DPL::SharedPtr<IMediacontentManager> IMediacontentManagerPtr;
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_IMEDIACONTENT_MANAGER_H_ */
diff --git a/src/platform/API/Mediacontent/MediacontentAudio.cpp b/src/platform/API/Mediacontent/MediacontentAudio.cpp
new file mode 100644 (file)
index 0000000..8defb18
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+* 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 "MediacontentAudio.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+MediacontentAudio::MediacontentAudio()
+{
+       m_isChangedPlayCount = false;
+       m_isChangedPlayedTime = false;
+
+}
+
+MediacontentAudio::~MediacontentAudio()
+{
+}
+
+
+string MediacontentAudio::getAudioAlbum() const
+{
+       return m_audioAlbum;
+}
+string MediacontentAudio::getAudioArtist() const
+{
+       return m_audioArtist;
+}
+
+string MediacontentAudio::getAudioGenre() const
+{
+       return m_audioGenre;
+}
+string MediacontentAudio::getAudioComposer() const
+{
+       return m_audioAuthor;
+}
+
+string MediacontentAudio::getAudioCopyright() const
+{
+       return m_audioCopyright;
+}
+
+int MediacontentAudio::getAudioBitrate() const
+{
+       return m_audioBitrate;
+}
+
+
+int MediacontentAudio::getAudioTrackNum() const
+{
+       return m_audioTrackNum;
+}
+
+int MediacontentAudio::getAudioDuration() const
+{
+       return m_audioDuration;
+}
+
+int MediacontentAudio::getAudioPlayCount() const
+{
+       return m_audioPlayCount;
+}
+
+int MediacontentAudio::getAudioPlayedTime() const
+{
+       return m_audioPlayedTime;
+}
+
+
+int MediacontentAudio::getAudioSize() const
+{      
+       return m_audioSize;
+}
+
+MediacontentLyricsPtr MediacontentAudio::getAudioLyrics() const
+{
+       return m_lyrics;
+}
+
+
+void MediacontentAudio::setAudioAlbum(const string &value)
+{
+       m_audioAlbum = value;
+}
+
+void MediacontentAudio::setAudioArtist(const string &value)
+{
+       m_audioAlbum = value;
+}
+
+void MediacontentAudio::setAudioGenre(const string &value)
+{
+       m_audioGenre = value;
+}
+
+void MediacontentAudio::setAudioComposer(const string &value)
+{
+       m_audioAuthor = value;
+}
+
+void MediacontentAudio::setAudioCopyright(const string &value)
+{
+       m_audioCopyright = value;
+}
+
+void MediacontentAudio::setAudioBitrate(const int &value) 
+{
+       m_audioBitrate = value;
+}
+
+void MediacontentAudio::setAudioTrackNum(const int &value)
+{
+       m_audioTrackNum = value;
+}
+
+void MediacontentAudio::setAudioDuration(const int &value)     
+{
+       m_audioDuration = value;
+}
+
+void MediacontentAudio::setAudioPlayCount(const int &value)
+{
+       m_audioPlayCount = value;
+       m_isChangedPlayCount = true;
+}
+
+void MediacontentAudio::setAudioPlayedTime(const int &value)
+{
+       m_audioPlayedTime = value;
+       m_isChangedPlayedTime = true;
+}
+
+void MediacontentAudio::setAudioSize(const int &value)
+{
+       m_audioSize = value;
+}
+
+void MediacontentAudio::setAudioLyrics(MediacontentLyricsPtr value)
+{
+       m_lyrics = value;
+}
+
+
+
+void MediacontentAudio::display() const
+{
+
+       MediacontentMedia::display();
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentAudio.h b/src/platform/API/Mediacontent/MediacontentAudio.h
new file mode 100644 (file)
index 0000000..340afc5
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+* 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_MEDIACONTENT_AUDIO_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_AUDIO_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentMedia.h"
+#include "MediacontentLyrics.h"
+
+
+using namespace std;
+
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class MediacontentAudio : public MediacontentMedia
+{
+       public:
+
+       MediacontentAudio();
+       virtual ~MediacontentAudio();
+
+
+       string getAudioAlbum() const;
+       string getAudioArtist() const;
+       string getAudioGenre() const;
+       string getAudioComposer() const;
+       string getAudioCopyright() const;
+       int getAudioBitrate() const;    
+       int getAudioTrackNum() const;
+       int getAudioDuration() const;   
+       int getAudioRating() const;
+       int getAudioPlayCount() const;
+       int getAudioPlayedTime() const;
+       int getAudioSize() const;
+       
+       MediacontentLyricsPtr getAudioLyrics() const;
+
+       void setAudioAlbum(const string &value);
+       void setAudioArtist(const string &value);
+       void setAudioGenre(const string &value);
+       void setAudioComposer(const string &value);
+       void setAudioCopyright(const string &value);
+       void setAudioBitrate(const int &value); 
+       void setAudioTrackNum(const int &value);
+       void setAudioDuration(const int &value);        
+       void setAudioPlayCount(const int &value);
+       void setAudioPlayedTime(const int &value);
+       void setAudioSize(const int &value);
+
+       void setAudioLyrics(MediacontentLyricsPtr value);
+
+       
+       void display() const;                   
+
+
+       protected:
+       string m_audioAlbum;
+       string m_audioArtist;
+       string m_audioGenre;
+       string m_audioAuthor;
+       string m_audioCopyright;
+       int m_audioTrackNum;
+       int m_audioDuration;
+       int m_audioPlayCount;
+       int m_audioPlayedTime;
+       int m_audioBitrate;
+       int m_audioSize;
+       bool m_isChangedPlayCount;
+       bool m_isChangedPlayedTime;
+
+       MediacontentLyricsPtr m_lyrics;
+
+};
+
+typedef DPL::SharedPtr<MediacontentAudio> MediacontentAudioPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_AUDIO_H_ */
+
diff --git a/src/platform/API/Mediacontent/MediacontentFactory.cpp b/src/platform/API/Mediacontent/MediacontentFactory.cpp
new file mode 100644 (file)
index 0000000..479edda
--- /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. 
+*/
+
+
+#include "MediacontentFactory.h"
+#include <Mediacontent/MediacontentManager.h>
+#include <Mediacontent/Mediacontent.h>
+
+
+using namespace TizenApis::Platform::Mediacontent;
+
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+IMediacontentManagerPtr MediacontentFactory::createMediacontentManagerObject()
+{
+    IMediacontentManagerPtr result(new MediacontentManager());
+    return result;
+}
+IMediacontentPtr MediacontentFactory::createMediacontentObject()
+{
+    IMediacontentPtr result(new TizenApis::Platform::Mediacontent::Mediacontent());
+    return result;
+}
+
+MediacontentFactory& MediacontentFactory::getInstance()
+{
+    static MediacontentFactory theInstance;
+    return theInstance;
+}
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentFactory.h b/src/platform/API/Mediacontent/MediacontentFactory.h
new file mode 100644 (file)
index 0000000..7b26857
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* 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_MEDIACONTENT_FACTORY_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_FACTORY_H_
+
+#include "IMediacontentManager.h"
+#include "IMediacontent.h"
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+       
+class MediacontentFactory : private DPL::Noncopyable
+{
+       private:
+       MediacontentFactory(){}
+
+       public:
+       static MediacontentFactory& getInstance();
+       IMediacontentManagerPtr    createMediacontentManagerObject();
+       IMediacontentPtr           createMediacontentObject();
+};
+
+}
+}
+}
+
+#endif /* WRTPLUGINSCAMERAFACTORY_H_ */
\ No newline at end of file
diff --git a/src/platform/API/Mediacontent/MediacontentFolder.cpp b/src/platform/API/Mediacontent/MediacontentFolder.cpp
new file mode 100644 (file)
index 0000000..a3d758a
--- /dev/null
@@ -0,0 +1,147 @@
+/*
+* 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 "MediacontentFolder.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+MediacontentFolder::MediacontentFolder()
+{
+
+}
+
+MediacontentFolder::~MediacontentFolder()
+{
+
+}
+
+
+EditableAttributeListPtr       MediacontentFolder::getEditableAttr() const
+{
+    return m_editableAttrPtr;
+}
+
+
+string MediacontentFolder::getFolderUUID() const
+{
+    return m_folderUUID;
+}
+
+void MediacontentFolder::setFolderUUID(const string &value)
+{
+       m_folderUUID = value;
+}
+
+
+string MediacontentFolder::getFolderName() const
+{
+    return m_folderName;
+}
+
+void MediacontentFolder::setFolderName(const string &value)
+{
+       m_folderName = value;
+}
+
+string MediacontentFolder::getFolderPath() const
+{
+       return m_folderPath;
+
+}
+
+void MediacontentFolder::setFolderPath(const string &value)
+{
+       m_folderPath = value;
+
+}
+
+string MediacontentFolder::getFolderStorageType()
+{
+       return m_storageType;   
+}
+
+void MediacontentFolder::setFolderStorageType(const string &value)
+{
+       m_storageType = value;
+
+}
+tm MediacontentFolder::getFolderModifiedDate() const
+{
+       return m_modifiedDate;
+}
+
+MediaIdListPtr MediacontentFolder::getMediaIdList() const
+{
+       return m_mediaIdArrayPtr;
+}
+
+
+void MediacontentFolder::setFolderModifiedDate(const tm &value)
+{
+       m_modifiedDate = value;
+
+}
+
+void MediacontentFolder::setMediaIdList(const MediaIdListPtr &value)
+{
+       m_mediaIdArrayPtr = value;
+
+}
+
+
+void MediacontentFolder::insertValue(string attrName, string value)
+{
+       m_folderValue.insert(pair<string, string>(attrName,value));
+}
+
+string MediacontentFolder::findValue(string attrName)
+{
+
+       string value;
+       
+       map<string, string>::iterator pos;
+
+       pos = m_folderValue.find(attrName);
+
+       if(m_folderValue.end() != pos)
+       {
+               value = pos->second;
+       }
+       else
+       {
+               LogDebug("Attribute(" << attrName << ") There is no data.");
+       }
+       return value;
+}
+
+
+void MediacontentFolder::display() const
+{
+    LogDebug("m_folderUUID: " << m_folderUUID);
+    LogDebug("m_folderName: " << m_folderName);
+       LogDebug("m_folderPath: " << m_folderPath);
+       LogDebug("m_storageType: " << m_storageType);
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentFolder.h b/src/platform/API/Mediacontent/MediacontentFolder.h
new file mode 100644 (file)
index 0000000..17e3240
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+* 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_MEDIACONTENT_FOLDER_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_FOLDER_H_
+
+#include <map>
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+typedef vector<std::string> EditableAttributeList;
+typedef DPL::SharedPtr<EditableAttributeList> EditableAttributeListPtr;
+
+typedef vector<std::string> MediaIdList;
+typedef DPL::SharedPtr<MediaIdList> MediaIdListPtr;
+
+class MediacontentFolder
+{
+       public:
+
+       MediacontentFolder();
+       virtual ~MediacontentFolder();
+
+       EditableAttributeListPtr        getEditableAttr() const;
+       string  getFolderUUID() const;
+       string  getFolderPath() const;  
+       string  getFolderName() const;
+       string  getFolderStorageType();
+       tm      getFolderModifiedDate() const;
+       MediaIdListPtr  getMediaIdList() const; 
+
+       void setFolderUUID(const string &value);
+       void setFolderPath(const string &value);        
+       void setFolderName(const string &value);
+       void setFolderStorageType(const string &value);         
+       void setFolderModifiedDate(const tm &value);
+       void setMediaIdList(const MediaIdListPtr &value);
+
+       void insertValue(string attr, string value);
+       string findValue(string attr);
+
+       void display() const;
+
+       protected:
+
+       string  m_folderUUID;
+       string  m_folderPath;   
+       string  m_folderName;
+       string  m_storageType;          
+       tm      m_modifiedDate;
+       MediaIdListPtr m_mediaIdArrayPtr;
+       EditableAttributeListPtr m_editableAttrPtr;
+       map<string,string> m_folderValue;
+
+};
+
+typedef DPL::SharedPtr<MediacontentFolder> MediacontentFolderPtr;
+typedef std::vector<MediacontentFolderPtr> MediacontentFolderList;
+typedef DPL::SharedPtr<MediacontentFolderList> MediacontentFolderListPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_FOLDER_H_ */
+
diff --git a/src/platform/API/Mediacontent/MediacontentImage.cpp b/src/platform/API/Mediacontent/MediacontentImage.cpp
new file mode 100644 (file)
index 0000000..7309b0b
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+* 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 "MediacontentImage.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+MediacontentImage::MediacontentImage()
+{
+}
+
+MediacontentImage::~MediacontentImage()
+{
+}
+
+double MediacontentImage::getImageLatitude() const
+{
+       return m_imageLatitude;
+}
+
+double MediacontentImage::getImageLongitude() const
+{
+       return m_imageLongitude;        
+
+}
+
+void MediacontentImage::setImageLatitude(const double  &value)
+{
+       m_imageLatitude = value;
+}
+void MediacontentImage::setImageLongitude(const double  &value)
+{
+       m_imageLongitude = value;
+}
+
+
+int MediacontentImage::getImageWidth() const
+{
+       return m_imageWidth;
+
+}
+
+void MediacontentImage::setImageWidth(const int &value)
+{
+       m_imageWidth = value;
+
+}
+
+int MediacontentImage::getImageHeight() const
+{
+       return m_imageHeight;
+}
+void MediacontentImage::setImageHeight(const int &value)
+{
+       m_imageHeight = value;
+
+}
+
+string MediacontentImage::getImageOrientation() const
+{
+       return m_imageOrientation;
+}
+
+void MediacontentImage::setImageOrientation(const string &value)
+{
+       m_imageOrientation = value;
+
+}
+
+
+void MediacontentImage::display()
+{
+       MediacontentMedia::display();
+       LogDebug("m_imageWidth : " << m_imageWidth);
+       LogDebug("m_imageHeight : " << m_imageHeight);
+       LogDebug("m_imageOrientation : " << m_imageOrientation);
+       LogDebug("m_imageLongitude : " << m_imageLongitude);
+       LogDebug("m_imageLatitude : " << m_imageLatitude);      
+
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentImage.h b/src/platform/API/Mediacontent/MediacontentImage.h
new file mode 100644 (file)
index 0000000..fc9d412
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+* 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_MEDIACONTENT_IMAGE_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_IMAGE_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentMedia.h"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class MediacontentImage : public MediacontentMedia
+{
+       public:
+
+       MediacontentImage();
+       virtual         ~MediacontentImage();
+
+       int getImageWidth() const;
+       int getImageHeight() const;
+       string getImageOrientation() const;
+       double getImageLatitude() const;
+       double getImageLongitude() const;
+
+
+       void setImageWidth(const int &value);   
+       void setImageHeight(const int &value);  
+       void setImageOrientation(const string &value);          
+       void setImageLatitude(const double &value);
+       void setImageLongitude(const double &value);    
+
+       void display();
+
+       protected:
+       int m_imageWidth;
+       int m_imageHeight;
+       string m_imageOrientation;              
+       double m_imageLongitude;
+       double m_imageLatitude; 
+
+};
+
+typedef DPL::SharedPtr<MediacontentImage> MediacontentImagePtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_MEDIA_H_ */
+
diff --git a/src/platform/API/Mediacontent/MediacontentLyrics.cpp b/src/platform/API/Mediacontent/MediacontentLyrics.cpp
new file mode 100644 (file)
index 0000000..843629e
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+* 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 "MediacontentLyrics.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+MediacontentLyrics::MediacontentLyrics()
+{
+}
+
+MediacontentLyrics::~MediacontentLyrics()
+{
+}
+
+
+string MediacontentLyrics::getMediaLyricsType() const
+{
+       return m_lyricsType;
+}
+
+void MediacontentLyrics::setMediaLyricsType(string value)
+{
+       m_lyricsType = value;
+}
+
+vector<unsigned long> MediacontentLyrics::getMediaLyricsTimeStamps() const
+{
+       return m_timeStamps;
+}
+
+void MediacontentLyrics::addMediaLyricsTimeStamp(unsigned long value)
+{
+       m_timeStamps.push_back(value);
+}
+
+vector<string> MediacontentLyrics::getMediaLyricsTexts() const
+{
+       return m_texts;
+}
+
+void MediacontentLyrics::addMediaLyricsText(string value)
+{
+       m_texts.push_back(value);
+}
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentLyrics.h b/src/platform/API/Mediacontent/MediacontentLyrics.h
new file mode 100644 (file)
index 0000000..4b55aad
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+* 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_MEDIACONTENT_LYRICS_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_LYRICS_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+class MediacontentLyrics
+{
+       
+       public:
+
+       MediacontentLyrics();
+       virtual ~MediacontentLyrics();
+
+       string getMediaLyricsType() const;
+       vector<string> getMediaLyricsTexts() const;
+       vector<unsigned long> getMediaLyricsTimeStamps() const; 
+       
+       void setMediaLyricsType(string value);
+       void addMediaLyricsText(string value);
+       void addMediaLyricsTimeStamp(unsigned long value);      
+       
+       private:
+       string m_lyricsType;
+       vector<unsigned long> m_timeStamps;
+       vector<string> m_texts;
+       
+};
+
+
+typedef DPL::SharedPtr<MediacontentLyrics> MediacontentLyricsPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_LYRICS_H_ */
+
diff --git a/src/platform/API/Mediacontent/MediacontentMedia.cpp b/src/platform/API/Mediacontent/MediacontentMedia.cpp
new file mode 100644 (file)
index 0000000..9635944
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+* 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 "MediacontentMedia.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+MediacontentMedia::MediacontentMedia()
+{
+       m_isChangedFavorite = false;
+}
+
+MediacontentMedia::~MediacontentMedia()
+{
+}
+
+string MediacontentMedia::getMediaUUID() const
+{
+       return m_mediaUUID;
+}
+
+void MediacontentMedia::setMediaUUID(const string &value)
+{
+       m_mediaUUID = value;
+}
+
+string MediacontentMedia::getMimeType() const
+{
+       return m_mimeType;
+}
+
+string MediacontentMedia::getDisplayName() const
+{
+    return m_displayName;
+}
+
+void MediacontentMedia::setMimeType(const string &value)
+{
+       m_mimeType = value;
+}
+
+
+void MediacontentMedia::setDisplayName(const string &value)
+{
+       m_displayName = value;
+}
+
+string MediacontentMedia::getFilePath() const
+{
+       return m_filePath;
+
+}
+
+void MediacontentMedia::setFilePath(const string &value)
+{
+       m_filePath = value;
+
+}
+
+string MediacontentMedia::getThumbnailPath() const
+{
+       return m_thumbnailPath;
+}
+
+
+tm MediacontentMedia::getCreatedDate() const
+{
+       return m_createdDate;
+}
+
+tm MediacontentMedia::getReleasedDate() const
+{
+       return m_releasedDate;
+}
+
+void MediacontentMedia::setThumbnailPath(const string &value)
+{
+       m_thumbnailPath = value;
+
+}
+tm MediacontentMedia::getModifiedDate() const
+{
+       return m_modifiedDate;
+}
+
+void MediacontentMedia::setCreatedDate(const tm &value)
+{
+       m_createdDate = value;
+
+}
+
+void MediacontentMedia::setReleasedDate(const tm &value)
+{
+       m_releasedDate = value;
+
+}
+
+void MediacontentMedia::setModifiedDate(const tm &value)
+{
+       m_modifiedDate = value;
+
+}
+int MediacontentMedia::getFavorite() const
+{
+       return m_favorite;
+}
+void MediacontentMedia::setFavorite(int value)
+{
+       m_favorite = value;
+       m_isChangedFavorite = true;
+
+}
+string MediacontentMedia::getMediaType() const
+{
+       return m_mediaType;
+}
+
+void MediacontentMedia::setMediaType(const string &value) 
+{
+       m_mediaType = value;
+}
+
+void MediacontentMedia::display() const
+{
+
+       LogDebug("m_mediaUUID : " << m_mediaUUID);
+       LogDebug("m_mediaType : " << m_mediaType);
+//     LogDebug("m_mimeType : " << m_mimeType);
+       LogDebug("m_displayName : " << m_displayName);
+       LogDebug("m_filePath : " << m_filePath);
+       LogDebug("m_thumbnailPath : " << m_thumbnailPath);
+       LogDebug("m_description : " << m_description);
+//     LogDebug("m_createdDate : " << m_createdDate);
+//     LogDebug("m_releasedDate : " << m_releasedDate);
+//     LogDebug("m_modifiedDate : " << m_modifiedDate);
+       LogDebug("m_favorite : " << m_favorite);
+       
+
+}
+string MediacontentMedia::getDescription() const
+{
+       return m_description;
+}
+
+void MediacontentMedia::setDescription(const string &value)
+{
+       m_description = value;
+}
+
+bool MediacontentMedia::getIsChangedFavorite() const
+{
+       return m_isChangedFavorite;
+}
+
+
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentMedia.h b/src/platform/API/Mediacontent/MediacontentMedia.h
new file mode 100644 (file)
index 0000000..ab502a5
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+* 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_MEDIACONTENT_MEDIA_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_MEDIA_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+
+using namespace std;
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+typedef enum 
+{
+       MEDIA_TYPE_IMAGE        = 1,
+       MEDIA_TYPE_VIDEO        = 2,
+       MEDIA_TYPE_AUDIO        = 3,
+       MEDIA_TYPE_UNKOWN       = 4,
+}media_type;
+
+
+class MediacontentMedia
+{
+       public:
+
+       MediacontentMedia();
+       virtual ~MediacontentMedia();
+
+       string getMediaUUID() const;
+       string getMediaType() const;
+       string getMimeType() const;
+       string getDisplayName() const;
+       string getFilePath() const;
+       string getThumbnailPath() const;
+       tm getCreatedDate() const;
+       tm getReleasedDate() const;
+       tm getModifiedDate() const;
+       string getDescription() const;  
+       int getFavorite() const;
+
+       bool getIsChangedFavorite() const;
+
+       void setMediaUUID(const string &value);
+       void setMediaType(const string &value);
+       void setMimeType(const string &value);
+       void setDisplayName(const string &value);       
+       void setFilePath(const string &value);  
+       void setThumbnailPath(const string &value);     
+       void setCreatedDate(const tm &value);
+       void setReleasedDate(const tm &value);
+       void setModifiedDate(const tm &value);  
+       void setFavorite( int value);
+       void setDescription(const string &value);
+
+       void display() const;
+
+       private:
+       string m_mediaUUID;
+       string m_mediaType;
+       string m_mimeType;
+       string m_displayName;
+       string m_filePath;
+       string m_thumbnailPath;
+       string m_description;
+       tm m_createdDate;
+       tm m_releasedDate;
+       tm m_modifiedDate;
+       int m_favorite;
+       bool m_isChangedFavorite;
+
+};
+
+
+typedef DPL::SharedPtr<MediacontentMedia> MediacontentMediaPtr;
+typedef std::vector<MediacontentMediaPtr> MediacontentMediaList;
+typedef DPL::SharedPtr<MediacontentMediaList> MediacontentMediaListPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_MEDIA_H_ */
+
diff --git a/src/platform/API/Mediacontent/MediacontentVideo.cpp b/src/platform/API/Mediacontent/MediacontentVideo.cpp
new file mode 100644 (file)
index 0000000..d352d96
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* 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 "MediacontentVideo.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+
+MediacontentVideo::MediacontentVideo()
+{
+       m_isChangedPlayCount = false;
+       m_isChangedPlayedTime = false;
+}
+
+MediacontentVideo::~MediacontentVideo()
+{
+}
+
+
+
+int MediacontentVideo::getVideoPlayedTime() const
+{
+       return m_videoPlayedTime;
+
+}
+
+int MediacontentVideo::getVideoPlayCount() const
+{
+       return m_videoPlayCount;
+
+}
+
+
+int MediacontentVideo::getVideoDuration() const
+{
+       return m_videoDuration;
+
+}
+
+int MediacontentVideo::getVideoWidth() const
+{
+       return m_videoWidth;
+
+}
+
+int MediacontentVideo::getVideoHeight() const
+{
+       return m_videoHeight;
+}
+
+double MediacontentVideo::getVideoLatitude() const
+{
+       return m_videoLatitude;
+}
+
+double MediacontentVideo::getVideoLongitude() const
+{
+       return m_videoLongitude;        
+
+}
+
+string MediacontentVideo::getVideoAlbum() const
+{
+    return m_videoAlbum;
+}
+
+string MediacontentVideo::getVideoArtist() const
+{
+    return m_videoArtist;
+}
+
+void MediacontentVideo::setVideoPlayedTime(const int &value)
+{
+       m_videoPlayedTime = value;
+       m_isChangedPlayedTime = true;
+}
+
+void MediacontentVideo::setVideoPlayCount(const int &value)
+{
+       m_videoPlayCount = value;
+       m_isChangedPlayCount = true;
+}
+
+void MediacontentVideo::setVideoDuration(const int &value)
+{
+       m_videoDuration = value;
+}
+
+void MediacontentVideo::setVideoWidth(const int &value)
+{
+       m_videoWidth = value;
+
+}
+
+void MediacontentVideo::setVideoHeight(const int &value)
+{
+       m_videoHeight = value;
+
+}
+
+void MediacontentVideo::setVideoLatitude(const double  &value)
+{
+       m_videoLatitude = value;
+}
+
+void MediacontentVideo::setVideoLongitude(const double  &value)
+{
+       m_videoLongitude = value;
+}
+
+
+void MediacontentVideo::setVideoAlbum(const string &value)
+{
+       m_videoAlbum = value;
+}
+
+void MediacontentVideo::setVideoArtist(const string &value)
+{
+       m_videoArtist = value;
+}
+
+
+void MediacontentVideo::display() const
+{
+
+       LogDebug("m_videoLongitude: " << m_videoLongitude;);
+    LogDebug("m_videoLatitude:  " << m_videoLatitude); 
+    LogDebug("m_videoAlbum: " << m_videoAlbum;);
+    LogDebug("m_videoArtist:    " << m_videoArtist);       
+
+    LogDebug("m_videoPlayedTime: " << m_videoPlayedTime);
+       LogDebug("m_videoDuration: " << m_videoDuration);
+       LogDebug("m_videoWidth: " << m_videoWidth);
+       LogDebug("m_videoHeight: " << m_videoHeight);   
+       MediacontentMedia::display();
+}
+
+}
+}
+}
diff --git a/src/platform/API/Mediacontent/MediacontentVideo.h b/src/platform/API/Mediacontent/MediacontentVideo.h
new file mode 100644 (file)
index 0000000..c1f46db
--- /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. 
+*/
+
+
+#ifndef _ABSTRACT_LAYER_MEDIACONTENT_VIDEO_H_
+#define _ABSTRACT_LAYER_MEDIACONTENT_VIDEO_H_
+
+#include <ctime>
+#include <string>
+#include <vector>
+#include <dpl/optional.h>
+#include <dpl/shared_ptr.h>
+#include "MediacontentMedia.h"
+
+using namespace std;
+
+
+namespace TizenApis {
+namespace Api {
+namespace Mediacontent {
+
+class MediacontentVideo : public MediacontentMedia
+{
+       public:
+
+       MediacontentVideo();
+       virtual ~MediacontentVideo();
+
+       int getVideoPlayedTime() const;
+       int getVideoPlayCount() const;
+       int getVideoDuration() const;
+       int getVideoWidth() const;
+       int getVideoHeight() const;
+       double getVideoLatitude() const;
+       double getVideoLongitude() const;
+       string getVideoAlbum() const;
+       string getVideoArtist() const;
+
+       void setVideoPlayedTime(const int &value);      
+       void setVideoPlayCount(const int &value);       
+       void setVideoDuration(const int &value);                
+       void setVideoWidth(const int &value);   
+       void setVideoHeight(const int &value);  
+       void setVideoLatitude(const double &value);
+       void setVideoLongitude(const double &value);    
+       void setVideoAlbum(const string &value);        
+       void setVideoArtist(const string &value);       
+
+       void display() const;   
+
+       private:
+       double  m_videoLongitude;
+       double m_videoLatitude; 
+       string m_videoAlbum;
+       string m_videoArtist;
+       int     m_videoPlayedTime;
+       int m_videoPlayCount;
+       int m_videoDuration;
+       int m_videoWidth;
+       int m_videoHeight;
+       bool m_isChangedPlayCount;
+       bool m_isChangedPlayedTime;
+};
+
+typedef DPL::SharedPtr<MediacontentVideo> MediacontentVideoPtr;
+
+
+}
+}
+}
+
+#endif /* _ABSTRACT_LAYER_MEDIACONTENT_VIDEO_H_ */
+
diff --git a/src/platform/API/Mediacontent/config.cmake b/src/platform/API/Mediacontent/config.cmake
new file mode 100644 (file)
index 0000000..0eaa91d
--- /dev/null
@@ -0,0 +1,13 @@
+get_current_path()
+set(SRCS_PLATFORM_API_MEDIACONTENT
+  ${CURRENT_PATH}/MediacontentFactory.cpp
+  ${CURRENT_PATH}/MediacontentMedia.cpp
+  ${CURRENT_PATH}/MediacontentFolder.cpp  
+  ${CURRENT_PATH}/MediacontentImage.cpp  
+  ${CURRENT_PATH}/MediacontentVideo.cpp    
+  ${CURRENT_PATH}/MediacontentAudio.cpp   
+  ${CURRENT_PATH}/IMediacontent.cpp
+  ${CURRENT_PATH}/IMediacontentManager.cpp
+  ${CURRENT_PATH}/MediacontentLyrics.cpp
+  PARENT_SCOPE
+)
index 7e77789..b1b43d9 100755 (executable)
 
 #include <dpl/log/log.h>
 #include <Commons/Exception.h>
-#include <Messaging/Attachment.h>
 #include "AttachmentFactory.h"
 #include "Attachments.h"
 #include <Messaging/Attachment.h>
+#include <Commons/WrtWrapper/WrtWrappersMgr.h>
+#include <WidgetDB/WidgetDBMgr.h>
 
 using namespace std;
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace TizenApis::Platform::Messaging;
 
+namespace {
+const char* PATH_DOWNLOADS = "/opt/media/Downloads";
+const char* PATH_DOCUMENTS = "/opt/media/Documents";
+const char* PATH_SOUNDS = "/opt/media/Music";
+const char* PATH_IMAGES = "/opt/media/Images";
+const char* PATH_VIDEOS = "/opt/media/Videos";
+
+const char* VPATH_DOWNLOADS = "download";
+const char* VPATH_DOCUMENTS = "documents";
+const char* VPATH_SOUNDS = "music";
+const char* VPATH_IMAGES = "images";
+const char* VPATH_VIDEOS = "videos";
+const char* VPATH_WGT_PACKAGE = "wgt-package";
+const char* VPATH_WGT_PRIVATE = "wgt-private";
+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";
+
+}
+
 namespace TizenApis {
 namespace Api {
 namespace Messaging {
 
+const char AttachmentFactory::m_pathSeparator = '/';
+
 IAttachmentPtr AttachmentFactory::createAttachment(const std::string& fullPath,
         bool isVirtualPath)
 {
@@ -48,6 +74,247 @@ IAttachmentPtr AttachmentFactory::createAttachment(const std::string& fullPath,
     }
     return attachment;
 }
+
+IAttachmentPtr AttachmentFactory::createAttachment(const std::string& path,
+        const std::string& mimeType)
+{
+    LogDebug("enter");
+
+    //check virtualPath
+    bool isVirtualPath = true;
+    IAttachmentPtr attachment(new Attachment(path, isVirtualPath));
+    if (!attachment->getIsCreatedProperly()) {
+        ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,
+                 "Attachment couldn't be created");
+    }
+
+    if ( attachment )
+       attachment->setMimeType(mimeType);
+               
+    return attachment;
+}
+
+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;
+       std::string tail;
+
+       std::string::size_type virtualrootpathposition;
+       //download
+       virtualrootpathposition = realpath.find(PATH_DOWNLOADS);
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(PATH_DOWNLOADS);
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_DOWNLOADS;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+
+               return virtualpath;
+       }
+
+       //document
+       virtualrootpathposition = realpath.find(PATH_DOCUMENTS);
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(PATH_DOCUMENTS);
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_DOCUMENTS;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+
+               return virtualpath;
+       }
+
+       //sound
+       virtualrootpathposition = realpath.find(PATH_SOUNDS);
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(PATH_SOUNDS);
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_SOUNDS;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+
+               return virtualpath;
+       }
+
+       //image
+       virtualrootpathposition = realpath.find(PATH_IMAGES);
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(PATH_IMAGES);
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_IMAGES;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+               LogDebug("virtualpath = " << virtualpath);
+               return virtualpath;
+       }
+
+       //video
+       virtualrootpathposition = realpath.find(PATH_VIDEOS);
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(PATH_VIDEOS);
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_VIDEOS;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+               LogDebug("virtualpath = " << virtualpath);
+               return virtualpath;
+       }
+
+       WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+
+       //wgt-package
+       virtualrootpathposition = realpath.find(widgetDB->getWidgetInstallationPath());
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(widgetDB->getWidgetInstallationPath());
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_WGT_PACKAGE;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+               LogDebug("virtualpath = " << virtualpath);
+               return virtualpath;
+       }       
+       
+       //wgt-private
+       virtualrootpathposition = realpath.find(widgetDB->getWidgetPersistentStoragePath());
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(widgetDB->getWidgetPersistentStoragePath());
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_WGT_PRIVATE;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+               LogDebug("virtualpath = " << virtualpath);
+               return virtualpath;
+       }
+
+       //wgt-package-tmp
+       virtualrootpathposition = realpath.find(widgetDB->getWidgetTemporaryStoragePath());
+       if (virtualrootpathposition != std::string::npos)
+       {
+               std::string vroot(widgetDB->getWidgetTemporaryStoragePath());
+               tail = realpath.substr(virtualrootpathposition + vroot.size() + 1, realpath.size() - 1);
+               LogDebug("tail = " << tail);
+               vroot=VPATH_WGT_PRIVATE_TEMP;
+               std::string virtualpath = vroot +  AttachmentFactory::m_pathSeparator + tail ;
+               LogDebug("virtualpath = " << virtualpath);
+               return virtualpath;
+       }       
+
+       //other file.
+       
+       //copy file
+       size_t pos = realpath.find_last_of("/");
+       if ((pos + 1) >= realpath.size()) {
+           LogError("Problem with short name creation");
+           Throw(InvalidArgumentException);
+       }
+       std::string attachShortName = realpath.substr(pos + 1);
+       std::string privat_dir = widgetDB->getWidgetPersistentStoragePath();
+       if ( privat_dir.empty())
+       {
+               LogError("Problem with short name creation");
+               Throw(InvalidArgumentException);
+       }       
+       
+     std::stringstream to_oss;
+               to_oss << "/email/" << attachShortName;
+               LogDebug("temp file=" << to_oss.str());
+       
+       std::stringstream cp_oss;
+       cp_oss << COMMAND_NAME;
+       cp_oss << " " << COMMAND_SWITCH_RECURSIVE;
+       cp_oss << " \"" << realpath << "\"";
+       cp_oss << " \"" << privat_dir << to_oss.str() << "\"";
+       
+       std::string vrootpath(VPATH_WGT_PRIVATE);
+       
+       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;
+       std::string::size_type separatorPosition = path.find(AttachmentFactory::m_pathSeparator);
+       if (separatorPosition != std::string::npos) {
+               root = path.substr(0, separatorPosition);
+               tail = path.substr(separatorPosition + 1, path.size() - 1);
+       } else {
+               root = path;
+       }
+       LogDebug("root = " << root);
+       LogDebug("tail = " << tail);
+       
+       WidgetDB::Api::IWidgetDBPtr widgetDB =
+        WidgetDB::Api::getWidgetDB(wrt->getWidgetId());
+
+       std::string realroot;
+
+       if ( root == VPATH_DOWNLOADS )
+       {
+               realroot = PATH_DOWNLOADS;
+       }
+       else if ( root == VPATH_DOCUMENTS )
+       {
+               realroot = PATH_DOCUMENTS;
+       }
+       else if ( root == VPATH_SOUNDS )
+       {
+               realroot = PATH_SOUNDS;
+       }
+       else if ( root == VPATH_IMAGES )
+       {
+               realroot = PATH_IMAGES;
+       }
+       else if ( root == VPATH_VIDEOS )
+       {
+               realroot = PATH_VIDEOS;
+       }
+       else if ( root == VPATH_WGT_PACKAGE )
+       {
+               realroot = widgetDB->getWidgetInstallationPath();
+       }
+       else if ( root == VPATH_WGT_PRIVATE )
+       {
+               realroot = widgetDB->getWidgetPersistentStoragePath();
+       }
+       else if ( root == VPATH_WGT_PRIVATE_TEMP )
+       {
+               realroot = widgetDB->getWidgetTemporaryStoragePath();
+       }
+       else
+       {       //exception
+               LogDebug("Can't find root path");
+               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException,
+                 "Attachment couldn't be created");
+       }
+
+       std::string ret = realroot + AttachmentFactory::m_pathSeparator + tail;
+                                       
+       return ret;
+}
+
+
+
 }
 }
 }
index ad047ae..a7693f8 100755 (executable)
@@ -25,6 +25,8 @@
 #define ATTACHMENTFACTORY_H
 
 #include <string>
+#include <JavaScriptCore/JavaScript.h>
+
 #include "IAttachment.h"
 
 namespace TizenApis {
@@ -44,7 +46,21 @@ class AttachmentFactory
      */
     static IAttachmentPtr createAttachment(const std::string& fullPath,
             bool isVirtualPath);
+
+    static IAttachmentPtr createAttachment(const std::string& path,
+            const std::string& mimeType = "");
+       
+    static std::string getRealPathFromVirtualPath(JSContextRef context, 
+               const std::string& path);
+
+    static std::string getVirtualPathFromRealPath(JSContextRef context, 
+               const std::string& realpath);
+
+private:       
+    static const char m_pathSeparator;
+
 };
+
 }
 }
 }
index bb20fe5..2c8ca88 100755 (executable)
@@ -33,8 +33,7 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               ConversationFilterValidator::ConversationFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag,Api::Tizen::PrimitiveType idType):FilterValidator(properties, matchFlag){
+               ConversationFilterValidator::ConversationFilterValidator(PropertyStructArray properties):FilterValidator(properties){
                        m_isTypeSetted = false;
                }
 
@@ -55,25 +54,25 @@ namespace TizenApis {
                        return retVal;
                }
 
-               bool ConversationFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool ConversationFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                                bool retBool = false;
 
                                AnyArray::iterator iter;
                                for(iter=values->begin(); iter!=values->end(); iter++){
                                        AnyPtr value = *iter;
-                                       if(validateAttributeEach(attrName, value, matchFlag, depth) == false){
+                                       if(validateAttributeEach(attrName, matchFlag, value, depth) == false){
                                                MsgLogWanning(">>>[Warning] attrName:[" << attrName << "] is invalid value:[" << value->toString() << "]");
                                                return false;
                                        }
                                }
 
-                               retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                               retBool = FilterValidator::validateAttribute(attrName, matchFlag, values,depth);
                                LogDebug(">>> retBool:" << retBool);
                                return retBool;
                }
 
-               bool ConversationFilterValidator::validateAttributeEach(std::string& attrName,Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               bool ConversationFilterValidator::validateAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
                        if(attrName.compare(ConversationFilterValidatorFactory::ATTRIBUTE_TYPE)==0){
index 7b962e5..8e84b3b 100755 (executable)
@@ -35,19 +35,18 @@ namespace TizenApis {
                                bool m_isTypeSetted;
 
                        public:
-                               ConversationFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                               Api::Tizen::MatchFlagStrArray matchFlag, Api::Tizen::PrimitiveType idType);
+                               ConversationFilterValidator(Api::Tizen::PropertyStructArray properties);
                                virtual ~ConversationFilterValidator();
 
                                // validate AttributeRangeFilter
                                virtual bool validateAttributeRange(std::string& attrName,
                                                                                        Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
-                               virtual bool validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                                               std::string& matchFlag, bool caseSensitive, int depth=0);
+                               virtual bool validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                                Api::Tizen::AnyArrayPtr& values, int depth=0);
 
                        protected:
-                               bool validateAttributeEach(std::string& attrName,Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                               bool validateAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
 
                };
 
index a6a2b23..45a203e 100755 (executable)
@@ -47,22 +47,13 @@ namespace TizenApis {
                                {ConversationFilterValidatorFactory::ATTRIBUTE_PREVIEW.c_str(),         Api::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_FROM.c_str(),            Api::Tizen::PrimitiveType_String},
                                {ConversationFilterValidatorFactory::ATTRIBUTE_TO.c_str(),              Api::Tizen::PrimitiveType_String},
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-//                     "MATCH_CASESENSITIVE",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                ConversationFilterValidatorPtr ConversationFilterValidatorFactory::getConversationFilterValidator()
                {
                    ConversationFilterValidatorPtr theInstance =
-                               ConversationFilterValidatorPtr(new ConversationFilterValidator(properties, matchFlag, Api::Tizen::PrimitiveType_Int));
+                               ConversationFilterValidatorPtr(new ConversationFilterValidator(properties));
 
                    return theInstance;
                }
index b7fc3e3..d1e1aab 100644 (file)
@@ -34,8 +34,7 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               FolderFilterValidator::FolderFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag, Api::Tizen::PrimitiveType idType):FilterValidator(properties, matchFlag){
+               FolderFilterValidator::FolderFilterValidator(PropertyStructArray properties):FilterValidator(properties){
                        m_isAccountIdSetted = false;
 
                        initMatchFlagVectors();
@@ -60,10 +59,36 @@ namespace TizenApis {
                        return retVal;
                }
 
-               bool FolderFilterValidator::vectorContains(std::vector<std::string>& vec, std::string& value){
+               bool FolderFilterValidator::vectorContains(std::vector<std::string>& vec, Api::Tizen::MatchFlag& value){
+                       std::string matchStr;
+                       switch(value)
+                       {
+                       case Api::Tizen::MATCH_EXACTLY:
+                               matchStr = "EXACTLY";
+                               break;
+                       case Api::Tizen::MATCH_FULLSTRING:
+                               matchStr = "FULLSTRING";
+                               break;
+                       case Api::Tizen::MATCH_CONTAINS:
+                               matchStr = "CONTAINS";
+                               break;
+                       case Api::Tizen::MATCH_STARTSWITH:
+                               matchStr = "STARTSWITH";
+                               break;
+                       case Api::Tizen::MATCH_ENDSWITH:
+                               matchStr = "ENDSWITH";
+                               break;
+                       case Api::Tizen::MATCH_EXISTS:
+                               matchStr = "EXISTS";
+                               break;
+                       default:
+                               matchStr = "";
+                               break;
+                       }
+
                        std::vector<std::string>::iterator it;
                        for(it=vec.begin(); it<vec.end(); it++){
-                               if((*it).compare(value) == 0){
+                               if((*it).compare(matchStr) == 0){
                                        return true;
                                }
                        }
@@ -71,26 +96,26 @@ namespace TizenApis {
                        return false;
                }
 
-               bool FolderFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool FolderFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                        bool retBool = false;
 
                        AnyArray::iterator iter;
                        for(iter=values->begin(); iter!=values->end(); iter++){
                                AnyPtr value = *iter;
-                               if(validateAttributeEach(attrName, value, matchFlag, depth) == false){
+                               if(validateAttributeEach(attrName, matchFlag, value, depth) == false){
                                        MsgLogWanning(">>>[Warning] attrName:[" << attrName << "] is invalid value:[" << value->toString() << "]");
                                        return false;
                                }
                        }
                        LogDebug("## 001 ##");
-                       retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                       retBool = FilterValidator::validateAttribute(attrName, matchFlag, values, depth);
                        LogDebug("## 002 ##");                  
                        LogDebug(">>> retBool:" << retBool);
                        return retBool;
                }
 
-               bool FolderFilterValidator::validateAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               bool FolderFilterValidator::validateAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
                        if(attrName.compare(FolderFilterValidatorFactory::ATTRIBUTE_ACCOUNTID)==0){
index 2a50dd2..47eba0d 100644 (file)
@@ -42,8 +42,7 @@ namespace TizenApis {
                                std::map<std::string, std::vector<std::string> > m_attributeAndMatchFlagsMap;
 
                        public:
-                       FolderFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                       Api::Tizen::MatchFlagStrArray matchFlag, Api::Tizen::PrimitiveType idType);
+                       FolderFilterValidator(Api::Tizen::PropertyStructArray properties);
 
                                virtual ~FolderFilterValidator();
 
@@ -52,16 +51,16 @@ namespace TizenApis {
                                                        Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
                                        virtual bool validateAttribute(std::string& attrName,
-                                                       Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth=0);
+                                                       Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth=0);
 
                                protected:
-                                               bool validateAttributeEach(std::string& attrName,Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                                               bool validateAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
 
                                private :
                                        void initMatchFlagVectors();
                                        void initAttributeAndMatchFlagsMap();
 
-                                       bool vectorContains(std::vector<std::string>& vec, std::string& value);
+                                       bool vectorContains(std::vector<std::string>& vec, Api::Tizen::MatchFlag& value);
 
                };
 
index c672310..254a7b9 100644 (file)
@@ -35,29 +35,18 @@ namespace TizenApis {
                 std::string FolderFilterValidatorFactory::MATCH_CONTAINS             = "CONTAINS";
                 std::string FolderFilterValidatorFactory::MATCH_STARTSWITH           = "STARTSWITH";
                 std::string FolderFilterValidatorFactory::MATCH_ENDSWITH             = "ENDSWITH";
-//              std::string FolderFilterValidatorFactory::MATCH_CASESENSITIVE        = "CASESENSITIVE";
-
                //TODO change to constant
                static PropertyStructArray properties =
                {
                                {"serviceId",        Api::Tizen::PrimitiveType_String},
                                {"path",             Api::Tizen::PrimitiveType_String},
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-//                     "MATCH_CASESENSITIVE",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                FolderFilterValidatorPtr FolderFilterValidatorFactory::getFolderFilterValidator()
                {
                    FolderFilterValidatorPtr theInstance =
-                               FolderFilterValidatorPtr(new FolderFilterValidator(properties, matchFlag, Api::Tizen::PrimitiveType_Int));
+                               FolderFilterValidatorPtr(new FolderFilterValidator(properties));
 
                    return theInstance;
                }
index 6df400b..a5d4cb0 100755 (executable)
@@ -43,7 +43,8 @@ namespace Api {
 namespace Messaging {
 
 IAttachment::IAttachment() :
-    m_validAttachment(false)
+    m_validAttachment(false),
+    m_attachmentID(-1)
 {
 }
 
@@ -64,6 +65,11 @@ void IAttachment::init(const string& fullPath,
         }
         LogDebug("real path " << l_fullPath);
 
+         if ( l_fullPath.size() > PATH_MAX + 1)
+         {
+               ThrowMsg(InvalidArgumentException, "Attachment file name is too long");
+         }
+       
         char buff[PATH_MAX + 1];
         if (NULL == realpath(l_fullPath.c_str(), buff)) {
             std::string errnoString = DPL::GetErrnoString();
index f89aa30..f58a076 100755 (executable)
@@ -34,6 +34,7 @@
 #include "CcRecipient.h"
 #include "BccRecipient.h"
 #include "Attachments.h"
+#include <API/Messaging/EmailAccountInfo.h>
 
 namespace TizenApis {
 namespace Api {
@@ -61,6 +62,16 @@ class IEmail : virtual public IMessage,
                return m_htmlBody;
     }
        
+    void setEmailAccount(const EmailAccountInfo& account)
+    {
+               m_EmailAccount = account;
+    }
+
+    EmailAccountInfo getEmailAccount()
+    {
+               return m_EmailAccount;
+    }
+       
     virtual int getAccountID() = 0;
     virtual int getUID() = 0;
     virtual int isBodyDownloaded() = 0;
@@ -70,12 +81,15 @@ class IEmail : virtual public IMessage,
 
     virtual int downloadAttachment(const Api::Messaging::IAttachmentPtr& attachment) = 0;
 
+    virtual bool hasAttachment() = 0;
+
 #if 0  
     virtual void sync(int account_id);  
     virtual void sync_folder(int account_id, int folder_id);
 #endif    
   private:
     std::string m_htmlBody;            //html body for Email.
+    EmailAccountInfo m_EmailAccount;   
 };
 
 typedef DPL::SharedPtr<IEmail> IEmailPtr;
index 377f0b3..d71d4af 100755 (executable)
@@ -39,6 +39,7 @@ namespace Messaging {
 
 enum MessageType
 {
+       UNKNOWN = 0,
        SMS = 1,
        MMS,
        EMAIL,
@@ -50,16 +51,19 @@ enum MessageType
 
 enum MessageStatus
 {
-       MESSAGE_STATUS_SENT = 1,
-       MESSAGE_STATUS_SENDING ,
-       MESSAGE_STATUS_FAILED,
+       MESSAGE_STATUS_CREATED = 0,
        MESSAGE_STATUS_DRAFT,
+       MESSAGE_STATUS_SENDING ,
+       MESSAGE_STATUS_SENT,
+       MESSAGE_STATUS_LOADED,
+       MESSAGE_STATUS_FAILED
 };
 
 //--------------------------------------------------------------------------
 
 enum FolderType
 {
+    TEMP_FOLDER =0,
     INBOX = 1,
     OUTBOX = 2,
     DRAFTBOX = 3,
index dbff801..12b829c 100755 (executable)
@@ -77,6 +77,8 @@ class IMms :
 
     IMms & operator <<(const VirtualMessage& msg);
 
+    virtual bool hasAttachment()=0;
+
   private:
     MMSType m_mmsType;
 };
index 921de11..0ec8e58 100755 (executable)
@@ -106,7 +106,7 @@ IMessagePtr MessageFactory::createMessage(const MessageType msgType,
        
 }
 
-IMessagePtr MessageFactory::createEmailMessage(const int mailId, const int accountId)
+IMessagePtr MessageFactory::createEmailMessage(const int accountId, const int mailId)
 {
        LogInfo("enter, Create Email Message with account ID");
        IEmail* email = NULL;
@@ -154,6 +154,19 @@ IMessagePtr MessageFactory::createEmailMessage(const int mailId, const int accou
 #endif
 }
 
+IMessagePtr MessageFactory::createEmailMessage()
+{
+       LogInfo("enter, Create Temporary Email Message without account");
+
+       IEmail* email = NULL;
+
+       email = new Email(Api::Messaging::TEMP_FOLDER); //create dumy email.
+
+       IMessagePtr imsg(email);
+       
+       return imsg;
+}
+
 IMessagePtr MessageFactory::createVirtualMessage()
 {
     return IMessagePtr(new VirtualMessage());
index 12a12fc..f5a8d4e 100755 (executable)
@@ -67,7 +67,9 @@ class MessageFactory
     static IMessagePtr createMessage(const MessageType msgType,
            Api::Messaging::EmailAccountInfo& account, const std::string& id = "" );
 
-    static IMessagePtr createEmailMessage ( const int id = 0, const int accountId = 0);
+    static IMessagePtr createEmailMessage ( const int accountId, const int id = 0 );
+
+    static IMessagePtr createEmailMessage();
 
     /**
      * Generate virtual message specyfied type, without platform projection
index ab1cc17..0d45373 100755 (executable)
@@ -34,8 +34,8 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               MessageFilterValidator::MessageFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag, Api::Tizen::PrimitiveType idType):FilterValidator(properties, matchFlag){
+               MessageFilterValidator::MessageFilterValidator(PropertyStructArray properties)
+                               :FilterValidator(properties){
                        m_isTypeSetted = false;
 
                        initMatchFlagVectors();
@@ -112,10 +112,36 @@ namespace TizenApis {
                }
 
 
-               bool MessageFilterValidator::vectorContains(std::vector<std::string>& vec, std::string& value){
+               bool MessageFilterValidator::vectorContains(std::vector<std::string>& vec, Api::Tizen::MatchFlag& value){
+                       std::string matchStr;
+                       switch(value)
+                       {
+                       case Api::Tizen::MATCH_EXACTLY:
+                               matchStr = "EXACTLY";
+                               break;
+                       case Api::Tizen::MATCH_FULLSTRING:
+                               matchStr = "FULLSTRING";
+                               break;
+                       case Api::Tizen::MATCH_CONTAINS:
+                               matchStr = "CONTAINS";
+                               break;
+                       case Api::Tizen::MATCH_STARTSWITH:
+                               matchStr = "STARTSWITH";
+                               break;
+                       case Api::Tizen::MATCH_ENDSWITH:
+                               matchStr = "ENDSWITH";
+                               break;
+                       case Api::Tizen::MATCH_EXISTS:
+                               matchStr = "EXISTS";
+                               break;
+                       default:
+                               matchStr = "";
+                               break;
+                       }
+
                        std::vector<std::string>::iterator it;
                        for(it=vec.begin(); it<vec.end(); it++){
-                               if((*it).compare(value) == 0){
+                               if((*it).compare(matchStr) == 0){
                                        return true;
                                }
                        }
@@ -123,25 +149,25 @@ namespace TizenApis {
                        return false;
                }
 
-               bool MessageFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool MessageFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                        bool retBool = false;
 
                        AnyArray::iterator iter;
                        for(iter=values->begin(); iter!=values->end(); iter++){
                                AnyPtr value = *iter;
-                               if(validateAttributeEach(attrName, value, matchFlag, depth) == false){
+                               if(validateAttributeEach(attrName, matchFlag, value, depth) == false){
                                        MsgLogWanning(">>>[Warning] attrName:[" << attrName << "] is invalid value:[" << value->toString() << "]");
                                        return false;
                                }
                        }
 
-                       retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                       retBool = FilterValidator::validateAttribute(attrName, matchFlag, values, depth);
                        LogDebug(">>> retBool:" << retBool);
                        return retBool;
                }
 
-               bool MessageFilterValidator::validateAttributeEach(std::string& attrName,Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               bool MessageFilterValidator::validateAttributeEach(std::string& attrName,MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
                        if(attrName.compare(MessageFilterValidatorFactory::ATTRIBUTE_TYPE)==0){
index f4a9150..7222500 100755 (executable)
@@ -52,8 +52,7 @@ namespace TizenApis {
                                std::map<std::string, std::vector<std::string> > m_attributeAndMatchFlagsMap;
 
                        public:
-                       MessageFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                       Api::Tizen::MatchFlagStrArray matchFlag, Api::Tizen::PrimitiveType idType);
+                       MessageFilterValidator(Api::Tizen::PropertyStructArray properties);
 
                                virtual ~MessageFilterValidator();
 
@@ -61,17 +60,17 @@ namespace TizenApis {
                                        virtual bool validateAttributeRange(std::string& attrName,
                                                        Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
-                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                                                       std::string& matchFlag, bool caseSensitive, int depth=0);
+                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                                       Api::Tizen::AnyArrayPtr& values, int depth=0);
 
                        protected:
-                                       bool validateAttributeEach(std::string& attrName,Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                                       bool validateAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
 
                                private :
                                        void initMatchFlagVectors();
                                        void initAttributeAndMatchFlagsMap();
 
-                                       bool vectorContains(std::vector<std::string>& vec, std::string& value);
+                                       bool vectorContains(std::vector<std::string>& vec, Api::Tizen::MatchFlag& value);
 
                };
 
index 2bec89e..762e8ba 100755 (executable)
@@ -60,21 +60,13 @@ namespace TizenApis {
                                {MessageFilterValidatorFactory::ATTRIBUTE_IS_READ.c_str(),   Api::Tizen::PrimitiveType_Boolean},
                                {MessageFilterValidatorFactory::ATTRIBUTE_PRIORITY.c_str(),  Api::Tizen::PrimitiveType_Boolean},
                                {MessageFilterValidatorFactory::ATTRIBUTE_SUBJECT.c_str(),   Api::Tizen::PrimitiveType_String},
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                MessageFilterValidatorPtr MessageFilterValidatorFactory::getMessageFilterValidator()
                {
                    MessageFilterValidatorPtr theInstance =
-                               MessageFilterValidatorPtr(new MessageFilterValidator(properties, matchFlag, Api::Tizen::PrimitiveType_Int));
+                               MessageFilterValidatorPtr(new MessageFilterValidator(properties));
 
                    return theInstance;
                }
diff --git a/src/platform/API/Messaging/MessageStorageFactory.cpp b/src/platform/API/Messaging/MessageStorageFactory.cpp
new file mode 100644 (file)
index 0000000..cb7e306
--- /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 "MessageStorageFactory.h"
+//#include <Messaging/MessagingServiceManager.h>
+#include <Messaging/JSMessagingListener.h>
+
+
+namespace TizenApis {
+namespace Api {
+namespace Messaging {
+
+using namespace TizenApis::Platform::Messaging;
+
+
+JSMessagingListenerPtr MessageStorageFactory::getMessagingListener(context) {
+       return JSMessagingListenerPtr( new JSMessagingListener::JSMessagingListener(context) );
+}
+
+MessageStorageFactory& MessageStorageFactory::getInstance() {
+       static MessageStorageFactory theInstance;
+       return theInstance;
+}
+
+MessageStorageFactory::MessageStorageFactory() {
+}
+
+MessageStorageFactory::~MessageStorageFactory(){
+}
+
+}
+}
+}
+
diff --git a/src/platform/API/Messaging/MessageStorageFactory.h b/src/platform/API/Messaging/MessageStorageFactory.h
new file mode 100644 (file)
index 0000000..0ef82c8
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+* 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_MESSAGING_STORAGE_FACTORY_H_
+#define WRTPLUGINS_API_MESSAGING_STORAGE_FACTORY_H_
+
+#include <dpl/noncopyable.h>
+//#include "IMessagingServiceManager.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Messaging {
+       
+class MessageStorageFactory : DPL::Noncopyable
+{
+public:
+       IMessagingServiceManagerPtr getMessagingListener();
+       static MessageStorageFactory& getInstance();
+
+protected:
+       MessageStorageFactory();
+       ~MessageStorageFactory();
+};
+
+
+}
+}
+}
+
+#endif //WRTPLUGINS_API_MESSAGING_FACTORY_H_
+
index 823fae6..521845a 100755 (executable)
 #include "ConversationFilterValidatorFactory.h"
 #include "FolderFilterValidatorFactory.h"
 
+//for email service
+#include <emf-types.h>
+#include <Emf_Mapi.h>
+
 
 using namespace std;
 using namespace TizenApis::Api::Tizen;
@@ -40,6 +44,7 @@ namespace TizenApis {
 namespace Api {
 namespace Messaging {
 
+
 ReqReceiverMessage::ReqReceiverMessage() :
     EventAddDraftMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),     
     EventSendMessageReqReceiver(ThreadEnum::MESSAGING_THREAD),
@@ -160,7 +165,38 @@ void ReqReceiverMessage::OnRequestReceived(const EventAddDraftMessagePtr& event)
         IMessagePtr msg = event->msg;
         if (!event->checkCancelled()) {
             event->setCancelAllowed(false);
-            msg->addMessageToDraft();
+               emf_account_t* accounts = NULL;
+               int count = 0;
+               if (msg->getMessageType() == Api::Messaging::EMAIL )
+               {       
+                       Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                       Try {
+                               
+                               
+                               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 );                                             
+                                               email->setEmailAccount(account);
+                                               
+                                               if (accounts != NULL) {
+                                                   email_free_account(&accounts, count);
+                                               }
+                                       }
+                               }               
+                       }
+                       Catch(WrtDeviceApis::Commons::PlatformException) {
+                               if (accounts != NULL) {
+                                       email_free_account(&accounts, count);
+                               }
+               }
+                                               
+                               
+               }
+
+                  msg->addMessageToDraft();
         } else {
             event->setCancelAllowed(true);
         }
@@ -185,6 +221,21 @@ void ReqReceiverMessage::OnRequestReceived(const EventSendMessagePtr& event)
                if (!event->checkCancelled()) {
                        event->setCancelAllowed(false);
                        event->switchToManualAnswer();
+                       if (msg->getMessageStatus() == Api::Messaging::MESSAGE_STATUS_CREATED ) //create message.
+                       {
+                               //add 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)
index 4e75c6c..ed0f18f 100755 (executable)
@@ -33,15 +33,16 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               StorageChangesConversationFilterValidator::StorageChangesConversationFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag,Api::Tizen::PrimitiveType idType):FilterValidator(properties, matchFlag){
+               StorageChangesConversationFilterValidator::StorageChangesConversationFilterValidator(PropertyStructArray properties)
+                               :FilterValidator(properties){
                        m_isTypeSetted = false;
                }
 
                StorageChangesConversationFilterValidator::~StorageChangesConversationFilterValidator(){
                }
 
-               bool StorageChangesConversationFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue){
+               bool StorageChangesConversationFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue,
+                               Api::Tizen::AnyPtr& endValue, int depth){
                        bool retVal = false;
                        if(attrName.compare(StorageChangesConversationFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)!=0){
                                LogError(">>> [ERROR] Not Supported attribute :[" << attrName << "]");
@@ -52,12 +53,12 @@ namespace TizenApis {
                        return retVal;
                }
 
-               bool StorageChangesConversationFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool StorageChangesConversationFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
 
                        bool retBool = false;
 
-                       retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                       retBool = FilterValidator::validateAttribute(attrName, matchFlag, values, depth);
                        LogDebug(">>> retBool:" << retBool);
                        return retBool;
                }
index 5448e34..846e70b 100755 (executable)
@@ -37,17 +37,16 @@ namespace TizenApis {
                                bool m_isTypeSetted;
 
                        public:
-                       StorageChangesConversationFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                       Api::Tizen::MatchFlagStrArray matchFlag,Api::Tizen::PrimitiveType idType);
+                       StorageChangesConversationFilterValidator(Api::Tizen::PropertyStructArray properties);
 
                                virtual ~StorageChangesConversationFilterValidator();
 
                                // validate AttributeRangeFilter
                                        virtual bool validateAttributeRange(std::string& attrName,
-                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue);
+                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
-                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                                                       std::string& matchFlag, bool caseSensitive, int depth=0);
+                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                                       Api::Tizen::AnyArrayPtr& values, int depth=0);
 
 
 
index 3f75d6a..ad835eb 100755 (executable)
@@ -55,21 +55,13 @@ namespace TizenApis {
                                {"bcc",              Api::Tizen::PrimitiveType_String},
                                {"subject",          Api::Tizen::PrimitiveType_String},
                                {"lastMessageId",        Api::Tizen::PrimitiveType_String},                             
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                StorageChangesConversationFilterValidatorPtr StorageChangesConversationFilterValidatorFactory::getStorageChangesConversationFilterValidator()
                {
                    static StorageChangesConversationFilterValidatorPtr theInstance =
-                               StorageChangesConversationFilterValidatorPtr(new StorageChangesConversationFilterValidator(properties, matchFlag, Api::Tizen::PrimitiveType_Int));
+                               StorageChangesConversationFilterValidatorPtr(new StorageChangesConversationFilterValidator(properties));
 
                    return theInstance;
                }
index 927cb5b..c30f8e7 100755 (executable)
@@ -38,12 +38,6 @@ namespace TizenApis {
                namespace Messaging {
 
 
-               const std::string StorageChangesConversationGenerator::STRING_MATCH_EXCACTLY        = "EXACTLY";
-               const std::string StorageChangesConversationGenerator::STRING_MATCH_CONTAINS        = "CONTAINS";
-               const std::string StorageChangesConversationGenerator::STRING_MATCH_STARTSWITH      = "STARTSWITH";
-               const std::string StorageChangesConversationGenerator::STRING_MATCH_ENDSWITH        = "ENDSWITH";
-//             const std::string StorageChangesConversationGenerator::STRING_MATCH_CASESENSITIVE   = "CASESENSITIVE";
-
                const int StorageChangesConversationGenerator::MESSAGE_TYPE_NOT_INITIALIZED = -1;
 
                StorageChangesConversationGenerator::StorageChangesConversationGenerator(Api::Messaging::IConversationPtr conv):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
@@ -255,17 +249,17 @@ namespace TizenApis {
                        }
 
                void StorageChangesConversationGenerator::visitAttribute(std::string& attrName,
-                                               AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
+                                                MatchFlag& matchFlag, AnyArrayPtr& values, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
                        LogDebug("values->size():" << values->size());
 
                        Api::Tizen::FilterType filterType = UNION_FILTER;
 
-                       if(matchFlag.compare("EXIST")==0){
+                       if(matchFlag==Api::Tizen::MATCH_EXISTS){
                                //TODO implement for EXIST
                        }else if(values->size() == 1){
                                AnyPtr matchValue = values->at(0);
-                               visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                               visitAttributeEach(attrName, matchFlag, matchValue, depth);
                        }else{
                                visitPreComposite(filterType, depth);
                        
@@ -278,7 +272,7 @@ namespace TizenApis {
                                        }
                        
                                        AnyPtr matchValue = *iter;
-                                       visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                                       visitAttributeEach(attrName, matchFlag, matchValue, depth);
                                }
                        
                                visitPostComposite(filterType, depth);
@@ -286,7 +280,7 @@ namespace TizenApis {
                        LogDebug(">>>");
                }
 
-               void StorageChangesConversationGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               void StorageChangesConversationGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
                        std::string valueString;
 
@@ -479,11 +473,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("tizen.sms") ==0){
+                       if(stringType.compare("messaging.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("tizen.mms") ==0){
+                       }else if(stringType.compare("messaging.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("tizen.email") ==0){
+                       }else if(stringType.compare("messaging.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
@@ -540,20 +534,20 @@ namespace TizenApis {
                        }
                        }
                        
-               bool StorageChangesConversationGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag)
+               bool StorageChangesConversationGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag)
                {
                        std::vector<std::string>::iterator iter;
                        bool result = FALSE;
-                       if(matchFlag.compare(STRING_MATCH_EXCACTLY) == 0){
+                       if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXCACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
-                       }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_STARTSWITH){
                                LogDebug("STRING_MATCH_STARTSWITH");
                                result = result || getMatchStartwithClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
                        }else{
index 09ac05d..aa88075 100755 (executable)
@@ -54,11 +54,11 @@ namespace TizenApis {
                                void visitInComposite(Api::Tizen::FilterType& type, int depth);
                                void visitPostComposite(Api::Tizen::FilterType& type, int depth);
                                void visitAttribute(std::string& attrName,
-                                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
+                                               Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth);
 
                                void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
 
-                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag);
+                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag);
                                bool getCompareResult();                                                        
 
                        private:
@@ -68,7 +68,7 @@ namespace TizenApis {
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
                                bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
 
-                               void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                               void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
                                int convertMessageType(std::string& stringType);
                                std::string convertBooleanStringToIntegerString(std::string& booleanString);
 
@@ -104,12 +104,6 @@ namespace TizenApis {
                                Api::Messaging::RecipientsPtr Recipents;
                                std::string m_currentType;
 
-                               static const std::string STRING_MATCH_EXCACTLY;
-                               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 7982fe6..f1b4adf 100755 (executable)
@@ -33,26 +33,25 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               StorageChangesFolderFilterValidator::StorageChangesFolderFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag,Api::Tizen::PrimitiveType idType):FilterValidator(properties, matchFlag){
+               StorageChangesFolderFilterValidator::StorageChangesFolderFilterValidator(PropertyStructArray properties):FilterValidator(properties){
                        m_isTypeSetted = false;
                }
 
                StorageChangesFolderFilterValidator::~StorageChangesFolderFilterValidator(){
                }
 
-               bool StorageChangesFolderFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue){
+               bool StorageChangesFolderFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth){
                        bool retVal = false;
                                LogError(">>> [ERROR] Not Supported attribute :[" << attrName << "]");
                        return retVal;
                }
 
-               bool StorageChangesFolderFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool StorageChangesFolderFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
 
                        bool retBool = false;
 
-                       retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                       retBool = FilterValidator::validateAttribute(attrName, matchFlag, values, depth);
                        LogDebug(">>> retBool:" << retBool);
                        return retBool;
 
index 25f83f6..bfb2b00 100755 (executable)
@@ -37,17 +37,16 @@ namespace TizenApis {
                                bool m_isTypeSetted;
 
                        public:
-                       StorageChangesFolderFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                       Api::Tizen::MatchFlagStrArray matchFlag,Api::Tizen::PrimitiveType idType);
+                       StorageChangesFolderFilterValidator(Api::Tizen::PropertyStructArray properties);
 
                                virtual ~StorageChangesFolderFilterValidator();
 
                                // validate AttributeRangeFilter
                                        virtual bool validateAttributeRange(std::string& attrName,
-                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue);
+                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
-                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                                                               std::string& matchFlag, bool caseSensitive, int depth=0);
+                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                                               Api::Tizen::AnyArrayPtr& values, int depth=0);
 
 
 
index 803efb0..6eaf229 100755 (executable)
@@ -47,21 +47,13 @@ namespace TizenApis {
                                {"path",           Api::Tizen::PrimitiveType_String},
                                {"type",           Api::Tizen::PrimitiveType_String},
                                {"synchronizable", Api::Tizen::PrimitiveType_Number},
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                StorageChangesFolderFilterValidatorPtr StorageChangesFolderFilterValidatorFactory::getStorageChangesFolderFilterValidator()
                {
                    static StorageChangesFolderFilterValidatorPtr theInstance =
-                               StorageChangesFolderFilterValidatorPtr(new StorageChangesFolderFilterValidator(properties, matchFlag, Api::Tizen::PrimitiveType_Int));
+                               StorageChangesFolderFilterValidatorPtr(new StorageChangesFolderFilterValidator(properties));
 
                    return theInstance;
                }
index 8e89d62..d3e5c57 100755 (executable)
@@ -210,17 +210,17 @@ namespace TizenApis {
                        }
 
                void StorageChangesFolderGenerator::visitAttribute(std::string& attrName,
-                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
+                               Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
                        LogDebug("values->size():" << values->size());
 
                        Api::Tizen::FilterType filterType = UNION_FILTER;
 
-                       if(matchFlag.compare("EXIST")==0){
+                       if(matchFlag == Api::Tizen::MATCH_EXISTS){
                                //TODO implement for EXIST
                        }else if(values->size() == 1){
                                AnyPtr matchValue = values->at(0);
-                               visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                               visitAttributeEach(attrName, matchFlag, matchValue, depth);
                        }else{
                                visitPreComposite(filterType, depth);
                        
@@ -233,7 +233,7 @@ namespace TizenApis {
                                        }
                        
                                        AnyPtr matchValue = *iter;
-                                       visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                                       visitAttributeEach(attrName, matchFlag, matchValue, depth);
                                }
                        
                                visitPostComposite(filterType, depth);
@@ -241,7 +241,7 @@ namespace TizenApis {
                        LogDebug(">>>");
                }
 
-               void StorageChangesFolderGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               void StorageChangesFolderGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
                        std::string valueString;
 
@@ -355,11 +355,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("tizen.sms") ==0){
+                       if(stringType.compare("messaging.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("tizen.mms") ==0){
+                       }else if(stringType.compare("messaging.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("tizen.email") ==0){
+                       }else if(stringType.compare("messaging.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
@@ -399,20 +399,20 @@ namespace TizenApis {
                        m_result.push_back(FALSE);                                              
                }
 
-               bool StorageChangesFolderGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag)
+               bool StorageChangesFolderGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag)
                {
                        std::vector<std::string>::iterator iter;
                        bool result = FALSE;
-                       if(matchFlag.compare(STRING_MATCH_EXCACTLY) == 0){
+                       if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXCACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
-                       }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_STARTSWITH){
                                LogDebug("STRING_MATCH_STARTSWITH");
                                result = result || getMatchStartwithClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
                        }else{
index b7a30c9..cc2595c 100755 (executable)
@@ -54,10 +54,10 @@ namespace TizenApis {
                                void visitPreComposite(Api::Tizen::FilterType& type, int depth);
                                void visitInComposite(Api::Tizen::FilterType& type, int depth);
                                void visitPostComposite(Api::Tizen::FilterType& type, int depth);
-                               void visitAttribute(std::string& attrName,
-                                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
+                               void visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                               Api::Tizen::AnyArrayPtr& values, int depth);
                                void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
-                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag);
+                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag);
                                bool getCompareResult();                                                        
 
                        private:
@@ -66,7 +66,7 @@ namespace TizenApis {
                                bool getMatchStartwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
 
-                               void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                               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);                         
 
index e80c406..574e3b7 100755 (executable)
@@ -33,15 +33,14 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               StorageChangesMessageFilterValidator::StorageChangesMessageFilterValidator(PropertyStructArray properties,
-                               MatchFlagStrArray matchFlag):FilterValidator(properties, matchFlag){
+               StorageChangesMessageFilterValidator::StorageChangesMessageFilterValidator(PropertyStructArray properties):FilterValidator(properties){
                        m_isTypeSetted = false;
                }
 
                StorageChangesMessageFilterValidator::~StorageChangesMessageFilterValidator(){
                }
 
-               bool StorageChangesMessageFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue){
+               bool StorageChangesMessageFilterValidator::validateAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth){
                        bool retVal = false;
                        if(attrName.compare(StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_TIMESTAMP)!=0){
                                LogError(">>> [ERROR] Not Supported attribute :[" << attrName << "]");
@@ -53,11 +52,11 @@ namespace TizenApis {
                }
 
                //TODO Implement
-               bool StorageChangesMessageFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                               std::string& matchFlag, bool caseSensitive, int depth){
+               bool StorageChangesMessageFilterValidator::validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                        bool retBool = false;
                        
-                       retBool = FilterValidator::validateAttribute(attrName, values, matchFlag, caseSensitive, depth);
+                       retBool = FilterValidator::validateAttribute(attrName, matchFlag, values, depth);
                        LogDebug(">>> retBool:" << retBool);
                        return retBool;
                }
index 1683625..fb41d23 100755 (executable)
@@ -37,17 +37,16 @@ namespace TizenApis {
                                bool m_isTypeSetted;
 
                        public:
-                       StorageChangesMessageFilterValidator(Api::Tizen::PropertyStructArray properties,
-                                       Api::Tizen::MatchFlagStrArray matchFlag);
+                       StorageChangesMessageFilterValidator(Api::Tizen::PropertyStructArray properties);
 
                                virtual ~StorageChangesMessageFilterValidator();
 
                                // validate AttributeRangeFilter
                                        virtual bool validateAttributeRange(std::string& attrName,
-                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue);
+                                                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth=0);
 
-                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values,
-                                                               std::string& matchFlag, bool caseSensitive, int depth=0);
+                                       virtual bool validateAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                                               Api::Tizen::AnyArrayPtr& values, int depth=0);
 
 
 
index 2bae4a8..9478bd1 100755 (executable)
@@ -54,21 +54,13 @@ namespace TizenApis {
                                {"isRead",           Api::Tizen::PrimitiveType_Number},
                                {StorageChangesMessageFilterValidatorFactory::ATTRIBUTE_PRIORITY.c_str(),  Api::Tizen::PrimitiveType_Number},
                                {"subject",          Api::Tizen::PrimitiveType_String},
-                               {0,                  Api::Tizen::PrimitiveType_Notype}
-               };
-
-               static MatchFlagStrArray matchFlag{
-                       "EXACTLY",
-                       "CONTAINS",
-                       "STARTSWITH",
-                       "ENDSWITH",
-                       0
+                               {0,                  Api::Tizen::PrimitiveType_NoType}
                };
 
                StorageChangesMessageFilterValidatorPtr StorageChangesMessageFilterValidatorFactory::getStorageChangesMessageFilterValidator()
                {
                    static StorageChangesMessageFilterValidatorPtr theInstance =
-                               StorageChangesMessageFilterValidatorPtr(new StorageChangesMessageFilterValidator(properties, matchFlag));
+                               StorageChangesMessageFilterValidatorPtr(new StorageChangesMessageFilterValidator(properties));
 
                    return theInstance;
                }
index d99d325..37bd722 100755 (executable)
@@ -37,12 +37,6 @@ namespace TizenApis {
        namespace Platform {
                namespace Messaging {
 
-               const std::string StorageChangesMessageGenerator::STRING_MATCH_EXCACTLY        = "EXACTLY";
-               const std::string StorageChangesMessageGenerator::STRING_MATCH_CONTAINS        = "CONTAINS";
-               const std::string StorageChangesMessageGenerator::STRING_MATCH_STARTSWITH      = "STARTSWITH";
-               const std::string StorageChangesMessageGenerator::STRING_MATCH_ENDSWITH        = "ENDSWITH";
-//             const std::string StorageChangesMessageGenerator::STRING_MATCH_CASESENSITIVE   = "CASESENSITIVE";
-
                const int StorageChangesMessageGenerator::MESSAGE_TYPE_NOT_INITIALIZED = -1;
 
                StorageChangesMessageGenerator::StorageChangesMessageGenerator(Api::Messaging::IMessagePtr msg):m_messageType(MESSAGE_TYPE_NOT_INITIALIZED) {
@@ -350,17 +344,17 @@ namespace TizenApis {
                }
 
                void StorageChangesMessageGenerator::visitAttribute(std::string& attrName,
-                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
+                               MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
                        LogDebug("values->size():" << values->size());
 
                        Api::Tizen::FilterType filterType = UNION_FILTER;
 
-                       if(matchFlag.compare("EXIST")==0){
+                       if(matchFlag == Api::Tizen::MATCH_EXISTS){
                                //TODO implement for EXIST
                        }else if(values->size() == 1){
                                AnyPtr matchValue = values->at(0);
-                               visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                               visitAttributeEach(attrName, matchFlag, matchValue, depth);
                        }else{
                                visitPreComposite(filterType, depth);
                        
@@ -373,7 +367,7 @@ namespace TizenApis {
                                        }
                        
                                        AnyPtr matchValue = *iter;
-                                       visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                                       visitAttributeEach(attrName, matchFlag, matchValue, depth);
                                }
                        
                                visitPostComposite(filterType, depth);
@@ -381,7 +375,7 @@ namespace TizenApis {
                        LogDebug(">>>");
                }
                
-               void StorageChangesMessageGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               void StorageChangesMessageGenerator::visitAttributeEach(std::string& attrName, MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
                        std::string valueString;
 
@@ -576,11 +570,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("tizen.sms") ==0){
+                       if(stringType.compare("messaging.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("tizen.mms") ==0){
+                       }else if(stringType.compare("messaging.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("tizen.email") ==0){
+                       }else if(stringType.compare("messaging.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                LogError("invalid type:[" << stringType << "]");
@@ -633,20 +627,20 @@ namespace TizenApis {
                        }
                }
 
-               bool StorageChangesMessageGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag)
+               bool StorageChangesMessageGenerator::getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, MatchFlag& matchFlag)
                {
                                std::vector<std::string>::iterator iter;
                        bool result = FALSE;
-                       if(matchFlag.compare(STRING_MATCH_EXCACTLY) == 0){
+                       if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXCACTLY");
                                result = result || getMatchExactlyClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                result = result || getMatchContainsClause(valueString, value);                                          
-                       }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_STARTSWITH){
                                LogDebug("STRING_MATCH_STARTSWITH");
                                result = result || getMatchStartwithClause(valueString, value);
-                       }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                result = result || getMatchEndwithClause(valueString, value);                           
                        }else{
index 4c50242..78987d0 100755 (executable)
@@ -54,9 +54,9 @@ namespace TizenApis {
                                void visitInComposite(Api::Tizen::FilterType& type, int depth);
                                void visitPostComposite(Api::Tizen::FilterType& type, int depth);
                                void visitAttribute(std::string& attrName,
-                                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
+                                               Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth);
                                void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
-                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, std::string& matchFlag);
+                               bool getMatchFlagResult(Api::Tizen::AnyPtr& value, std::string& valueString, Api::Tizen::MatchFlag& matchFlag);
                                bool getCompareResult();                                                        
                                int getMessageType(){
                                        return m_messageType;
@@ -70,7 +70,7 @@ namespace TizenApis {
                                bool getMatchEndwithClause(std::string& attrName, Api::Tizen::AnyPtr& value);                           
                                bool getBetweenRangeClause(struct tm initialValue, struct tm endValue);                         
 
-                               void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                               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);                         
 
@@ -107,12 +107,6 @@ namespace TizenApis {
                                Api::Messaging::RecipientsPtr Recipents;
                                std::string m_currentType;
 
-                               static const std::string STRING_MATCH_EXCACTLY;
-                               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 71f90e3..ba89efc 100755 (executable)
@@ -34,13 +34,14 @@ class INdefMessage
                                       INdefMessage() {}
         virtual                     ~INdefMessage() {}
        virtual void *getHandle() = 0;
-       virtual long getRecordCount() = 0;
+       virtual void *getRecordHandle(const long index) = 0;
        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 removeNDEFRecord(const long index) = 0;
-
+       virtual void changeAllRecords(const std::vector<void *> ndefRcords) = 0;
 };
 
 typedef DPL::SharedPtr<INdefMessage> INdefMessagePtr;
index ee02f01..d803478 100755 (executable)
@@ -35,6 +35,9 @@ class INdefRecord
        virtual                     ~INdefRecord() {}
        virtual void *getHandle() = 0;
        virtual NdefRecordProperties getNDEFRecordProperties() = 0;
+       virtual nfcTNF getTNF() = 0;
+       virtual std::vector<unsigned char> getTypeName() = 0;
+       virtual std::vector<unsigned char> getID() = 0;
        virtual std::vector<unsigned char> getPayload() = 0;
        virtual bool getText(char **text) = 0;
        virtual bool getLangCode(char **landCode) = 0;
index a705d3c..c189c76 100755 (executable)
@@ -49,6 +49,10 @@ INdefMessagePtr NFCFactory::createNDEFMessageObject(std::vector<unsigned char> r
        return INdefMessagePtr( new Platform::NFC::NdefMessage(rawdata) );
 }
 
+INdefRecordPtr NFCFactory::createNDEFRecordObject() {
+       return INdefRecordPtr( new Platform::NFC::NdefRecord() );
+}
+
 INdefRecordPtr NFCFactory::createNDEFRecordObject(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload) {
        return INdefRecordPtr( new Platform::NFC::NdefRecord(ndefRecordProperties, payload) );
 }
index 6eed2b0..eaac901 100755 (executable)
@@ -44,6 +44,7 @@ public:
        INdefMessagePtr createNDEFMessageObject(void *messageHandle);
        INdefMessagePtr createNDEFMessageObject(std::vector<void *> ndefRcords);
        INdefMessagePtr createNDEFMessageObject(std::vector<unsigned char> rawdata);
+       INdefRecordPtr createNDEFRecordObject();
        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);
index fe5bccb..ce1a8de 100755 (executable)
@@ -11,6 +11,7 @@ include_config_file(Systeminfo)
 include_config_file(NFC)
 include_config_file(Filesystem)
 include_config_file(Account)
+include_config_file(Mediacontent)
 
 #include_config_file(Accelerometer)
 #include_config_file(Orientation)
index a649bcd..83fd03b 100755 (executable)
@@ -28,6 +28,7 @@
 #include <dpl/scoped_ptr.h>
 
 #include "AccountManager.h"
+#include "AccountWrapper.h"
 
 #include "API/Account/OnAddEventsChanged.h"
 #include "API/Account/OnUpdateEventsChanged.h"
@@ -84,36 +85,36 @@ AccountManager::~AccountManager()
     }
 }
 
-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 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)
@@ -193,57 +194,44 @@ void AccountManager::OnRequestReceived(const IEventAddAccountPtr &account)
 
 void AccountManager::OnRequestReceived(const IEventFindAccountsPtr &event)
 {
-    LogDebug("entered");
-    const AccountFilterPtr &filter = event->getFilter();
-
-       count = 0;
-       memset(id_list, 0x00, 1024);
-    if (NULL != filter)
-       {
-        if(filter->getIdIsSet()) {
-            std::istringstream istream(filter->getIdFilter());
-            int id;
-            istream>>id;
-                       LogDebug("id : " << id);
-        }
-       }
+       LogDebug("<<<");
+       Try{
+               DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
+               if (event->checkCancelled()) {
+                       event->setCancelAllowed(true);
+                       event->setResult(true);
+                       return;
+               }
 
-    try {
-/*
-               UserAccount_t* account_list = NULL;
-               int find_accounts(&search_list, &account_list, status_e status, &total_count);
-               for(i = 0; i < total_count; i++)
-               {
-                       event->tryCancelled();
-                       DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-                       accountWrapper->loadAccount(id_list[i]);
-                       event->addEvent(accountWrapper->getAbstractAccount());
-               }
-*/
-               int error = account_foreach_account_from_db(GetAccountList, NULL);
-               if ((ACCOUNT_ERROR_NONE == error) || (ACCOUNT_ERROR_RECORD_NOT_FOUND == error))
-               {
-               }else
-               {
-                       ThrowMsg(PlatformException, "Can't get all records");
+               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;
        }
 
-               int i = 0;
-               for(i = 0; i < count; i++)
-               {
-                       event->tryCancelled();
-                       DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper());
-                       accountWrapper->loadAccount(id_list[i]);
-                       event->addEvent(accountWrapper->getAbstractAccount());
-               }
+               AccountServicesArrayPtr serviceListPtr = accountWrapper->findServiceByFilter(event->getFilterProperty());
+               event->setAccountServiceList(serviceListPtr);
                event->setResult(true);
-    }
-    catch (const Exception &ex)
-    {
-        LogError("Exception: " << ex.DumpToString());
+       } catch (const Exception &ex) {
+               LogError("Error during adding event" << ex.DumpToString());
         event->setResult(false);
     }
-    event->setCancelAllowed(true);
+       event->setCancelAllowed(false);
+       LogDebug(">>>");
 }
 
 
@@ -311,26 +299,23 @@ void AccountManager:: OnRequestReceived(const IEventGetServiceTypeByIdPtr &event
 
        Try{
                if (!eventGetServicetypeById->getEvent()) {
-                       ThrowMsg(NullPointerException, "event parameter is NULL");
-               }
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
 
                DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(eventGetServicetypeById->getEvent()));
-               accountWrapper->getServiceTypebyId();
                if (eventGetServicetypeById->checkCancelled()) {
                        eventGetServicetypeById->setCancelAllowed(true);
                        eventGetServicetypeById->setResult(true);
-                       return;
-               }
+            return;
+        }
                eventGetServicetypeById->setEvent(accountWrapper->getAbstractAccount());
-
-               //TODO set real value sangtai.kim
-               eventGetServicetypeById->setAccountServiceTypeProperty(accountWrapper->getDummyAccountServiceType());
+               eventGetServicetypeById->setAccountServiceTypeProperty(accountWrapper->getAccountServiceTypebyId());
 
                eventGetServicetypeById->setResult(true);
        } catch (const Exception &ex) {
-               LogError("Error during updating event " << ex.DumpToString());
+        LogError("Error during updating event " << ex.DumpToString());
                eventGetServicetypeById->setResult(false);
-       }
+    }
        eventGetServicetypeById->setCancelAllowed(false);
 }
 
@@ -339,77 +324,101 @@ void AccountManager:: OnRequestReceived(const IEventGetProviderByIdPtr &event)
        LogDebug("<<<");
        Try{
                if (!event->getEvent()) {
-                       ThrowMsg(NullPointerException, "event parameter is NULL");
-               }
+            ThrowMsg(NullPointerException, "event parameter is NULL");
+        }
                DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(event->getEvent()));
                if (event->checkCancelled()) {
                        event->setCancelAllowed(true);
                        event->setResult(true);
-                       return;
-               }
-
-               //TODO set real value sangtai.kim
-               event->setAccountServiceProviderProperty(accountWrapper->getDummyAccountServiceProviderProperty());
+            return;
+        }
 
+               event->setAccountServiceProviderProperty(accountWrapper->getAccountServiceProviderProperty());
                event->setResult(true);
        }catch (const Exception &ex)    {
-               LogError("Error during updating event " << ex.DumpToString());
+        LogError("Error during updating event " << ex.DumpToString());
                event->setResult(false);
-       }
+    }
        event->setCancelAllowed(false);
        LogDebug(">>>");
 }
 
-void AccountManager:: OnRequestReceived(const IEventFindProvidersPtr &account)
+void AccountManager:: OnRequestReceived(const IEventFindProvidersPtr &eventFindProvidersPtr)
 {
-    LogDebug("entered");
-    Try
-    {
-        if (!account->getEvent()) {
-            ThrowMsg(NullPointerException, "event parameter is NULL");
-        }
-        DPL::ScopedPtr<AccountWrapper> accountWrapper(new AccountWrapper(account->getEvent()));
-        accountWrapper->findProviders();
-        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);
+       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) {
+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 prefix = event->getPrefix();
-       LogDebug("prefix:[" << prefix << "]");
+       std::string serviceName = event->getServiceName();
+       LogDebug("serviceName:[" << serviceName << "]");
 
-       //set dummy AccountService Type
-       AccountServiceTypePropertyArrayPtr accountServiceTypeProperties(new AccountServiceTypePropertyArray());
-       AccountServiceTypePropertyPtr property(new AccountServiceTypeProperty);
-       property->setId("dummyId1");
-       property->setDisplayName("dummyDisplayName1");
-       property->setIconPath("dummyIcon1");
-       std::vector<std::string> tmpVector;
-       tmpVector.push_back("dummyTag1");
-       tmpVector.push_back("dummyTag2");
-       property->setTags(tmpVector);
-       accountServiceTypeProperties->push_back(property);
+       //dummy implementation
+       AccountServicesPtr dummyServices1(new AccountServices());
+       dummyServices1->setProviderId("dummyProviderId");
+       dummyServices1->setServiceTypeId("dummyServiceTypeId");
+       dummyServices1->setDisplayName("dummyDisplayName");
+       dummyServices1->setName("dummyName");
+       dummyServices1->setId("dummyServiceId");
 
-       event->setServiceTypeProperties(accountServiceTypeProperties);
+       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(">>>");
+}
 
 }
 }
index 2be836e..00928a2 100755 (executable)
 #include <vector>
 #include <list>
 #include <dpl/mutex.h>
-#include "AccountService.h"
+//#include "AccountService.h"
 #include "API/Account/IAccountManager.h"
 
-//using namespace TizenApis::Api::Account;
+using namespace TizenApis::Api::Account;
 //using namespace WrtDeviceApis::Commons;
 //using namespace WrtDeviceApis::CommonsJavaScript;
 
@@ -45,7 +45,7 @@ class AccountManager : public IAccountManager
                virtual ~AccountManager();
 
        protected:
-               virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event);
+//             virtual void OnRequestReceived(const IEventGetAccountServicesPtr &event);
                virtual void OnRequestReceived(const IEventAddAccountPtr &event);
                virtual void OnRequestReceived(const IEventDeleteAccountPtr &event);
                virtual void OnRequestReceived(const IEventFindAccountsPtr &account);
@@ -55,6 +55,9 @@ class AccountManager : public IAccountManager
                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:
index fae2d5b..e61a29f 100755 (executable)
@@ -14,7 +14,6 @@
  * limitations under the License.
  */
 
-
 /**
  * @file        AccountWrapper.cpp
  * @author      Jihwa Park (jh7979.park@samsung.com)
@@ -28,7 +27,7 @@
 #include <dpl/log/log.h>
 #include <Commons/Exception.h>
 #include "AccountWrapper.h"
-#include "AccountService.h"
+//#include "AccountService.h"
 #include "account.h"
 
 #include "db-util.h"
@@ -37,7 +36,7 @@ using namespace TizenApis::Api::Account;
 using namespace WrtDeviceApis::Commons;
 //using namespace WrtDeviceApis::CommonsJavaScript;
 
- // For Test
+// For Test
 
 #define _QUERY_DB_NAME "/opt/dbspace/.test-accounts.db"
 #define _QUERY_SQL_STRING_LEN          4096    //short sql string length
@@ -49,6 +48,10 @@ using namespace WrtDeviceApis::Commons;
 #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;
 
@@ -58,7 +61,7 @@ typedef sqlite3_stmt* stmt;
        "displayname TEXT, "\
        "icon TEXT, "\
        "account_id TEXT, "\
-       "enable INTEGER, "\
+       "enable INTEGER DEFAULT 0, "\
        "credential_id REAL, "\
        "settings TEXT, "\
        "provider_id TEXT, "\
@@ -118,8 +121,7 @@ typedef sqlite3_stmt* stmt;
        "icon TEXT "\
 ");"
 
-stmt __query_prepare(char *query)
-{
+stmt __query_prepare(char *query) {
        int rc = -1;
        stmt pStmt = NULL;
 
@@ -127,26 +129,38 @@ stmt __query_prepare(char *query)
 
        rc = sqlite3_prepare_v2(test_hDBCt, query, strlen(query), &pStmt, NULL);
 
-       if(SQLITE_OK != rc)
-       {
+       if (SQLITE_OK != rc) {
                return NULL;
        }
 
        return pStmt;
 }
 
-int _query_exec(char *query)
+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)
 {
-   int rc = -1;
-   char* pszErrorMsg = NULL;
+   return sqlite3_column_int(pStmt, pos);
+}
 
-    rc = sqlite3_exec(test_hDBCt, query, NULL, NULL, &pszErrorMsg);
-   if(SQLITE_OK != rc)
-   {
-       sqlite3_free(pszErrorMsg);
-   }
+char* _query_column_text(stmt pStmt, int pos)
+{
+   return (char *)sqlite3_column_text(pStmt, pos);
+}
 
-   return rc;
+double _query_column_double(stmt pStmt, int pos)
+{
+   return sqlite3_column_double(pStmt, pos);
 }
 
 int
@@ -154,36 +168,36 @@ _create_all_tables(void)
 {
        int rc = -1;
        int error_code = 0;
-       char    query[_QUERY_SQL_STRING_LEN + 1] = {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);
+               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);
+               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);
+               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);
+               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);
+               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);
+               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);
+               snprintf(query, sizeof(query) - 1, __PROVIDER_LIST_SCHEMA, _PROVIDER_LIST_TABLE_NAME);
                rc = _query_exec(query);
 
        }
@@ -194,43 +208,38 @@ _create_all_tables(void)
 int _query_bind_text(stmt pStmt, int pos, char* str)
 {
        int len = 0;
-       if(str != NULL)
-       {
+       if (str != NULL) {
                len = strlen(str);
-               return sqlite3_bind_text(pStmt, pos, (const char*)str, len, SQLITE_STATIC);
+               return sqlite3_bind_text(pStmt, pos, (const char*) str, len, SQLITE_STATIC);
        }
        return -1;
 }
 
-int _query_step(stmt pStmt)
-{
+int _query_step(stmt pStmt) {
        return sqlite3_step(pStmt);
 }
 
-void _query_finalize(stmt pStmt)
-{
+void _query_finalize(stmt pStmt) {
        int rc = -1;
 
-       if(!pStmt)
-         return;
+       if (!pStmt)
+               return;
 
        rc = sqlite3_finalize(pStmt);
-       if(rc != SQLITE_OK)
-       {
+       if (rc != SQLITE_OK) {
 
        }
 }
 
-int _query_bind_int(stmt pStmt, int pos, int num)
-{
-   return sqlite3_bind_int(pStmt, pos, num);
+int _query_bind_int(stmt pStmt, int pos, int num) {
+       return sqlite3_bind_int(pStmt, pos, num);
 }
-#if 0
+#if 1
 void insert_dummy_data()
 {
-       int             rc = 0;
-       char    query[_QUERY_SQL_STRING_LEN + 1] = {0, };
-       stmt    hstmt = NULL;
+       int rc = 0;
+       char query[_QUERY_SQL_STRING_LEN + 1] = {0,};
+       stmt hstmt = NULL;
        int i = 0;
 
        _create_all_tables();
@@ -239,15 +248,15 @@ void insert_dummy_data()
        memset(query, 0x00, sizeof(query));
        sprintf(query, "insert into %s(tag_name) values (?) ", _TAGS_MIME_TABLE_NAME);
 
-       char* tag_name[] =
+       const char* tag_name[] =
        {
-               "tizen.messaging",
-               "tizen.email",
-               "tizen.sms",
-               "tizen.mms",
-               "tizen.chat",
-               "tizen.call",
-               "tizen.sharing"
+               "call.voice",
+               "call.video",
+               "call.emergency",
+               "call",
+               "sync.contact",
+               "sync.calendar",
+               "messaging.email"
        };
 
        for(i = 0; i < 7; i++)
@@ -270,9 +279,9 @@ void insert_dummy_data()
 // 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);
+                       "(?, ?, ?, ?, ?) ", _USER_ACCOUNT_TABLE_NAME);
 
-       char* displayname[] =
+       const char* displayname[] =
        {
                "Jamie's google account",
                "William's facebook account",
@@ -280,7 +289,7 @@ void insert_dummy_data()
                "Lucille's account"
        };
 
-       char* icon[] =
+       const char* icon[] =
        {
                "/opt/icon/image1.jpg",
                "",
@@ -288,7 +297,7 @@ void insert_dummy_data()
                "/opt/icon/image2.jpg"
        };
 
-       char* account_id[] =
+       const char* account_id[] =
        {
                "com.google:Jamie@gmail.com",
                "com.facebook:William@facebook.com",
@@ -296,7 +305,7 @@ void insert_dummy_data()
                "com.custom:Lucille@gmail.com"
        };
 
-       char* provider_id[] =
+       const char* provider_id[] =
        {
                "com.google",
                "com.facebook",
@@ -304,7 +313,7 @@ void insert_dummy_data()
                "com.custom"
        };
 
-       char* login_id[] =
+       const char* login_id[] =
        {
                "Jamie@gmail.com",
                "William@facebook.com",
@@ -334,19 +343,27 @@ void insert_dummy_data()
 
 // insert to _SERVICETYPE_TABLE_NAME
        memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(serviceType_id) values (?) ", _SERVICETYPE_TABLE_NAME);
+       sprintf(query, "insert into %s(serviceType_id, display_name) values (?, ?) ", _SERVICETYPE_TABLE_NAME);
+
+       const char* service_type_id[] =
+       {
+               "tizen.tel",
+               "tizen.xmpp",
+               "tizen.sip"
+       };
 
-       char* service_type_id[] =
+       const char* service_type_display_name[] =
        {
-               "tizen.sms",
-               "tizen.mms",
-               "tizen.tel"
+               "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)
@@ -360,10 +377,20 @@ void insert_dummy_data()
 
 // insert to _SERVICE_TABLE_NAME
        memset(query, 0x00, sizeof(query));
-       sprintf(query, "insert into %s(service_id, provider_id, serviceType_id) values "
-               "(?, ?, ?) ", _SERVICES_TABLE_NAME);
+       sprintf(query, "insert into %s(service_id, provider_id, serviceType_id, service_name, display_name) values "
+               "(?, ?, ?, ?, ?) ", _SERVICES_TABLE_NAME);
 
-       char* service_id[] =
+       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",
@@ -373,6 +400,16 @@ void insert_dummy_data()
                "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);
@@ -383,12 +420,15 @@ void insert_dummy_data()
                {
                        _query_bind_text(hstmt, 2, (char*)provider_id[0]);
                        _query_bind_text(hstmt, 3, (char*)service_type_id[i]);
-               }else
+               } 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)
                {
@@ -403,7 +443,7 @@ void insert_dummy_data()
        memset(query, 0x00, sizeof(query));
        sprintf(query, "insert into %s(provider_id, display_name) values (?, ?) ", _PROVIDER_LIST_TABLE_NAME);
 
-       char* provider_display_name[] =
+       const char* provider_display_name[] =
        {
                "provider:com.google",
                "provider:com.facebook",
@@ -441,7 +481,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -453,7 +493,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -465,7 +505,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -478,7 +518,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -491,7 +531,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -504,7 +544,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -517,7 +557,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -530,7 +570,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -543,7 +583,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -556,7 +596,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -569,7 +609,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -582,7 +622,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -595,7 +635,7 @@ void insert_dummy_data()
 
        rc = _query_step(hstmt);
        if(rc != SQLITE_DONE)
-               printf("\n !! rc : %d \n", rc);
+       printf("\n !! rc : %d \n", rc);
        _query_finalize(hstmt);
        hstmt = NULL;
 
@@ -611,7 +651,7 @@ void insert_dummy_data()
                {
                        _query_bind_int(hstmt, 1, 1);
                        _query_bind_int(hstmt, 2, i+1);
-               }else
+               } else
                {
                        _query_bind_int(hstmt, 1, i-1);
                        _query_bind_int(hstmt, 2, 3);
@@ -630,7 +670,6 @@ void insert_dummy_data()
 
 }
 #endif
-
 typedef enum
 {
        SERVICE_TYPE_ID,
@@ -646,22 +685,6 @@ typedef enum
        ALL
 }status_e;
 
-typedef enum
-{
-       TIZEN_MESSAGING = 0x00000001,
-       TIZEN_SMS = 0x00000002,
-       TIZEN_MMS = 0x00000004,
-       TIZEN_EMAIL = 0x00000008,
-       TIZEN_CHAT = 0x00000010,
-       TIZEN_CALL = 0x00000020,
-       TIZEN_TEL = 0x00000040,
-       TIZEN_VIDEOCALL = 0x00000080,
-       TIZEN_VOIP = 0x00000100,
-       TIZEN_SKYPE = 0x00000200,
-       TIZEN_SHARING = 0x00000400,
-       TIZEN_CUSTOM = 0x01000000
-}tags_e;
-
 typedef struct
 {
        char* tag_info;
@@ -700,19 +723,6 @@ typedef struct
 
 typedef struct
 {
-       char* AccountId;
-       char* displayName;
-       char* icon;
-       bool enabled;
-       char* AccountServiceProviderId;
-       unsigned long credentialId;
-       GList* services; // AccountService_t
-       char* settings;
-       provider_t* provider;
-}UserAccount_t;
-
-typedef struct
-{
        char* displayName;
        char* icon;
 }UserProperties_t;
@@ -722,105 +732,134 @@ UserProperties_t property = {0, };
 AccountServiceType_t serviceType = {0, };
 provider_t provider = {0, };
 
-int addAccount(const char* providerId, UserProperties_t* properties, UserAccount_t* account)
+int check_provider_activate(char* providerId, int* activate, char** package_name)
 {
-       return 0;
+       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;
 }
 
-typedef struct
+int _add_platform_to_web()
 {
-       GList* filter_list;
-       status_e status;
-       int tags_count;
-}search_list_t;
 
-typedef struct
+// update provider_list table
+
+// update user_account table
+       return 0;
+}
+
+int addAccount(char* providerId, UserProperties_t* properties, UserAccount_t* account)
 {
-       filter_e filter_type;
-       char* value;
-}filter_value_t;
+       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;
 
-int set_account_filter(search_list_t* search_list, filter_e filter_type, char* value)
+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)
+       if (filter_type == TAGS)
                search_list->tags_count++;
        search_list->filter_list = g_list_append(search_list->filter_list, object);
 
        return 0;
 }
 
-static char* filter_attribute[FILTER_ATTRIBUTE_MAX] =
+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;
-
-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);
-}
+typedef enum {
+       USE_FILTER_NONE = 0x00000000, USE_SERVICE_TYPE_ID = 0x00000001, USE_TAGS = 0x00000002, USE_PROVIDER_ID = 0x00000004
+} used_filter_attr;
 
-double _query_column_double(stmt pStmt, int pos)
-{
-   return sqlite3_column_double(pStmt, pos);
-}
+typedef enum {
+       TAG_SERVICE, TAG_SERVICE_TYPE
+} tags_owner;
 
-#define QUERY_MAX_LEN 4096
-#define SUB_QUERY_LEN 2048
-#define TABLE_LEN 512
+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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
 
-       switch(owner)
-       {
-               case TAG_SERVICE :
+       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 :
+               case TAG_SERVICE_TYPE:
                        snprintf(query, sizeof(query) - 1, "select tag_name from relation where type_id = %d", id);
-               default :
+               default:
                        break;
        }
 
        stmt hstmt = __query_prepare(query);
 
        rc = _query_step(hstmt);
-       while(rc == SQLITE_ROW)
-       {
+       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));
@@ -831,75 +870,65 @@ void _get_tags(tags_owner owner, int id, GList** tags_list)
        _query_finalize(hstmt);
 }
 
-char* _make_condition_part(search_list_t* search_list, query_type_e type)
-{
+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, };
+       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)
+       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;
+       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 (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')
+                               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);
+                       } 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')
+                               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)
+                                       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)
+                                       } 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
-                               {
+                               } 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)
+                                       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);
+                       } else if (object->filter_type == PROVIDER_ID) {
+                               use_filter = (used_filter_attr) (use_filter | USE_PROVIDER_ID);
 
-                               if(tmp_query[0] == '\0')
+                               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]);
@@ -909,28 +938,23 @@ char* _make_condition_part(search_list_t* search_list, query_type_e type)
                tmp_filter_list = g_list_next(tmp_filter_list);
        }
 
-       if(table[0] != '\0')
+       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)
-               {
+       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)
-               {
+               } 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)
-               {
+       } else {
+               if ((use_filter | USE_PROVIDER_ID) == USE_PROVIDER_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 user_account.provider_id = ? ");
+                       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);
@@ -938,26 +962,26 @@ char* _make_condition_part(search_list_t* search_list, query_type_e type)
                }
        }
 
-       if(filter_count == 0)
+       if (filter_count == 0)
                return NULL;
        else
                return query;
 }
 
-void _get_service_list_by_account(char* provider_id, GList** service_list)
-{
+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, };
+       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 = %s", _SERVICES_TABLE_NAME, provider_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)
-       {
+       while (rc == SQLITE_ROW) {
                AccountService_t* service_info = NULL;
                service_info = g_new0(AccountService_t, 1);
 
@@ -970,7 +994,7 @@ void _get_service_list_by_account(char* provider_id, GList** service_list)
                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);
+               id = _query_column_int(hstmt, 9);
 
                _get_tags(TAG_SERVICE, id, &(service_info->tags_info));
 
@@ -980,14 +1004,13 @@ void _get_service_list_by_account(char* provider_id, GList** service_list)
        _query_finalize(hstmt);
 }
 
-void _make_account_info(int user_id, UserAccount_t* account_info)
-{
-       char query[QUERY_MAX_LEN + 1] = {0, };
+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);
+                       "from %s where user_id = %d", _USER_ACCOUNT_TABLE_NAME, user_id);
 
        stmt hstmt = __query_prepare(query);
 
@@ -1003,35 +1026,18 @@ void _make_account_info(int user_id, UserAccount_t* account_info)
        _query_finalize(hstmt);
        hstmt = NULL;
 
-// Get provider
-       snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon "
-               "from %s where provider_id = '%s'", _PROVIDER_LIST_TABLE_NAME, account_info->AccountServiceProviderId);
-
-       hstmt = __query_prepare(query);
-
-       rc = _query_step(hstmt);
-
-       account_info->provider = g_new0(provider_t, 1);
-       account_info->provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
-       account_info->provider->displayName = g_strdup(_query_column_text(hstmt, 1));
-       account_info->provider->icon = g_strdup(_query_column_text(hstmt, 2));
-
-       _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, };
+void _make_service_info(int id, AccountService_t* service_info) {
+       char query[QUERY_MAX_LEN + 1] = { 0, };
        int rc = 0;
        stmt hstmt = NULL;
 
-// Get user_account
+// 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);
+                       "from %s where _svc_id = %d", _SERVICES_TABLE_NAME, id);
 
        hstmt = __query_prepare(query);
 
@@ -1065,15 +1071,14 @@ void _make_service_info(int id, AccountService_t* service_info)
 
 }
 
-int find_accounts(search_list_t* search_list, status_e status, GList** account_list)
-{
+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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
        int i = 1;
-       int index_list[SUB_QUERY_LEN + 1] = {0, };
+       int index_list[SUB_QUERY_LEN + 1] = { 0, };
        int index_count = 0;
        int rc = 0;
-       stmt    hstmt = NULL;
+       stmt hstmt = NULL;
 
        char* filter = _make_condition_part(search_list, FIND_ACCOUNT);
 
@@ -1082,26 +1087,26 @@ int find_accounts(search_list_t* search_list, status_e status, GList** account_l
                case ENABLE :
                {
                        if(filter)
-                               snprintf(query, sizeof(query) - 1, "select user_account.user_id from user_account %s and user_account.enable = 1", 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 user_account.user_id from user_account where user_account.enable = 1");
+                               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 user_account.user_id from user_account %s and user_account.enable = 0", 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 user_account.user_id from user_account where user_account.enable = 0");
+                               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 user_account.user_id from user_account %s", filter);
+                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account %s", filter);
                        else
-                               snprintf(query, sizeof(query) - 1, "select user_account.user_id from user_account");
+                               snprintf(query, sizeof(query) - 1, "select distinct(user_account.user_id) from user_account");
                }
                        break;
        }
@@ -1109,24 +1114,17 @@ int find_accounts(search_list_t* search_list, status_e status, GList** account_l
        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;
+       while (filter_list_val) {
+               filter_value_t* object = (filter_value_t*) filter_list_val->data;
 
-               if(object->value != NULL)
+               if (object->value != NULL)
                        _query_bind_text(hstmt, i++, object->value);
-
-               printf("input value : %s \n", object->value);
-
                filter_list_val = g_list_next(filter_list_val);
        }
 
        rc = _query_step(hstmt);
-       printf("rc : %d \n", rc);
-
        int ret = 0;
-       while(rc == SQLITE_ROW)
-       {
+       while (rc == SQLITE_ROW) {
                ret = _query_column_int(hstmt, 0);
                index_list[index_count++] = ret;
                rc = _query_step(hstmt);
@@ -1135,8 +1133,7 @@ int find_accounts(search_list_t* search_list, status_e status, GList** account_l
        _query_finalize(hstmt);
 
 // make account object by index_list
-       for(i = 0; i< index_count; i++)
-       {
+       for (i = 0; i < index_count; i++) {
 // Get account info
                UserAccount_t* account_info = NULL;
                account_info = g_new0(UserAccount_t, 1);
@@ -1146,18 +1143,17 @@ int find_accounts(search_list_t* search_list, status_e status, GList** account_l
                *account_list = g_list_append(*account_list, account_info);
        }
 
-       if(filter)
+       if (filter)
                free(filter);
 
        return error_code;
 }
 
-int find_services(search_list_t* search_list, status_e status, GList** service_list)
-{
+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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
        int i = 1;
-       int index_list[SUB_QUERY_LEN + 1] = {0, };
+       int index_list[SUB_QUERY_LEN + 1] = { 0, };
        int index_count = 0;
        int rc = 0;
 
@@ -1168,26 +1164,26 @@ int find_services(search_list_t* search_list, status_e status, GList** service_l
                case ENABLE :
                {
                        if(filter)
-                               snprintf(query, sizeof(query) - 1, "select service._id from service %s and service.enable = 1", 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 service._id from service where service.enable = 1");
+                               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 service._id from service %s and service.enable = 0", 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 service._id from service where service.enable = 0");
+                               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 service._id from service %s", filter);
+                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service %s", filter);
                        else
-                               snprintf(query, sizeof(query) - 1, "select service._id from service");
+                               snprintf(query, sizeof(query) - 1, "select distinct(service._svc_id) from service");
                }
                        break;
        }
@@ -1195,27 +1191,24 @@ int find_services(search_list_t* search_list, status_e status, GList** service_l
        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;
+       while (filter_list_val) {
+               filter_value_t* object = (filter_value_t*) filter_list_val->data;
 
-               if(object->value != NULL)
+               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)
-       {
+       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++)
-       {
+       for (i = 0; i < index_count; i++) {
 // Get service info
                AccountService_t* service_info = NULL;
                service_info = g_new0(AccountService_t, 1);
@@ -1225,34 +1218,34 @@ int find_services(search_list_t* search_list, status_e status, GList** service_l
                *service_list = g_list_append(*service_list, service_info);
        }
 
-       if(filter)
+       if (filter)
                free(filter);
 
        return error_code;
 }
 
-int find_providers(const char* serviceTypeId, GList** provider_list)
+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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
+       char sub_query[SUB_QUERY_LEN + 1] = { 0, };
 
-       if(serviceTypeId == NULL)
-       {
+       if (serviceTypeId == NULL) {
                snprintf(query, sizeof(query) - 1, "select provider_id, display_name, icon from provider_list");
-       }else
-       {
+       } 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);
+                               "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)
-       {
+       while (rc == SQLITE_ROW) {
                provider_t* provider = NULL;
                provider = g_new0(provider_t, 1);
                provider->AccountServiceProviderId = g_strdup(_query_column_text(hstmt, 0));
@@ -1273,21 +1266,20 @@ 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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
 
-       if(prefix == NULL)
+       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)
+       if (prefix != NULL)
                _query_bind_text(hstmt, 1, prefix);
 
        rc = _query_step(hstmt);
-       while(rc == SQLITE_ROW)
-       {
+       while (rc == SQLITE_ROW) {
                type_id = _query_column_int(hstmt, 0);
 
                AccountServiceType_t* servicetype = NULL;
@@ -1307,12 +1299,11 @@ int find_service_types(char* prefix, GList** servicetype_list)
 }
 
 // use mandatory input parameter
-int getAccountById(char* accountId, UserAccount_t* account)
-{
+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, };
+       char query[QUERY_MAX_LEN + 1] = { 0, };
 
        snprintf(query, sizeof(query) - 1, "select user_id from user_account where account_id = ?");
 
@@ -1329,12 +1320,12 @@ int getAccountById(char* accountId, UserAccount_t* account)
        return error_code;
 }
 
-int getServiceTypeById(char* serviceTypeId, AccountServiceType_t* serviceType)
-{
+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 = ?");
 
@@ -1342,6 +1333,7 @@ int getServiceTypeById(char* serviceTypeId, AccountServiceType_t* serviceType)
        _query_bind_text(hstmt, 1, serviceTypeId);
 
        rc = _query_step(hstmt);
+       printf("rc : %d \n", rc);
 
        type_id = _query_column_int(hstmt, 0);
 
@@ -1356,6 +1348,90 @@ int getServiceTypeById(char* serviceTypeId, AccountServiceType_t* serviceType)
        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;
@@ -1378,36 +1454,302 @@ int getProviderById(char* serviceProviderId, provider_t* provider)
        return error_code;
 }
 
-namespace TizenApis {
-namespace Platform {
-namespace Account{
-AccountWrapper::AccountWrapper() : m_platformAccount(NULL), m_abstractAccount(NULL)
+int getServiceById(char* serviceId, AccountService_t* service_info)
 {
-    LogDebug("entered");
-    m_abstractAccount = EventAccountPtr(new EventAccount());
-    if (!m_abstractAccount) {
-        ThrowMsg(UnknownException, "abstract object is not created");
-    }
-}
+       int error_code = 0;
+       int rc = 0;
+       char query[QUERY_MAX_LEN + 1] = {0, };
 
-AccountWrapper::AccountWrapper(const EventAccountPtr &event) : m_platformAccount(NULL), m_abstractAccount(event)
-{
-    LogDebug("entered");
-}
+       snprintf(query, sizeof(query) - 1, "select _svc_id where service_id = ?");
 
-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();
+       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 AccountWrapper::getIDFromPlatformAccount() const
+int getServiceByName(char* serviceName, AccountService_t* service_info)
 {
-    LogDebug("Entered");
-    int error_code = -1;
-       int accountid = 0;
+       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");
     }
@@ -1441,7 +1783,8 @@ void AccountWrapper::saveAccount()
 
     //insert new record or update existing one
     if (accountID < 0) { // insert new account
-           int err = addAccount(m_abstractAccount->getProviderName().c_str(), &property, &user_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);
@@ -1463,7 +1806,7 @@ void AccountWrapper::saveAccount()
         LogDebug("Account updated");
     }
 
-}
+                       }
 
 void AccountWrapper::loadAccount(int id)
 {
@@ -1508,183 +1851,132 @@ void AccountWrapper::deleteAccount()
 
 void AccountWrapper::getAccountbyId()
 {
-    std::string accountID = m_abstractAccount->getAccountId();
-    LogDebug("accountID : " << accountID);
-       unsigned long value = 123;
-       bool b_value = true;
-
-//     int errorCode = getAccountById(m_abstractAccount->getAccountId().c_str(), &user_account);
-
-       m_abstractAccount->setAccountId("com.google:getaccountbyid@gmail.com");
-       m_abstractAccount->setDisplayName("samsung");
-       m_abstractAccount->setIconPath("/path/icon/icon.png");
-       m_abstractAccount->setProviderName("com.google");
-       m_abstractAccount->setEnabled(b_value);
-       m_abstractAccount->setCredentailId(value);
-       m_abstractAccount->setSettings("port:8080, server:http://test.com");
-/*
-       m_abstractAccount->setAccountId(user_account.AccountId);
-       m_abstractAccount->setDisplayName(user_account.displayName);
-       m_abstractAccount->setIconPath(user_account.icon);
-       m_abstractAccount->setProviderName(user_account.AccountServiceProviderId);
-       m_abstractAccount->setEnabled(user_account.enabled);
-       m_abstractAccount->setCredentailId(user_account.credentialId);
-       m_abstractAccount->setSettings(user_account.settings);
-*/
+       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);
        }
 */
-//     convertPlatformAccountToAbstractAccount();
-}
+       if(account->AccountId)
+               m_abstractAccount->setAccountId(account->AccountId);
 
-void AccountWrapper::getServiceTypebyId()
-{
-    std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
-    LogDebug("serviceTypeId : " << serviceTypeId);
+       if(account->displayName)
+               m_abstractAccount->setDisplayName(account->displayName);
 
-//     getServiceTypeById(m_abstractAccount->getServiceTypeId().c_str(), &serviceType);
-       m_abstractAccount->setAccountId("com.google:getaccountbyid@gmail.com");
+       if(account->icon)
+               m_abstractAccount->setIconPath(account->icon);
 
-}
+       if(account->AccountServiceProviderId)
+               m_abstractAccount->setProviderName(account->AccountServiceProviderId);
 
-void AccountWrapper::getProviderbyId()
-{
-    std::string providerId = m_abstractAccount->getProviderId();
-    LogDebug("providerId : " << providerId);
+       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();
 
-//     getProviderById(m_abstractAccount->getProviderId().c_str(), &provider);
-       m_abstractAccount->setAccountId("com.google:getaccountbyid@gmail.com");
+       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);
 
 }
 
-void AccountWrapper::findProviders()
+AccountServiceProviderPropertyArrayPtr AccountWrapper::findProviders(std::string serviceTypeId)
 {
-    std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
-    LogDebug("serviceTypeId : " << serviceTypeId);
+       LogDebug("<<<");
 
-       db_util_open(_QUERY_DB_NAME, &test_hDBCt, 0);
-//     insert_dummy_data();
+       AccountServiceProviderPropertyArrayPtr serviceProviderPropertiesPtr(new AccountServiceProviderPropertyArray);
 
-#if 0
        GList* provider_list = NULL;
-       int i = 0;
+       GList* tmp_list = NULL;
 
-       GList* account_list = NULL;
-       UserAccount_t* account = NULL;
+       find_providers((char*)serviceTypeId.c_str(), &provider_list);
+       tmp_list = provider_list;
 
-       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)
+       while(tmp_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);
-       }
+               provider_t* provider = (provider_t*)tmp_list->data;
 
-       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\n\n", account_info->AccountServiceProviderId);
-               account_list = g_list_next(account_list);
-       }
+               AccountServiceProviderPropertyPtr serviceProviderPropertyPtr(new AccountServiceProviderProperty());
 
-       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\n\n", account_info->AccountServiceProviderId);
-               account_list = g_list_next(account_list);
-       }
+               if(provider->AccountServiceProviderId)
+                       serviceProviderPropertyPtr->setId(provider->AccountServiceProviderId);
 
-       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\n\n", account_info->AccountServiceProviderId);
-               account_list = g_list_next(account_list);
-       }
+               if(provider->displayName)
+                       serviceProviderPropertyPtr->setDisplayName(provider->displayName);
 
-       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);
+               if(provider->icon)
+                       serviceProviderPropertyPtr->setIconPath(provider->icon);
+
+               serviceProviderPropertiesPtr->push_back(serviceProviderPropertyPtr);
+
+               tmp_list = g_list_next(tmp_list);
        }
+       free_provider_list(provider_list);
 
-       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);
+       LogDebug(">>>");
+       return serviceProviderPropertiesPtr;
+}
 
-       while(account_list)
+void AccountWrapper::setTags(std::vector<std::string> &tagsVector, GList* tags_list)
+{
+       GList* tmp_tags_list = tags_list;
+       while(tmp_tags_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);
-
-// Add service info to Javascript obj
-               account_list = g_list_next(account_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());
 
-#endif
        GList* servicetype_list = NULL;
+       find_service_types((char*)m_abstractAccount->getprefix().c_str(), &servicetype_list);
 
-       find_service_types("tizen", &servicetype_list);
-       while(servicetype_list)
+       GList* tmp_list = servicetype_list;
+       while(tmp_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);
+               AccountServiceType_t* serviceType_info = (AccountServiceType_t*)tmp_list->data;
 
-                       tmp_tag_list = g_list_next(tmp_tag_list);
-               }
+               AccountServiceTypePropertyPtr serviceType(new AccountServiceTypeProperty());
 
-               servicetype_list = g_list_next(servicetype_list);
-       }
+               if(serviceType_info->AccountServiceTypeId)
+                       serviceType->setId(serviceType_info->AccountServiceTypeId);
 
-       m_abstractAccount->setAccountId("com.google:findProviders@gmail.com");
+               if(serviceType_info->displayName)
+                       serviceType->setDisplayName(serviceType_info->displayName);
 
-}
+               if(serviceType_info->icon)
+                       serviceType->setIconPath(serviceType_info->icon);
 
-void AccountWrapper::findServiceTypes()
-{
-       std::string prefix = m_abstractAccount->getprefix();
-    LogDebug("prefix : " << prefix);
-//     GList* servicetype_list = NULL;
+// add tags
+               std::vector<std::string> tagsVector;
 
-//     find_service_types(m_abstractAccount->getprefix().c_str(), &servicetype_list);
+               setTags(tagsVector, serviceType_info->tags_info);
+               if(serviceType_info->tags_info)
+                       serviceType->setTags(tagsVector);
 
-//     m_abstractAccount->setAccountId("com.google:findServiceTypes@gmail.com");
+               servicetypes->push_back(serviceType);
+               tmp_list = g_list_next(tmp_list);
+       }
+       free_serviceType_list(servicetype_list);
 
+       return servicetypes;
 }
 
 char *AccountWrapper::getPlatformAccount() const
@@ -1693,55 +1985,51 @@ char *AccountWrapper::getPlatformAccount() const
     return (char*)m_platformAccount;
 }
 
-EventAccountPtr AccountWrapper::getAbstractAccount() const
-{
-    LogDebug("entered");
-    return m_abstractAccount;
-}
+                       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;
-    }
-}
+                       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();
+                       char *AccountWrapper::convertAbstractAccountToPlatformAccount() {
+                               LogDebug("entered");
+                               freePlatformAccount();
 
-       if (ACCOUNT_ERROR_NONE != account_create(&m_platformAccount)) {
-               ThrowMsg(PlatformException, "Can't create handle");
-       }
+                               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());
+                               property.displayName = g_strdup(m_abstractAccount->getDisplayName().c_str());
+                               property.icon = g_strdup(m_abstractAccount->getIconPath().c_str());
 
-       setDisplayNameToPlatformAccount();
-       setIconPathToPlatformAccount();
-       setProviderNameToPlatformAccount();
-/*
-       setUserNameToPlatformAccount();
-       setPackageNameToPlatformAccount();
+                               setDisplayNameToPlatformAccount();
+                               setIconPathToPlatformAccount();
+                               setProviderNameToPlatformAccount();
+                               /*
+                                setUserNameToPlatformAccount();
+                                setPackageNameToPlatformAccount();
 
-       //TODO: check if we need to have  user be able to set  the ID.
-       //setIDToPlatformAccount();
-       setEmailAddressToPlatformAccount();
-       setDomainNameToPlatformAccount();
+                                //TODO: check if we need to have  user be able to set  the ID.
+                                //setIDToPlatformAccount();
+                                setEmailAddressToPlatformAccount();
+                                setDomainNameToPlatformAccount();
 
-       setAccountServices();
-*/
-       return getPlatformAccount();
-}
+                                setAccountServices();
+                                */
+                               return getPlatformAccount();
+                       }
 
-void AccountWrapper::setIDToPlatformAccount()
-{
-    LogDebug("entered");
+                       void AccountWrapper::setIDToPlatformAccount() {
+                               LogDebug("entered");
 
 //TODO: check if we need to have  user be able to set  the ID.
 
@@ -1763,151 +2051,212 @@ void AccountWrapper::setIDToPlatformAccount()
             ThrowMsg(PlatformException, "Can't set event ID.");
         }
     }
-       #endif
+#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::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::setIconPathToPlatformAccount() {
+                               LogDebug("entered");
+                               if (!m_platformAccount) {
+                                       ThrowMsg(UnknownException, "Null platform pointer.");
+                               }
 
-void AccountWrapper::setProviderNameToPlatformAccount()
-{
-    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.");
+                               }
 
-       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.");
-       }
+                       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.");
+                               }
+                       }
 
-       if (ACCOUNT_ERROR_NONE != account_set_email_address(m_platformAccount, m_abstractAccount->getEmailAddress().c_str()))
-       {
-               ThrowMsg(PlatformException, "Can't set packagename.");
-       }
-}
+                       void AccountWrapper::setEmailAddressToPlatformAccount() {
+                               LogDebug("entered");
+                               if (!m_platformAccount) {
+                                       ThrowMsg(UnknownException, "Null platform pointer.");
+                               }
 
-void AccountWrapper::setDomainNameToPlatformAccount()
-{
-       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.");
+                               }
+                       }
 
-       if (ACCOUNT_ERROR_NONE != account_set_domain_name(m_platformAccount, m_abstractAccount->getDomainName().c_str()))
-       {
-               ThrowMsg(PlatformException, "Can't set packagename.");
-       }
-}
+                       void AccountWrapper::setDomainNameToPlatformAccount() {
+                               LogDebug("entered");
+                               if (!m_platformAccount) {
+                                       ThrowMsg(UnknownException, "Null platform pointer.");
+                               }
 
-/*
-void AccountWrapper::setHasContactFeatureToPlatformAccount()
-{
-    LogDebug("entered");
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
-       account_set_capability(m_platformAccount, ACCOUNT_CAPABILITY_CONTACT, ACCOUNT_CAPABILITY_ENABLED);
-}
-*/
+                               if (ACCOUNT_ERROR_NONE != account_set_domain_name(m_platformAccount, m_abstractAccount->getDomainName().c_str())) {
+                                       ThrowMsg(PlatformException, "Can't set packagename.");
+                               }
+                       }
 
-void AccountWrapper::setAccountServices()
-{
-    LogDebug("entered");
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
+                       /*
+                        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;
+                               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());
+                               //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 (!m_platformAccount) {
+    if (!account) {
         ThrowMsg(UnknownException, "Null platform pointer.");
     }
 
        AccountServicesArrayPtr services(new AccountServicesArray());
-       for(int i = 0; i < 2; i++)
+
+       GList* tmp_service_list = account->services;
+       while(tmp_service_list)
        {
+               AccountService_t* service_info = (AccountService_t*)tmp_service_list->data;
+
                AccountServicesPtr service(new AccountServices());
 
-               service->setName("gmail");
-//             service->setServiceType("google_service");
+               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::getDummyAccountServiceType(){
-
+AccountServiceTypePropertyPtr AccountWrapper::getAccountServiceTypebyId()
+{
        std::string serviceTypeId = m_abstractAccount->getServiceTypeId();
-
        AccountServiceTypePropertyPtr accountServiceTypePropertyPtr(new AccountServiceTypeProperty);
-       accountServiceTypePropertyPtr->setId(serviceTypeId);
-       accountServiceTypePropertyPtr->setDisplayName("dummyDisplayName");
-       accountServiceTypePropertyPtr->setIconPath("dummyIconPath");
-       std::vector<std::string> dummyVector;
-       dummyVector.push_back("dummyTag1");
-       dummyVector.push_back("dummyTag2");
-       accountServiceTypePropertyPtr->setTags(dummyVector);
+
+       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::getDummyAccountServiceProviderProperty(){
+AccountServiceProviderPropertyPtr AccountWrapper::getAccountServiceProviderProperty()
+{
        std::string accountServiceProviderId = m_abstractAccount->getProviderId();
 
+       provider_t provider = {0, };
+       getProviderById((char*)accountServiceProviderId.c_str(), &provider);
+
        AccountServiceProviderPropertyPtr accountServiceProviderPropertyPtr(new AccountServiceProviderProperty);
-       accountServiceProviderPropertyPtr->setId(accountServiceProviderId);
-       accountServiceProviderPropertyPtr->setDisplayName("dummyDisplayName");
-       accountServiceProviderPropertyPtr->setIconPath("dummyIconPath");
+
+       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;
 }
@@ -1928,16 +2277,184 @@ void AccountWrapper::setDummyServices(){
                service->setServiceTypeId("dummy_serviceTypeId");
                service->setProviderId("dummy_ProviderId");
 //             service->setTags("dummy_");
-               service->setSettings("dummy_settings");
+                                       service->setSettings("dummy_settings");
 
-               services->push_back(service);
-       }
+                                       services->push_back(service);
+                               }
 
-       m_abstractAccount->setService(services);
+                               m_abstractAccount->setService(services);
 
-       LogDebug(">>>");
+                               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()
 {
@@ -2004,71 +2521,66 @@ void AccountWrapper::setDisplayNameFromPlatformAccount()
 
 void AccountWrapper::setIconPathFromPlatformAccount()
 {
-    LogDebug("entered");
-    if (!m_platformAccount) {
-        ThrowMsg(UnknownException, "Null platform pointer.");
-    }
+   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);
-    }
+   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.");
-    }
+                       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);
-    }
-}
+                               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.");
-    }
+                       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);
-    }
-}
+                               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.");
-    }
+                       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);
-    }
-}
+                               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::displayAbstractAccount() {
+                               LogDebug("account id : " << m_abstractAccount->getID());
+                               LogDebug("Display name  : " << m_abstractAccount->getDisplayName());
+                       }
 
-void AccountWrapper::displayPlatformAccount()
-{
+                       void AccountWrapper::displayPlatformAccount() {
 
-}
+                       }
 
-}
-}
+               }
+       }
 }
index ad47391..138d03d 100755 (executable)
 #include <API/Account/EventAccount.h>
 #include <API/Account/AccountServiceTypeProperty.h>
 #include <API/Account/AccountServiceProviderProperty.h>
-#include "account.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 {
@@ -58,15 +70,18 @@ class AccountWrapper
                void        loadAccount(int id);
                void        deleteAccount();
                void            getAccountbyId();
-               void            getServiceTypebyId();
-               void            getProviderbyId();
-               void            findProviders();
-void findServiceTypes();
+               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();
-               AccountServiceTypePropertyPtr     getDummyAccountServiceType();
-               AccountServiceProviderPropertyPtr getDummyAccountServiceProviderProperty();
 
        protected:
                int  getIDFromPlatformAccount() const;
@@ -99,6 +114,8 @@ void findServiceTypes();
                account_h m_platformAccount;
                EventAccountPtr m_abstractAccount;
 
+               UserAccount_t* account;
+
 //             static std::map<std::string, std::string> attrSvcMap;
 
 };
index 7e5b818..071ce1a 100755 (executable)
@@ -19,7 +19,7 @@ set(LIBS_PLATFORM_IMPLEMENTATION_ACCOUNT
 )
 
 set(SRCS_PLATFORM_IMPLEMENTATION_ACCOUNT
-  ${CURRENT_PATH}/AccountService.cpp
+#  ${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
new file mode 100755 (executable)
index 0000000..e596f63
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * 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
new file mode 100755 (executable)
index 0000000..0b63ff8
--- /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. 
+ */
+
+
+/**
+ * @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 b3657d7..bcfe943 100755 (executable)
 #include "Application.h"
 #include <API/Application/ApplicationEvent.h>
 #include <API/Application/ApplicationInformation.h>
+#include <API/Application/ApplicationContext.h>
+
 #include <bundle.h>
-#include <API/Application/ApplicationServiceExtraData.h>
-#include <API/Application/ApplicationServiceRequest.h>
+#include <aul.h>
+#include <ail.h>
+#include <app.h>
+#include <API/Application/ApplicationServiceData.h>
+#include <API/Application/ApplicationService.h>
+#include <dpl/log/log.h>
 
 namespace TizenApis {
 namespace Platform {
@@ -38,11 +44,100 @@ using namespace Platform;
 
 namespace
 {
+       typedef struct {
+               char **result_str;
+               ail_prop_str_e type;
+       } convert_cb_context;
+
+       ail_cb_ret_e convert_cb(const ail_appinfo_h appinfo, void *user_data)
+       {
+               convert_cb_context *foreach_cb_context = NULL;
+               if (appinfo == NULL || user_data == NULL) {
+                       return AIL_CB_RET_CANCEL;
+               }
+               
+               foreach_cb_context = (convert_cb_context *)user_data;
+               char* tmp_str = NULL;
+               if (ail_appinfo_get_str(appinfo, foreach_cb_context->type, &tmp_str) == AIL_ERROR_OK) {
+                       *(foreach_cb_context->result_str) = strdup(tmp_str);
+                       return AIL_CB_RET_CANCEL;
+               } else {
+                       return AIL_CB_RET_CONTINUE;
+               }
+       }
+
+       static char* id_to_pkg(const char* appId)
+       {
+               ail_filter_h filter;
+               ail_error_e ret;
+               char* result = NULL;
+
+               LogDebug("[id_to_pkg] appId : "<<appId);
+               ret = ail_filter_new(&filter);
+               if (ret != AIL_ERROR_OK)
+               {
+                       return NULL;
+               }
+
+               ret = ail_filter_add_str(filter, AIL_PROP_X_SLP_PACKAGEID_STR , appId);
+               if (ret != AIL_ERROR_OK)
+               {
+                       ail_filter_destroy(filter);
+                       return NULL;
+               }
+
+               convert_cb_context foreach_cb_context;
+               foreach_cb_context.result_str = &result;
+               foreach_cb_context.type = AIL_PROP_PACKAGE_STR;
+               
+               ail_filter_list_appinfo_foreach(filter, convert_cb, &foreach_cb_context);
+               ail_filter_destroy(filter);
+
+               LogDebug("[id_to_pkg] pkg : "<<result);
+               return result;
+       }
+
+       static char* pkg_to_id(const char* pkg)
+       {
+               ail_appinfo_h handle;
+               ail_error_e ret;
+               char* getVal;
+               char* result;
+
+               LogDebug("[pkg_to_id] pkg : "<<pkg);
+               ret = ail_package_get_appinfo(pkg, &handle);
+               if (ret != AIL_ERROR_OK) {
+                       LogDebug("[id_to_pkg] fail to get appinfo ");
+                       return NULL;
+               }
+
+               ret = ail_appinfo_get_str(handle, AIL_PROP_X_SLP_PACKAGEID_STR, &getVal);
+               if (ret != AIL_ERROR_OK) {
+                       LogDebug("[id_to_pkg] fail to get web id ");
+                       return NULL;
+               }
+
+               result = strdup(getVal);
+
+               ret = ail_package_destroy_appinfo(handle);
+               if (ret != AIL_ERROR_OK) {
+                       LogError("===[WS] pkg_to_id. error. return NULL");
+                       return NULL;
+               }
+
+               LogDebug("[pkg_to_id] id : "<<result);
+               return result;
+       }
+
+
+       
        static bool app_manager_app_list_cb(const char *package, void *user_data)
        {
                char *name = NULL;
                char *iconPath = NULL;
                char *version = NULL;
+               char *appid = pkg_to_id(package);
+
                if(user_data != NULL){
                        EventListInstalledApplications* event = (EventListInstalledApplications*)user_data;
 
@@ -51,20 +146,52 @@ namespace
                        app_manager_get_app_icon_path(package, &iconPath);
                        app_manager_get_app_version(package, &version);
                        appinfo->setName(name);
-                       appinfo->setPackage(package);
+                       appinfo->setAppId(appid);
                        appinfo->setIconPath(iconPath);
                        appinfo->setVersion(version);                   
                                
                        event->addApplicationInformation(appinfo);
-                       free(name);
-                       free(iconPath);
-                       free(version);
+                       if (name)
+                               free(name);
+                       if (iconPath)
+                               free(iconPath);
+                       if (version)
+                               free(version);
+                       if (appid)
+                               free(appid);
                }
                return true;
        }
 
+       static int app_manager_app_context_cb(const aul_app_info *ainfo, void *user_data)
+       {
+               //TBD : get package from appid. below code is temporal code. should be replaced.
+               //char *appid;
+               //appid = app_manager_get_appid(package, &appid);
+               char *appid = pkg_to_id(ainfo->pkg_name);
+               //char *appid = strdup(ainfo->pkg_name);
+               char contextid[PATH_MAX];
+               snprintf(contextid, PATH_MAX, "%d", ainfo->pid);
+
+               if(user_data != NULL){
+                       EventListInstalledApplications* event = (EventListInstalledApplications*)user_data;
+
+                       ApplicationContextPtr appcontext(new ApplicationContext());
+                       appcontext->setAppId(appid);
+                       appcontext->setContextId(contextid);
+
+                       event->addApplicationContext(appcontext);
+                       if (appid)
+                               free(appid);
+               }
+               return 0;
+       }
+
+
        static void app_manager_app_list_changed_cb(app_manger_event_type_e event_type,const char *package, void *user_data)
        {
+               LogDebug(">>> app_manager_app_list_changed_cb");
+                       
                if(user_data != NULL){
                        ((Application*)user_data)->InstalledApplicationChanged(event_type, package);
                }
@@ -80,31 +207,70 @@ namespace
        static bool service_extra_data_cb(service_h service, const char *key, void* user_data)
        {
                EventLaunchService* event = (EventLaunchService*)user_data;
-               char *value=NULL;
                LogDebug(">>>service_extra_data_cb, key = "<<key);
-               int result = service_get_extra_data(service, key, &value);
-               switch (result ){
-                       case SERVICE_ERROR_NONE:{
-                               LogDebug("service_get_extra_data success");
-                               LogDebug("key = "<<key<<" value = "<<value);
-                               // let's set key extra data to event.
-                               std::string StrKey = key;
-                               std::string StrValue = value;
-                               // FIXME :
-                               event->addExtraDataToReply(StrKey, StrValue);
-                               free(value);
-                               break;
+
+               bool isArray = false;
+               if (service_is_extra_data_array(service, key, &isArray) != SERVICE_ERROR_NONE) {
+                       LogDebug("service_is_extra_data_array retuns Error");
+               }
+
+               if (isArray) {
+                       int length = 0;
+                       char **value = NULL;
+                       int result = service_get_extra_data_array(service, key, &value, &length);
+                       switch (result ){
+                               case SERVICE_ERROR_NONE:{
+                                       LogDebug("service_get_extra_data success");
+                                       //LogDebug("key = "<<key<<" value = "<<value);
+                                       // let's set key extra data to event.
+                                       std::string StrKey = key;
+                                       std::vector<std::string> StrValue;
+                                       for (int i = 0; i < length; i++) {
+                                               StrValue.push_back(std::string(value[i]));
+                                       }
+
+                                       event->addServiceData(StrKey, StrValue);
+                                       free(value);
+                                       break;
+                               }
+                               case SERVICE_ERROR_INVALID_PARAMETER:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_INVALID_PARAMETER");
+                               case SERVICE_ERROR_KEY_NOT_FOUND:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_KEY_NOT_FOUND");
+                               case SERVICE_ERROR_OUT_OF_MEMORY:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_OUT_OF_MEMORY");
+                               default :
+                                       LogDebug("service_get_extra_data retuns Error");
+                                       return false;
+                                       break;
+                       }                       
+               } else {
+                       char *value = NULL;
+                       int result = service_get_extra_data(service, key, &value);
+                       switch (result ){
+                               case SERVICE_ERROR_NONE:{
+                                       LogDebug("service_get_extra_data success");
+                                       LogDebug("key = "<<key<<" value = "<<value);
+                                       // let's set key extra data to event.
+                                       std::string StrKey = key;
+                                       std::vector<std::string> StrValue;
+                                       StrValue.push_back(value);
+                                       event->addServiceData(StrKey, StrValue);
+                                       
+                                       free(value);
+                                       break;
+                               }
+                               case SERVICE_ERROR_INVALID_PARAMETER:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_INVALID_PARAMETER");
+                               case SERVICE_ERROR_KEY_NOT_FOUND:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_KEY_NOT_FOUND");
+                               case SERVICE_ERROR_OUT_OF_MEMORY:
+                                       LogDebug("service_get_extra_data retuns SERVICE_ERROR_OUT_OF_MEMORY");
+                               default :
+                                       LogDebug("service_get_extra_data retuns Error");
+                                       return false;
+                                       break;
                        }
-                       case SERVICE_ERROR_INVALID_PARAMETER:
-                               LogDebug("service_get_extra_data retuns SERVICE_ERROR_INVALID_PARAMETER");
-                       case SERVICE_ERROR_KEY_NOT_FOUND:
-                               LogDebug("service_get_extra_data retuns SERVICE_ERROR_KEY_NOT_FOUND");
-                       case SERVICE_ERROR_OUT_OF_MEMORY:
-                               LogDebug("service_get_extra_data retuns SERVICE_ERROR_OUT_OF_MEMORY");
-                       default :
-                               LogDebug("service_get_extra_data retuns Error");
-                               return false;
-                               break;
                }
                return true;
        }
@@ -122,6 +288,38 @@ Application::~Application()
 {
 }
 
+void Application::launch(const EventManageApplicationPtr& event)
+{
+       if (m_initialized == false) {
+               initialize();
+       }
+
+       EventRequestReceiver<EventManageApplication>::PostRequest(event);
+}
+
+void Application::kill(const EventManageApplicationPtr& event)
+{
+       if (m_initialized == false) {
+               initialize();
+       }
+
+       EventRequestReceiver<EventManageApplication>::PostRequest(event);
+}
+
+void Application::exit()
+{
+       app_efl_exit();
+}
+
+void Application::hide(const EventManageApplicationPtr& event)
+{
+       if (m_initialized == false) {
+               initialize();
+       }
+
+       EventRequestReceiver<EventManageApplication>::PostRequest(event);
+}
+
 void Application::listApplications(const EventListInstalledApplicationsPtr& event)
 {
        if (m_initialized == false) {
@@ -131,7 +329,7 @@ void Application::listApplications(const EventListInstalledApplicationsPtr& even
        EventRequestReceiver<EventListInstalledApplications>::PostRequest(event);
 }
 
-void Application::getApplicationInformation(const EventGetApplicationPtr& event)
+void Application::getApplication(const EventGetApplicationPtr& event)
 {
        if (m_initialized == false) {
                initialize();
@@ -140,8 +338,7 @@ void Application::getApplicationInformation(const EventGetApplicationPtr& event)
        EventRequestReceiver<EventGetApplication>::PostRequest(event);
 }
 
-
-long Application::addApplicationListChangeListener(const EventInstalledApplicationChangedEmitterPtr& emitter)
+long Application::addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter)
 {
        if(m_installedApplicationsEmitterPtr != NULL)
        {
@@ -166,7 +363,7 @@ long Application::addApplicationListChangeListener(const EventInstalledApplicati
 
 }
 
-void Application::removeApplicationListChangeListener(const EventInstalledApplicationChangedEmitter::IdType id)
+void Application::removeApplicationInformationEventListener(const EventInstalledApplicationChangedEmitter::IdType id)
 {
        if(m_installedApplicationsEmitterPtr)
        {
@@ -194,16 +391,37 @@ void Application::launchService(const EventLaunchServicePtr& event)
        LogDebug(">>>");
 }
 
-void Application::InstalledApplicationChanged(app_manger_event_type_e event_type,const char *package)
+void Application::getApplicationService(const EventLaunchServicePtr& event)
+{
+       LogDebug("<<<");
+
+       if (m_initialized == false) {
+               initialize();
+       }
+
+       EventRequestReceiver<EventLaunchService>::PostRequest(event);
+
+       LogDebug(">>>");
+}
+
+
+void Application::InstalledApplicationChanged(app_manger_event_type_e event_type, const char *package)
 {
        char *name = NULL;
        char *iconPath = NULL;
        char *version = NULL;
+       LogDebug(">>> InstalledApplicationChanged : package : " << package);
+       char *appid = pkg_to_id(package);
+       LogDebug(">>> InstalledApplicationChanged : appid : " << appid);
+
+       if (appid == NULL) {
+               appid = strdup(package);
+       }
        
        EventInstalledApplicationChangedPtr event(new EventInstalledApplicationChanged());
        ApplicationInformationPtr appinfo(new ApplicationInformation());
 
-       appinfo->setPackage(package);   
+       appinfo->setAppId(appid);       
        if(event_type != APP_MANAGER_EVENT_UNINSTALLED)
        {
                app_manager_get_app_name(package, &name);
@@ -242,6 +460,8 @@ void Application::InstalledApplicationChanged(app_manger_event_type_e event_type
                free(iconPath);
        if(version != NULL )
                free(version);
+       if(appid != NULL )
+               free(appid);
 
        LogDebug("<<<InstalledApplicatonChanged");
 }
@@ -257,8 +477,7 @@ void Application::launchServiceManualAnswer(service_h request, service_h reply,
                // onsuccess
                LogDebug("SERVICE_RESULT_SUCCEEDED in service_result_cb");
 
-               //after  service_foreach_extra_data() called, extra_data must be set to event
-               int result = service_foreach_extra_data(reply,  service_extra_data_cb, m_eventLaunchServicePtr.Get());          
+               int result = service_foreach_extra_data(reply, service_extra_data_cb, m_eventLaunchServicePtr.Get());           
                if( result == SERVICE_ERROR_NONE)
                {
                        LogDebug("service_foreach_extra_data() success");
@@ -272,28 +491,11 @@ void Application::launchServiceManualAnswer(service_h request, service_h reply,
                m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_REPLY_SUCCESS_CALLBACK);
                
        }
-       else if(result == SERVICE_RESULT_FAILED)
+       else if(result == SERVICE_RESULT_FAILED || result == SERVICE_RESULT_CANCELED)
        {
                // onfail
                LogDebug("SERVICE_RESULT_FAILED in service_result_cb");
-               //after  service_foreach_extra_data() called, extra_data must be set to event
-               int result = service_foreach_extra_data(reply,  service_extra_data_cb, m_eventLaunchServicePtr.Get());
-               if( result == SERVICE_ERROR_NONE)
-               {
-                       LogDebug("service_foreach_extra_data() success");
-               }
-               else
-               {
-                       LogDebug("service_foreach_extra_data() failed");
-               }
-               
-               m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_REPLY_FAIL_CALLBACK);
-       }
-       else if(result == SERVICE_RESULT_CANCELED)
-       {
-               // oncancel
-               m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_REPLY_CANCEL_CALLBACK);                
-               LogDebug("SERVICE_RESULT_CANCELED in service_result_cb");                       
+               m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_REPLY_FAIL_CALLBACK);
        }
 
        // FIXME : if there is no callback , then we don't need to call ManualAnswer. 
@@ -313,7 +515,7 @@ void Application::OnRequestReceived(const Api::Application::EventListInstalledAp
                        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
                
        } else if(event->getEventType() == EventListInstalledApplications::APPMANAGER_LIST_RUNNING_APPLICATIONS) {
-               int result = app_manager_foreach_app_running(app_manager_app_list_cb, event.Get());
+               int result = aul_app_get_running_app_info(app_manager_app_context_cb, event.Get());
                if( result != 0)
                        event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
        } else {
@@ -322,109 +524,285 @@ void Application::OnRequestReceived(const Api::Application::EventListInstalledAp
        }
 }
 
-void Application::OnRequestReceived(const Api::Application::EventGetApplicationPtr& event)
+void Application::OnRequestReceived(const Api::Application::EventManageApplicationPtr& event)
 {
-       char *name = NULL;
-       char *iconPath = NULL;
-       char *version = NULL;
-       std::string strPackage = event->getPackage();
+       if (event->getEventType() == EventManageApplication::APP_MANAGER_LAUNCH_APPLICATION) {
+               service_h service;
+               service_create(&service);
+
+               std::string arg = event->getArgument();
+               
+               if (!arg.empty()) {
+                       service_set_operation(service, "slp.appsvc.operation.PAGE");
+                       service_set_uri(service, arg.c_str());                  
+               } else {
+                       service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+               }
+
+               const char *appId = event->getAppId().c_str();
+               if (appId == NULL) {
+                       LogError("[ERROR] Can not get context id from context");
+                       event->setExceptionCode(Commons::ExceptionCodes::UnknownException);                     
+               }
+               char *package = id_to_pkg(appId);
+               service_set_package(service, package);
+               service_send_launch_request(service, NULL, this);
+
+               service_destroy(service);
+               
+               if (package)
+                       free(package);
        
-       ApplicationInformationPtr appinfo(new ApplicationInformation());
-       LogInfo("package name to get information : "<<strPackage);
-       if( app_manager_get_app_name(strPackage.c_str(), &name) <0  ||
-               app_manager_get_app_icon_path(strPackage.c_str(), &iconPath) <0)
-       {
-               LogError("can not get the information of "<<strPackage<<" package");
-               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+       } else if (event->getEventType() == EventManageApplication::APP_MANAGER_KILL_APPLICATION) {
+               const char *contextId = event->getApplicationContext()->getContextId().c_str();
+               if (contextId == NULL) {
+                       LogError("[ERROR] Can not get context id from context");
+                       event->setExceptionCode(Commons::ExceptionCodes::UnknownException);                     
+               }
+               
+               int pid = atoi(contextId);
+               int result = aul_terminate_pid(pid);
+               if (result < 0) {
+                       LogError("[ERROR] Fail to terminate application with context");
+                       event->setExceptionCode(Commons::ExceptionCodes::UnknownException);                             
+               }
+       } else if (event->getEventType() == EventManageApplication::APP_MANAGER_HIDE_APPLICATION) {
+               LogError("[ERROR] Hide is not supported yet");
+               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);     
+       } else {
+               LogError("[ERROR] UNKNOWN EVENT TYPE");
+               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
        }
-       else
-       {
-               if(     app_manager_get_app_version(strPackage.c_str(), &version) <0)   
+}
+
+
+
+void Application::OnRequestReceived(const Api::Application::EventGetApplicationPtr& event)
+{
+       if(event->getEventType() == EventGetApplication::APP_MANAGER_GET_INFORMATION) {
+               char *name = NULL;
+               char *iconPath = NULL;
+               char *version = NULL;
+               char *appId = NULL;
+               char *package = NULL;
+               
+               std::string strId = event->getAppId();
+               if (strId.empty()) {
+                       //char *tmpStr;
+                       if (app_get_package(&package) != APP_ERROR_NONE) {
+                               LogError("[ERROR] Can not get package name from current pid");
+                               event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                       } else {
+                               appId = pkg_to_id(package);
+                       }
+               } else {
+                       //TBD : get package from appid. below code is temporal code. should be replaced.
+                       //package = strId.c_str();
+                       appId = strdup(strId.c_str());
+                       package = id_to_pkg(appId);
+               }
+
+               ApplicationInformationPtr appinfo(new ApplicationInformation());
+               LogInfo("AppID to get information : "<<appId);
+               if( app_manager_get_app_name(package, &name) <0  ||
+                       app_manager_get_app_icon_path(package, &iconPath) <0)
                {
-                       LogWarning("can not get the version information of "<<strPackage<<" package");
+                       LogError("can not get the information of "<<appId<<" package");
+                       event->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
                }
-               appinfo->setName(name);
-               appinfo->setPackage(strPackage.c_str());
-               appinfo->setIconPath(iconPath);
-               appinfo->setVersion(version);
-               event->setApplicationInformation(appinfo);
+               else
+               {
+                       if(     app_manager_get_app_version(package, &version) <0)      
+                       {
+                               LogWarning("can not get the version information of "<<appId<<" package");
+                       }
+                       appinfo->setName(name);
+                       appinfo->setAppId(appId);
+                       appinfo->setIconPath(iconPath);
+                       appinfo->setVersion(version);
+                       event->setApplicationInformation(appinfo);
+               }
+
+               LogError("Recheck!!! AppId : "<<appinfo->getAppId());
+               
+               if(name)
+                       free(name);
+               if(iconPath)    
+                       free(iconPath);
+               if(version)     
+                       free(version);
+               if(package)     
+                       free(package);
+               if (appId)
+                       free(appId);
+               
+       } else if (event->getEventType() == 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::NotFoundException);
+               } else {
+                       char *appId = pkg_to_id(package);
+                       ApplicationContextPtr appContext(new ApplicationContext());
+                       appContext->setAppId(appId);
+                       appContext->setContextId(contextId);
+
+                       event->setApplicationContext(appContext);
+                       
+                       if (package)
+                               free(package);
+                       if (appId)
+                               free(appId);
+               }
+       } else {
+               LogError("[ERROR] UNKNOWN EVENT TYPE");
+               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
        }
-       
-       if(name)
-               free(name);
-       if(iconPath)    
-               free(iconPath);
-       if(version)     
-               free(version);
 }
 
+extern "C" int service_create_event(bundle *data, struct service_s **service);
+
 void Application::OnRequestReceived(const Api::Application::EventLaunchServicePtr& event)
 {
-       LogDebug("<<<");
-       m_eventLaunchServicePtr = event;
-       ApplicationServiceRequestPtr appservice= event->getServiceRequest();
+       LogError("[enter] OnRequestReceived >>>");
+       if (event->getEventType() == 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";
+               service_h service;
 
-       // from now on we will have to call answer manually
-       event->switchToManualAnswer();
+               bundle *request_bundle = bundle_decode((bundle_raw*)bundle_str.c_str(), bundle_str.length());
+               if (service_create_event(request_bundle, &service) != SERVICE_ERROR_NONE)
+               {
+                       // throw exception.
+               }
 
-       service_h service;
-       service_create(&service);
-       service_set_operation(service, appservice->getOperation().c_str() );
+               ApplicationServicePtr appService(new ApplicationService());
+               char* str;
 
-       if( appservice->getPackage().compare("") != 0)
-       {
-               LogDebug("package name is "<<appservice->getPackage());
-               service_set_package(service, appservice->getPackage().c_str() );                
-       }       
+               appService->setService_h(service);
+               
+               if (service_get_operation(service, &str) == SERVICE_ERROR_NONE) {
+                       LogError("operation : "<<str);
+                       if (str != NULL) {
+                               appService->setOperation(str);
+                               free(str);
+                       }
+               } else {
+                       LogError("fail to get operation");
+               }
+               if (service_get_uri(service, &str) == SERVICE_ERROR_NONE) {
+                       LogError("uri : "<<str);
+                       if (str != NULL) {
+                               appService->setUri(str);        
+                               free(str);
+                       }               
+               } else {
+                       LogError("fail to get uri");
+               }
+               if (service_get_mime(service, &str) == SERVICE_ERROR_NONE) {
+                       LogError("mime : "<<str);
+                       if (str != NULL) {
+                               appService->setMime(str);       
+                               free(str);
+                       }                       
+               } else {
+                       LogError("fail to get mime");
+               }
 
-       if( appservice->getUri().compare("") != 0)
+               event->setService(appService);
+               if (service_foreach_extra_data(service, service_extra_data_cb, event.Get()) != SERVICE_ERROR_NONE)
+               {
+                       LogError("service_foreach_extra_data fail");
+               }
+               else
+               {
+                       LogError("service_foreach_extra_data success");
+               }
+       } 
+       else if (event->getEventType() == EventLaunchService::APPLICATION_SERVICE_LAUNCH)
        {
-               LogDebug("appservice.uri is not null");
-               service_set_uri(service, appservice->getUri().c_str() );
-       }
+               LogDebug("<<<");
+               m_eventLaunchServicePtr = event;
+               ApplicationServicePtr appservice= event->getService();
 
-       if( appservice->getMime().compare("") != 0)
-       {
-               LogDebug("mime is "<<appservice->getMime());
-               service_set_mime(service, appservice->getMime().c_str() );
-       }
+               // from now on we will have to call answer manually
+               event->switchToManualAnswer();
 
-       ApplicationServiceExtraDataArrayPtr extraDataArray= appservice->getExtraDataArray();
-       if(extraDataArray)
-       {
-               for (size_t i = 0; i < extraDataArray->size(); ++i) {
-                       LogDebug("extraData.key= " <<extraDataArray->at(i)->getKey()<<"extraData.value = "<<extraDataArray->at(i)->getValue());
-
-                       service_add_extra_data(service, extraDataArray->at(i)->getKey().c_str(), extraDataArray->at(i)->getValue().c_str());
-               }
-       }
-
-       int result = service_send_launch_request (service, service_result_cb , this);
-
-       switch (result){
-               case SERVICE_ERROR_NONE :
-                       LogDebug("service_send_launch_request successful");
-                       m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_CALLBACK);
-                       break;
-               case SERVICE_ERROR_INVALID_PARAMETER:
-                       LogDebug("service_send_launch_request returns SERVICE_ERROR_INVALID_PARAMETER");
-                       m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);   
-                       break;
-               case SERVICE_ERROR_OUT_OF_MEMORY:
-                       LogDebug("service_send_launch_request returns SERVICE_ERROR_OUT_OF_MEMORY");
-                       m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::PlatformException);
-                       break;
-               case SERVICE_ERROR_APP_NOT_FOUND:
-                       LogDebug("service_send_launch_request returns SERVICE_ERROR_APP_NOT_FOUND");
-                       m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
-                       break;
-               default:
-                       LogDebug("service_send_launch_request returns UNKNOWN ERROR!!!");
-                       m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
-                       break;
-       }
-       EventRequestReceiver<Api::Application::EventLaunchService>::ManualAnswer(m_eventLaunchServicePtr);
-       LogDebug(">>>");
+               service_h service;
+               service_create(&service);
+               service_set_operation(service, appservice->getOperation().c_str() );
+
+               if (appservice->getUri().compare("") != 0)
+               {
+                       LogDebug("appservice.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();
+               
+               const char** arr = NULL;
+               const char* key = NULL;
+               if (!serviceDataArray.empty())
+               {
+                       LogDebug("serviceDataArray.size() : "<<serviceDataArray.size());
+                       for (size_t i = 0; i < serviceDataArray.size(); ++i) {
+                               key = serviceDataArray.at(i)->getKey().c_str();
+                               std::vector<std::string> valueArray = serviceDataArray.at(i)->getValue();
+                               
+                               arr = (const char**) calloc (sizeof(char*), valueArray.size());
+
+                               for (size_t j = 0; j < valueArray.size(); j++) {
+                                       arr[j] = valueArray.at(j).c_str();
+                               }
+                               service_add_extra_data_array(service, key, arr, valueArray.size());
+                       }
+               }
+
+               int result = service_send_launch_request (service, service_result_cb , this);
+               
+               //TODO: free each items of arr
+               if (arr)
+                       free(arr);
+
+               switch (result){
+                       case SERVICE_ERROR_NONE :
+                               LogDebug("service_send_launch_request successful");
+                               m_eventLaunchServicePtr->setCallbackType(EventLaunchService::APPLICATION_SERVICE_CALLBACK);
+                               break;
+                       case SERVICE_ERROR_INVALID_PARAMETER:
+                               LogDebug("service_send_launch_request returns SERVICE_ERROR_INVALID_PARAMETER");
+                               m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::InvalidArgumentException);   
+                               break;
+                       case SERVICE_ERROR_OUT_OF_MEMORY:
+                               LogDebug("service_send_launch_request returns SERVICE_ERROR_OUT_OF_MEMORY");
+                               m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+                               break;
+                       case SERVICE_ERROR_APP_NOT_FOUND:
+                               LogDebug("service_send_launch_request returns SERVICE_ERROR_APP_NOT_FOUND");
+                               m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::NotFoundException);
+                               break;
+                       default:
+                               LogDebug("service_send_launch_request returns UNKNOWN ERROR!!!");
+                               m_eventLaunchServicePtr->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+                               break;
+               }
+               EventRequestReceiver<Api::Application::EventLaunchService>::ManualAnswer(m_eventLaunchServicePtr);
+               LogDebug(">>>");
+       } else {
+               LogError("[ERROR] UNKNOWN EVENT TYPE");
+               event->setExceptionCode(Commons::ExceptionCodes::UnknownException);
+       }
 }
 
 void Application::initialize() 
index 17b6c77..1a175c1 100755 (executable)
@@ -23,6 +23,7 @@
 #include <API/Application/ApplicationFactory.h>
 #include <API/Application/EventListInstalledApplications.h>
 #include <API/Application/EventGetApplication.h>
+#include <API/Application/EventManageApplication.h>
 #include <API/Application/EventInstalledApplicationChanged.h>
 #include <API/Application/EventLaunchService.h>
 
@@ -40,16 +41,22 @@ class Application: public IApplication {
 public:
        Application();
        virtual ~Application();
+       virtual void launch(const EventManageApplicationPtr& event);
+       virtual void kill(const EventManageApplicationPtr& event);
+       virtual void exit();
+       virtual void hide(const EventManageApplicationPtr& event);      
        virtual void listApplications(const EventListInstalledApplicationsPtr& event);
-       virtual void getApplicationInformation(const EventGetApplicationPtr& event);
-       virtual long addApplicationListChangeListener(const EventInstalledApplicationChangedEmitterPtr& emitter);
-       virtual void removeApplicationListChangeListener(const EventInstalledApplicationChangedEmitter::IdType id);
-       virtual void launchService(const EventLaunchServicePtr& event); 
+       virtual void getApplication(const EventGetApplicationPtr& event);
+       virtual long addApplicationInformationEventListener(const EventInstalledApplicationChangedEmitterPtr& emitter);
+       virtual void removeApplicationInformationEventListener(const EventInstalledApplicationChangedEmitter::IdType id);
+       virtual void launchService(const EventLaunchServicePtr& event);
+       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);
 
 protected:
        virtual void OnRequestReceived(const EventListInstalledApplicationsPtr& event);
+       virtual void OnRequestReceived(const EventManageApplicationPtr& event);
        virtual void OnRequestReceived(const EventGetApplicationPtr& event);
        virtual void OnRequestReceived(const EventLaunchServicePtr& event);     
  
index a02be8f..3cda9a6 100755 (executable)
@@ -354,6 +354,41 @@ void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event)
     event->setCancelAllowed(false);
 }
 
+void Calendar::OnRequestReceived(const IEventGetPtr &event)
+{
+    LogDebug("entered");
+    Try
+    {
+        if (!event->getItemId()) {
+            ThrowMsg(NullPointerException, "Id parameter is NULL");
+        }
+
+        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)
+    {
+        LogError("Item doesn't exist");
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::NotFoundException);
+    }
+    catch (const Exception &ex)
+    {
+        LogError("Error during getting an item " << ex.DumpToString());
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
+    }
+    event->setCancelAllowed(false);
+}
+
 void Calendar::OnRequestReceived(const IEventDeleteEventsPtr &events)
 {
     LogDebug("entered");
index a2eba33..64c16e1 100755 (executable)
@@ -46,6 +46,7 @@ class Calendar : public ICalendar
     virtual void OnRequestReceived(const IEventWatchChangesPtr &event);
     virtual void OnRequestReceived(const IEventClearWatchPtr &event);
     virtual void OnRequestReceived(const IEventExpandEventRecurrencePtr &event);
+    virtual void OnRequestReceived(const IEventGetPtr &event);
 };
 
 }
index e9f2db2..cc49827 100755 (executable)
@@ -91,9 +91,9 @@ void CalendarFilter::visitPostComposite(TizenApis::Api::Tizen::FilterType& type,
        m_query.append(" )");
 }
 
-void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen::AnyArrayPtr& matchValues, std::string& matchFlag, bool caseSensitive, int depth)
+void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen::MatchFlag& matchFlag, TizenApis::Api::Tizen::AnyArrayPtr& matchValues, int depth)
 {
-       LogDebug("attrName: "<<attrName<<", value length: "<<matchValues->size()<<", matchFlag: "<<matchFlag<<", caseSensitive: "<<caseSensitive<< ", depth:"<<depth);
+       LogDebug("attrName: "<<attrName<<", value length: "<<matchValues->size()<<", matchFlag: "<<matchFlag<<", depth:"<<depth);
 
        std::string conditionQuery;
        std::string matchString;
@@ -109,7 +109,7 @@ void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen
 
         if(matchValue->getType() == TizenApis::Api::Tizen::PrimitiveType_Time)
         {
-            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(matchValue)->getValue();
+            tm date = matchValue->getDateTm();
             std::stringstream time;
             time << mktime(&date);
             valueString = time.str();
@@ -123,15 +123,15 @@ void CalendarFilter::visitAttribute(std::string& attrName, TizenApis::Api::Tizen
             valueString = convertStringToValue(attrName, valueString);
         }
 
-        if( matchFlag=="EXACTLY" ) {
+        if( matchFlag==TizenApis::Api::Tizen::MATCH_EXACTLY ) {
             matchString = " like \'" + valueString + "\'";
-        } else if( matchFlag=="CONTAINS") {
+        } else if( matchFlag==TizenApis::Api::Tizen::MATCH_CONTAINS) {
             matchString = " like \'%" + valueString + "%\'";
-        } else if( matchFlag=="STARTSWITH") {
+        } else if( matchFlag==TizenApis::Api::Tizen::MATCH_STARTSWITH) {
             matchString = " like \'%" + valueString + "\'";
-        } else if( matchFlag=="ENDSWITH") {
+        } else if( matchFlag==TizenApis::Api::Tizen::MATCH_ENDSWITH) {
             matchString = " like \'" + valueString + "%\'";
-        }else if( matchFlag=="EXISTS") {
+        }else if( matchFlag==TizenApis::Api::Tizen::MATCH_EXISTS) {
             matchString = " is not null";
         } else {
             LogError("Invalid matchFlag!");
@@ -157,7 +157,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, TizenApis::Api::
 
        if (initialValue != NULL) {
         if( TizenApis::Api::Tizen::PrimitiveType_Time==initialValue->getType() ) {
-            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(initialValue)->getValue();
+            tm date = initialValue->getDateTm();
             std::stringstream time;
             time << mktime(&date);
             initialValueStr = time.str();
@@ -168,7 +168,7 @@ void CalendarFilter::visitAttributeRange(std::string& attrName, TizenApis::Api::
 
        if (endValue != NULL) {
         if( TizenApis::Api::Tizen::PrimitiveType_Time==endValue->getType() ) {
-            tm date = DPL::DynamicPointerCast< TizenApis::Api::Tizen::Any_T<tm> >(endValue)->getValue();
+            tm date = endValue->getDateTm();
             std::stringstream time;
             time << mktime(&date);
             endValueStr = time.str();
index e03fd33..29fa483 100755 (executable)
@@ -75,9 +75,8 @@ public:
        virtual void visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
 
        virtual void visitAttribute(std::string& attrName,
+                       TizenApis::Api::Tizen::MatchFlag& matchFlag,
                        TizenApis::Api::Tizen::AnyArrayPtr& matchValues,
-                       std::string& matchFlag,
-                       bool caseSensitive,
                        int depth);
 
        virtual void visitAttributeRange(std::string& attrName,
index 2be178c..730efce 100755 (executable)
@@ -43,23 +43,13 @@ static PropertyStructArray properties =
     {CALENDAR_FILTER_ATTRIBUTE_IS_ALL_DAY,          PrimitiveType_Boolean},
     {CALENDAR_FILTER_ATTRIBUTE_END_DATE,            PrimitiveType_Time},
     {CALENDAR_FILTER_ATTRIBUTE_AVAILABILITY,        PrimitiveType_String},
-    {0,        PrimitiveType_Notype}
-};
-
-static MatchFlagStrArray matchFlag
-{
-       "EXACTLY",
-       "CONTAINS",
-       "STARTSWITH",
-       "ENDSWITH",
-       "EXISTS",
-       0
+    {0,        PrimitiveType_NoType}
 };
 
 FilterValidatorPtr CalendarFilterValidatorFactory::getCalendarFilterValidator()
 {
     static FilterValidatorPtr theInstance =
-               FilterValidatorPtr(new FilterValidator(properties, matchFlag));
+               FilterValidatorPtr(new FilterValidator(properties));
     return theInstance;
 }
 
index 9592542..3a21b73 100755 (executable)
@@ -17,6 +17,7 @@
 
 #include "CalendarManager.h"
 #include <vector>
+#include <sstream>
 #include <dpl/log/log.h>
 #include <calendar-svc-provider.h>
 
@@ -66,51 +67,49 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
     static std::vector<ICalendarPtr> calendars;
     Try
     {
-        if (calendars.empty()) {
-            cal_iter *iter = NULL;
-            if (CAL_SUCCESS !=
-                calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR,
-                                     &iter)) {
-                event->setResult(false);
-                return;
+        cal_iter *iter = NULL;
+        if (CAL_SUCCESS !=
+            calendar_svc_get_all(ALL_ACCOUNT_ID, ALL_CALENDAR_ID, CAL_STRUCT_CALENDAR,
+                                 &iter)) {
+            event->setResult(false);
+            return;
+        }
+        cal_struct *calendar = NULL;
+        while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+            if (event->checkCancelled()) {
+                break;
             }
-            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(
-                            calendar,
-                            CAL_TABLE_TXT_NAME);
-                    const int id = calendar_svc_struct_get_int(
-                            calendar,
-                            CAL_TABLE_INT_INDEX);
-                    const int accountId = calendar_svc_struct_get_int(
-                            calendar,
-                            CAL_TABLE_INT_ACCOUNT_ID);
-                    if (name != NULL) {
-                        LogDebug(
-                            "Got calendar, id: " << id << ", name: " << name <<
-                            ", account id: " << accountId);
-                        ICalendarPtr newCalendar(new Calendar());
-                        newCalendar->setName(name);
-                        newCalendar->setId(id);
-                        newCalendar->setAccountId(accountId);
-                        newCalendar->setType(event->getType());
-                        calendars.push_back(newCalendar);
-                    } else {
-                        LogError("calendar contains invalid parameters");
-                    }
-                    calendar_svc_struct_free(&calendar);
-                    calendar = NULL;
+            if (CAL_SUCCESS ==
+                calendar_svc_iter_get_info(iter, &calendar)) {
+                const char* name = calendar_svc_struct_get_str(
+                        calendar,
+                        CAL_TABLE_TXT_NAME);
+                const int id = calendar_svc_struct_get_int(
+                        calendar,
+                        CAL_TABLE_INT_INDEX);
+                const int accountId = calendar_svc_struct_get_int(
+                        calendar,
+                        CAL_TABLE_INT_ACCOUNT_ID);
+                if (name != NULL) {
+                    LogDebug(
+                        "Got calendar, id: " << id << ", name: " << name <<
+                        ", account id: " << accountId);
+                    ICalendarPtr newCalendar(new Calendar());
+                    newCalendar->setName(name);
+                    newCalendar->setId(id);
+                    newCalendar->setAccountId(accountId);
+                    newCalendar->setType(event->getType());
+                    calendars.push_back(newCalendar);
                 } else {
-                    LogError("cannot get calendar");
+                    LogError("calendar contains invalid parameters");
                 }
+                calendar_svc_struct_free(&calendar);
+                calendar = NULL;
+            } else {
+                LogError("cannot get calendar");
             }
-            calendar_svc_iter_remove(&iter);
         }
+        calendar_svc_iter_remove(&iter);
 
         if (!event->checkCancelled()) {
             std::vector<ICalendarPtr>::const_iterator it = calendars.begin();
@@ -124,6 +123,7 @@ void CalendarManager::OnRequestReceived(const IEventGetCalendarsPtr &event)
     {
         LogError("error occuered during obtaining data");
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(true);
 }
@@ -185,6 +185,67 @@ void CalendarManager::OnRequestReceived(const IEventGetDefaultCalendarPtr &event
     {
         LogError("error occuered during obtaining data");
         event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
+    }
+    event->setCancelAllowed(true);
+}
+
+void CalendarManager::OnRequestReceived(const IEventGetCalendarPtr &event)
+{
+    LogDebug("entered");
+    Try
+    {
+        std::stringstream ss(event->getId());
+        int calendarId = -1;
+        ss>>calendarId;
+
+        ICalendarPtr newCalendar(new Calendar());
+
+        cal_iter *iter = NULL;
+        if (CAL_SUCCESS !=
+            calendar_svc_get_all(ALL_ACCOUNT_ID, calendarId, CAL_STRUCT_CALENDAR, &iter)) {
+            event->setResult(false);
+            return;
+        }
+        cal_struct *calendar = NULL;
+        while (CAL_SUCCESS == calendar_svc_iter_next(iter)) {
+            if (CAL_SUCCESS == calendar_svc_iter_get_info(iter, &calendar)) {
+                const char* name = calendar_svc_struct_get_str(
+                        calendar,
+                        CAL_TABLE_TXT_NAME);
+                const int id = calendar_svc_struct_get_int(
+                        calendar,
+                        CAL_TABLE_INT_INDEX);
+                const int accountId = calendar_svc_struct_get_int(
+                        calendar,
+                        CAL_TABLE_INT_ACCOUNT_ID);
+
+                if (name != NULL) {
+                    LogDebug("Got a calendar, id: "<<id<<", name: "<<name<<", account id: "<<accountId);
+                    newCalendar->setName(name);
+                    newCalendar->setId(id);
+                    newCalendar->setAccountId(accountId);
+                    newCalendar->setType(event->getType());
+                    event->setCalendar(newCalendar);
+                    break;
+                } else {
+                    LogError("calendar contains invalid parameters");
+                }
+                calendar_svc_struct_free(&calendar);
+                calendar = NULL;
+            } else {
+                LogError("cannot get calendar");
+            }
+        }
+        calendar_svc_iter_remove(&iter);
+
+        event->setResult(true);
+    }
+    Catch(Exception)
+    {
+        LogError("error occuered during obtaining data");
+        event->setResult(false);
+        event->setExceptionCode(ExceptionCodes::UnknownException);
     }
     event->setCancelAllowed(true);
 }
index 03a7bfc..a64297e 100755 (executable)
@@ -35,6 +35,7 @@ class CalendarManager : public Api::Calendar::ICalendarManager
   protected:
     virtual void OnRequestReceived(const IEventGetCalendarsPtr &event);
     virtual void OnRequestReceived(const IEventGetDefaultCalendarPtr &event);
+    virtual void OnRequestReceived(const IEventGetCalendarPtr &event);
 
   private:
     static int m_instanceCount;
index ae17a04..2651a45 100755 (executable)
@@ -644,7 +644,7 @@ void EventWrapper::setRecurrenceRuleToPlatformEvent()
     }
 
     // set the recurrence end date
-    if (rrule->isEndDateSet()) {
+    if (0!=rrule->getEndDate()) {
         if (CAL_SUCCESS != calendar_svc_struct_set_time(
                 m_platformEvent,
                 CAL_VALUE_GMT_REPEAT_END_DATE,
index b7065c7..04a09c0 100755 (executable)
 #include <API/Filter/IFilter.h>
 #include <API/Filter/IFilterVisitor.h>
 #include <calllog.h>
+#include <contacts-svc.h>
 
 #include "CallHistoryFilter.h"
+#include <app.h>
 
 using namespace TizenApis::Api::Tizen;
 using namespace TizenApis::Api::Call;
@@ -40,6 +42,8 @@ namespace TizenApis {
 namespace Platform {
 namespace Call {
 
+std::vector<CallHistory::WatcherPtr> CallHistory::m_watchers;
+
 CallHistory::CallHistory()
 {
        _db_init();
@@ -60,6 +64,18 @@ CallHistory::~CallHistory()
        } else {
                LogDebug("Failed to disconnect Call history DB ");
        }
+
+       std::vector<CallHistory::WatcherPtr>::iterator it = CallHistory::m_watchers.begin();
+
+       if (m_watchers.size() > 0) {
+               for (;it < CallHistory::m_watchers.end();) {
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, addedListenerCB);
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_MISSED_CALL_CHANGE, changedListenerCB);
+                       it = CallHistory::m_watchers.erase(it);
+                       ++it;
+               }
+               LogDebug("CallHistory Watcher is removed. (" << CallHistory::m_watchers.size() << ")");
+       }
 }
 
 bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistoryEntryListPtr &callEntries)
@@ -68,8 +84,12 @@ bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistory
                return false;
 
        CallHistoryEntryPropertiesPtr callHistoryItem(new CallHistoryEntryProperties());
+       StringArrayPtr stringArray(new StringArray());
+       RemotePartyPtr remoteParty(new RemoteParty());
+       RemotePartyListPtr remotePartyList(new RemotePartyList());
 
        std::string callType("");
+       std::string tags("");
        std::string direction("");
        std::string number("");
        
@@ -79,52 +99,64 @@ bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistory
 
        switch(query_log->calllog_type) {
        case CALLLOG_TYPE_VOICE_ANSWERED:
-               callType.append("tel");
-               direction.append("received");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_RECEIVED);
                break;
        case CALLLOG_TYPE_VOICE_OUTGOING:
-               callType.append("tel");
-               direction.append("dialed");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_DIALED);
                break;
        case CALLLOG_TYPE_VOICE_MISSED_CHECKED:
-               callType.append("tel");
-               direction.append("missed");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_MISSED);
                break;
        case CALLLOG_TYPE_VOICE_MISSED_UNCHECKED:
-               callType.append("tel");
-               direction.append("missed-new");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_MISSED_NEW);
                break;
        case CALLLOG_TYPE_VOICE_REJECTED:
-               callType.append("tel");
-               direction.append("rejected");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_REJECTED);
                break;
        case CALLLOG_TYPE_VOICE_BLOCKED:
-               callType.append("tel");
-               direction.append("blocked");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VOICE);
+               direction.append(STR_BLOCKED);
                break;
        case CALLLOG_TYPE_VIDEO_ANSWERED:
-               callType.append("vt");
-               direction.append("received");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_RECEIVED);
                break;
        case CALLLOG_TYPE_VIDEO_OUTGOING:
-               callType.append("vt");
-               direction.append("dialed");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_DIALED);
                break;
        case CALLLOG_TYPE_VIDEO_MISSED_CHECKED:
-               callType.append("vt");
-               direction.append("missed");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_MISSED);
                break;
        case CALLLOG_TYPE_VIDEO_MISSED_UNCHECKED:
-               callType.append("vt");
-               direction.append("missed-new");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_MISSED_NEW);
                break;
        case CALLLOG_TYPE_VIDEO_REJECTED:
-               callType.append("vt");
-               direction.append("rejected");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_REJECTED);
                break;
        case CALLLOG_TYPE_VIDEO_BLOCKED:
-               callType.append("vt");
-               direction.append("blocked");
+               callType.append(STR_TIZEN_TEL);
+               tags.append(STR_CALL_VIDEO);
+               direction.append(STR_BLOCKED);
                break;
        default:
                return false;
@@ -135,8 +167,14 @@ bool CallHistory::convertCallHistory(callhistory_query_s *query_log, CallHistory
 
        callHistoryItem->setEntryId(query_log->calllog_db_id);
        callHistoryItem->setCallType(callType);
-       callHistoryItem->setRemoteParty(number);
-       callHistoryItem->setContactId(contactId.str());
+       stringArray->push_back(tags);
+       callHistoryItem->setTags(stringArray);
+
+       remoteParty->setRemoteParty(number);
+       remoteParty->setContactId(contactId.str());
+       remotePartyList->push_back(remoteParty);
+       callHistoryItem->setRemoteParties(remotePartyList);
+
        callHistoryItem->setStartTime(query_log->timestamp);
        callHistoryItem->setDuration((unsigned long)(query_log->duration_sec));
        callHistoryItem->setDirection(direction);
@@ -171,6 +209,121 @@ void CallHistory::removeBatch(const EventRemoveBatchPtr& event)
        EventRequestReceiver<EventRemoveBatch>::PostRequest(event);
 }
 
+void CallHistory::removeAll(const EventRemoveAllPtr& event)
+{
+       EventRequestReceiver<EventRemoveAll>::PostRequest(event);
+}
+
+long CallHistory::addListener(const EventCallHistoryListenerEmitterPtr& emitter)
+{
+       int ret =0;
+       if (CallHistory::m_watchers.size() == 0) {
+               WatcherPtr watcher(new Watcher(0, emitter));
+               ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, addedListenerCB, watcher.Get());
+
+               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");
+                       executeQuery(query, callHistoryListPtr);
+
+                       if (callHistoryListPtr->size() > 0) {
+                               watcher->setCurrentLogTime((*callHistoryListPtr)[0]->getStartTime());
+                       }
+               }
+
+               ret = contacts_svc_subscribe_change(CTS_SUBSCRIBE_MISSED_CALL_CHANGE, changedListenerCB, watcher.Get());
+
+               if (ret == CTS_SUCCESS) {
+                       MissedCallListPtr missedCallList(updateCurrentMissedCall());
+                       watcher->setMissedCallList(missedCallList);
+               }
+
+               CallHistory::m_watchers.push_back(watcher);
+               return static_cast<long>(emitter->getId());
+       } else {
+               return 0;
+       }
+}
+
+void CallHistory::removeListener(EventCallHistoryListenerEmitter::IdType id)
+{
+       std::vector<CallHistory::WatcherPtr>::iterator it = CallHistory::m_watchers.begin();
+       
+       for (;it < CallHistory::m_watchers.end();) {
+               if (id == (*it)->getEmitter()->getId()) {
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_PLOG_CHANGE, addedListenerCB);
+                       contacts_svc_unsubscribe_change(CTS_SUBSCRIBE_MISSED_CALL_CHANGE, changedListenerCB);
+                       it = CallHistory::m_watchers.erase(it);
+                       continue;
+               }
+               ++it;
+       }
+}
+
+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(" 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)->stateHasChanged(callHistoryListPtr, EventCallHistoryListener::ADDED);
+       }
+}
+
+void CallHistory::changedListenerCB(void *user_data)
+{
+       MissedCallListPtr missedCallListPtr(((CallHistory::Watcher*)user_data)->getMissedCallList());
+       CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
+       if (missedCallListPtr->size() > 0) {
+               std::string query(STR_BASE_QUERY);
+               query.append(" WHERE log_type <= 12 AND (");
+
+               MissedCallList::iterator itM = missedCallListPtr->begin();
+               std::stringstream id;
+
+               do {
+                       if (itM != missedCallListPtr->begin()) {
+                               query.append(" OR ");
+                       }
+                       query.append(" id = ");
+                       id << static_cast<unsigned long>(*itM);
+                       query.append(id.str());
+                       id.str("");
+                       itM++;
+               } while(itM < missedCallListPtr->end());
+
+               query.append(")");
+
+               ((CallHistory::Watcher*)user_data)->executeQuery(query, callHistoryListPtr);
+
+               CallHistoryEntryList::iterator itC = callHistoryListPtr->begin();
+
+               for (;itC != callHistoryListPtr->end();) {
+                       if ((*itC)->getDirection().compare(STR_MISSED) != 0) {
+                               itC = callHistoryListPtr->erase(itC);
+                               continue;
+                       }
+                       ++itC;
+               }
+
+               if (callHistoryListPtr->size() > 0) {
+                       ((CallHistory::Watcher*)user_data)->updateCurrentMissedCall();
+                       ((CallHistory::Watcher*)user_data)->stateHasChanged(callHistoryListPtr, EventCallHistoryListener::CHANGED);
+               }
+       }
+
+}
 bool CallHistory::executeQuery(std::string &query, CallHistoryEntryListPtr &callEntries)
 {
        callhistory_query_s query_data;
@@ -218,43 +371,52 @@ std::string CallHistory::convertAttrName(std::string &name)
        }
 }
 
-std::string CallHistory::makeQuerySortMode(SortModeArrayPtr attr)
+std::string CallHistory::makeQuerySortMode(SortModePtr attr)
 {
        std::string query("");
        std::string attriName;
-       int cnt = 0;
-       SortModeArray::iterator it = attr->begin();
-       
 
-       for (;it!=attr->end(); ++it) {
-               attriName = (*it)->getAttributeName();
-               attriName = convertAttrName(attriName);
-               if (attriName.compare("") != 0) { 
-                       if (cnt == 0) {
-                               query.append(" ORDER BY ");
-                       } else {
-                               query.append(", ");
-                       }
-                       query.append(attriName);
+       attriName = attr->getAttributeName();
+       attriName = convertAttrName(attriName);
+       if (attriName.compare("") != 0) { 
+               query.append(" ORDER BY ");
+               query.append(attriName);
 
-                       if ((*it)->getOrder() == Api::Tizen::ASCENDING_SORT_ORDER) {
-                               query.append(" ASC");
-                       } else {
-                               query.append(" DESC");
-                       }
-                       cnt++;
+               if (attr->getOrder() == Api::Tizen::ASCENDING_SORT_ORDER) {
+                       query.append(" ASC");
+               } else {
+                       query.append(" DESC");
                }
        }
 
        return query;
 }
 
+MissedCallListPtr CallHistory::updateCurrentMissedCall()
+{
+       CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
+       std::string query(STR_BASE_QUERY);
+       query.append(" WHERE log_type = 5 OR log_type = 7 ORDER BY log_time DESC");
+       executeQuery(query, callHistoryListPtr);
+       LogDebug("result counter [" << callHistoryListPtr->size() << "]");
+
+       CallHistoryEntryList::iterator it = callHistoryListPtr->begin();
+       MissedCallListPtr missedCallList(new MissedCallList());
+
+       for (;it != callHistoryListPtr->end(); ++it) {
+               missedCallList->push_back((*it)->getEntryId());
+       }
+       LogDebug("missed Call size (" << missedCallList->size() << ")");
+
+       return missedCallList;
+}
+
 void CallHistory::OnRequestReceived(const EventFindCallHistoryPtr& event)
 {
        try {
                CallHistoryEntryListPtr callHistoryListPtr(new CallHistoryEntryList());
 
-               std::string query ("SELECT id, log_type, contact_id, number, log_time, data1 FROM phonelogs");
+               std::string query(STR_BASE_QUERY);
 
                CallHistoryFilterPtr filtering(new CallHistoryFilter());
                IFilterVisitorPtr filterTraversal = DPL::StaticPointerCast<IFilterVisitor>(filtering);
@@ -316,6 +478,79 @@ void CallHistory::OnRequestReceived(const EventRemoveBatchPtr& event)
        }
 }
 
+void CallHistory::OnRequestReceived(const EventRemoveAllPtr& event)
+{
+       try {
+               int ret = CALLLOG_ERROR_NONE;
+               ret = calllog_delete_all_from_db();
+               if (ret != CALLLOG_ERROR_NONE) {
+                       event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+               }
+       } catch (const Commons::PlatformException& ex) {
+               LogError("Exception: " << ex.GetMessage());
+               event->setExceptionCode(Commons::ExceptionCodes::PlatformException);
+       }
+}
+
+CallHistory::Watcher::Watcher(int handle, const Api::Call::EventCallHistoryListenerEmitterPtr& emitter) :
+                       m_handle(handle),
+                       m_emitter(emitter),
+                       m_currentLogTime(0)
+{
+       m_missedCallList = MissedCallListPtr(new MissedCallList());
+       _db_init();
+}
+
+CallHistory::Watcher::~Watcher()
+{
+       _db_finish();
+}
+
+void CallHistory::Watcher::stateHasChanged(CallHistoryEntryListPtr &entryList, EventCallHistoryListener::ResultStates state)
+{
+       if (entryList == NULL)
+               return;
+
+       EventCallHistoryListenerPtr event(new EventCallHistoryListener());
+       event->setResultState(state);
+       event->setResult(entryList);
+       m_emitter->emit(event);
+}
+
+bool CallHistory::Watcher::executeQuery(std::string &query, CallHistoryEntryListPtr &entryList)
+{
+       CallHistory* callHistory = (CallHistory *) this;
+       if (callHistory != NULL) {
+               callHistory->executeQuery(query, entryList);
+               return true;
+       }
+       return false;
+}
+
+bool CallHistory::Watcher::addMissedCall(CallHistoryEntryListPtr &entryList)
+{
+       if (entryList != NULL) {
+               CallHistoryEntryList::iterator it = entryList->begin();
+               for (; it != entryList->end(); it++) {
+                       if ((*it)->getDirection().compare(STR_MISSED_NEW) == 0) {
+                               m_missedCallList->push_back((*it)->getEntryId());
+                       }
+               }
+               return true;
+       }
+       return false;
+}
+
+bool CallHistory::Watcher::updateCurrentMissedCall()
+{
+       CallHistory* callHistory = (CallHistory *) this;
+       if (callHistory != NULL) {
+               setMissedCallList(callHistory->updateCurrentMissedCall());
+               return true;
+       }
+       return false;
+}
+
 }
 }
 }
index 9a7b988..63e1c7b 100755 (executable)
@@ -18,6 +18,7 @@
 #ifndef TIZENAPIS_PLATFORM_CALLHISTORY_H_
 #define TIZENAPIS_PLATFORM_CALLHISTORY_H_
 
+#include <vector>
 #include <dpl/shared_ptr.h>
 #include <dpl/noncopyable.h>
 
 #include <API/Call/CallHistoryFactory.h>
 #include <API/Call/EventFindCallHistory.h>
 #include <API/Call/EventRemoveBatch.h>
+#include <API/Call/EventRemoveAll.h>
+#include <API/Call/EventCallHistoryListener.h>
 #include <API/Call/CallHistoryEntryProperties.h>
+#include <API/Call/RemoteParty.h>
 #include "CallHistoryQuery.h"
 
 namespace TizenApis {
 namespace Platform {
 namespace Call {
 
+typedef std::vector<unsigned long> MissedCallList;
+typedef DPL::SharedPtr<MissedCallList> MissedCallListPtr;
+
 class CallHistory : public Api::Call::ICallHistory
 {
 public:
@@ -41,16 +48,86 @@ public:
        void find(const Api::Call::EventFindCallHistoryPtr& event);
        bool remove(const unsigned long entryId);
        void removeBatch(const Api::Call::EventRemoveBatchPtr& event);
+       void removeAll(const Api::Call::EventRemoveAllPtr& event);
+       long addListener(const Api::Call::EventCallHistoryListenerEmitterPtr& emitter);
+       void removeListener(const Api::Call::EventCallHistoryListenerEmitter::IdType id);
+
+       static void addedListenerCB(void *user_data);
+       static void changedListenerCB(void *user_data);
+
+       class Watcher
+       {
+       private:
+               int m_handle;
+               Api::Call::EventCallHistoryListenerEmitterPtr m_emitter;
+               time_t m_currentLogTime;
+               Platform::Call::MissedCallListPtr m_missedCallList;
+
+       public:
+               Watcher(int handle, const Api::Call::EventCallHistoryListenerEmitterPtr& emitter);
+               ~Watcher();
+
+               void setHandle(int handle)
+               {
+                       m_handle = handle;
+               }
+
+               int& getHandle()
+               {
+                       return m_handle;
+               }
+
+               void setCurrentLogTime(time_t logTime)
+               {
+                       m_currentLogTime = logTime;
+               }
+
+               time_t getCurrentLogTime()
+               {
+                       return m_currentLogTime;
+               }
+
+               void setMissedCallList(const Platform::Call::MissedCallListPtr &missedCallList)
+               {
+                       m_missedCallList = missedCallList;
+               }
+
+               Platform::Call::MissedCallListPtr getMissedCallList()
+               {
+                       return m_missedCallList;
+               }
+
+               Api::Call::EventCallHistoryListenerEmitterPtr getEmitter()
+               {
+                       return m_emitter;
+               }
+
+               void emit(const Api::Call::EventCallHistoryListenerPtr& event)
+               {
+                       m_emitter->emit(event);
+               }
+
+               void stateHasChanged(Api::Call::CallHistoryEntryListPtr &entryList, Api::Call::EventCallHistoryListener::ResultStates state);
+               bool executeQuery(std::string &query, Api::Call::CallHistoryEntryListPtr &entryList);
+               bool addMissedCall(Api::Call::CallHistoryEntryListPtr &entryList);
+               bool updateCurrentMissedCall();
+       };
+       typedef DPL::SharedPtr<Watcher> WatcherPtr;
 
 private:
        bool convertCallHistory(callhistory_query_s *query_log, Api::Call::CallHistoryEntryListPtr &callEntries);
        bool executeQuery(std::string &query, Api::Call::CallHistoryEntryListPtr &callEntries);
        std::string convertAttrName(std::string &name);
-       std::string makeQuerySortMode(Api::Tizen::SortModeArrayPtr attr);
+       std::string makeQuerySortMode(Api::Tizen::SortModePtr attr);
+       Platform::Call::MissedCallListPtr updateCurrentMissedCall();
 
 protected:
        void OnRequestReceived(const Api::Call::EventFindCallHistoryPtr& event);
        void OnRequestReceived(const Api::Call::EventRemoveBatchPtr& event);
+       void OnRequestReceived(const Api::Call::EventRemoveAllPtr& event);
+
+private:
+       static std::vector<WatcherPtr> m_watchers;
 };
 
 }
diff --git a/src/platform/Tizen/Call/CallHistoryEntry.cpp b/src/platform/Tizen/Call/CallHistoryEntry.cpp
new file mode 100755 (executable)
index 0000000..bd06d09
--- /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 "CallHistoryEntry.h"
+
+#include <Commons/Exception.h>
+#include <dpl/shared_ptr.h>
+#include <dpl/log/log.h>
+#include <calllog.h>
+
+using namespace TizenApis::Api::Tizen;
+using namespace TizenApis::Api::Call;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace DPL;
+
+namespace TizenApis {
+namespace Platform {
+namespace Call {
+
+CallHistoryEntry::CallHistoryEntry()
+{
+       if (calllog_connect() == CALLLOG_ERROR_NONE) {
+               LogDebug("Successful to connect Call history DB ");
+       } else {
+               LogDebug("Failed to connect Call history DB ");
+       }
+}
+
+CallHistoryEntry::~CallHistoryEntry()
+{
+       if (calllog_disconnect() == CALLLOG_ERROR_NONE) {
+               LogDebug("Successful to disconnect Call history DB ");
+       } else {
+               LogDebug("Failed to disconnect Call history DB ");
+       }
+}
+
+void CallHistoryEntry::setMarkSeen(const unsigned long entryId)
+{
+       calllog_update_missed_unchecked_to_checked_to_db(entryId);
+}
+
+}
+}
+}
+
diff --git a/src/platform/Tizen/Call/CallHistoryEntry.h b/src/platform/Tizen/Call/CallHistoryEntry.h
new file mode 100755 (executable)
index 0000000..4712f84
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * 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_CALLHISTORYENTRY_H_
+#define TIZENAPIS_PLATFORM_CALLHISTORYENTRY_H_
+
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include <dpl/noncopyable.h>
+
+#include <API/Call/ICallHistoryEntry.h>
+#include <API/Call/CallHistoryFactory.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Call {
+
+class CallHistoryEntry : public Api::Call::ICallHistoryEntry
+{
+public:
+       CallHistoryEntry();
+       ~CallHistoryEntry();
+
+       void setMarkSeen(const unsigned long entryId);
+};
+
+}
+}
+}
+
+#endif
index bc4ea2d..46ea04a 100755 (executable)
@@ -83,7 +83,7 @@ void CallHistoryFilter::visitPostComposite(FilterType& type, int depth)
        m_query = m_query + STR_RIGHT_BRACKET;
 }
 
-void CallHistoryFilter::visitAttribute(std::string& attrName, Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth)
+void CallHistoryFilter::visitAttribute(std::string& attrName, MatchFlag& matchFlag, Api::Tizen::AnyArrayPtr& values, int depth)
 {
        std::string str ("");
 
@@ -108,9 +108,9 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
        string initialValueStr ("");
        string endValueStr ("");
 
-       if (attrName.compare("remoteParty") == 0) {
+       if (attrName.compare("remoteParties.remoteParty") == 0) {
                name = STR_NUMBER;
-       } else if (attrName.compare("contactId") == 0) {
+       } else if (attrName.compare("remoteParties.contactId") == 0) {
                name = STR_CONTACT_ID;
        } else if (attrName.compare("startTime") == 0) {
                name = STR_LOG_TIME;    
@@ -122,7 +122,7 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (initialValue != NULL) {
                if(initialValue->getType() == PrimitiveType_Time) {
-                       tm date = DPL::DynamicPointerCast< Any_T<tm> >(initialValue)->getValue();
+                       tm date = initialValue->getDateTm();
                        std::stringstream time;
                        time << mktime(&date);
                        initialValueStr = time.str();
@@ -133,7 +133,7 @@ void CallHistoryFilter::visitAttributeRange(std::string& attrName, AnyPtr& initi
 
        if (endValue != NULL) {
                if(endValue->getType() == PrimitiveType_Time) {
-                       tm date = DPL::DynamicPointerCast< Any_T<tm> >(endValue)->getValue();
+                       tm date = endValue->getDateTm();
                        std::stringstream time;
                        time << mktime(&date);
                        endValueStr = time.str();
@@ -181,36 +181,39 @@ std::string CallHistoryFilter::convertAttribute(std::string &name, AnyPtr& value
 {
        std::string query("");
        if (name.compare("direction") == 0) {
-               if (value->toString().compare("received") == 0) {
+               if (value->toString().compare(STR_RECEIVED) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_ANSWERED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_ANSWERED + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("dialed") == 0) {
+               } else if (value->toString().compare(STR_DIALED) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_OUTGOING + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_OUTGOING + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("missed") == 0) {
+               } else if (value->toString().compare(STR_MISSED) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_MISSED_CHECKED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_MISSED_CHECKED + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("missed-new") == 0) {
+               } else if (value->toString().compare(STR_MISSED_NEW) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_MISSED_UNCHECKED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_MISSED_UNCHECKED + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("rejected") == 0) {
+               } else if (value->toString().compare(STR_REJECTED) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_REJECTED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_REJECTED  + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("blocked") == 0) {
+               } else if (value->toString().compare(STR_BLOCKED) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_BLOCKED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_BLOCKED + STR_RIGHT_BRACKET;
                } else {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + "=0" + STR_RIGHT_BRACKET;
                }
-       } else if (name.compare("callType") == 0) {
-               if (value->toString().compare("tel") == 0) {
+       } else if (name.compare("tags") == 0) {
+               if (value->toString().compare(STR_CALL) == 0) {
+                       query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_GREATER_THAN + STR_EQUAL + STR_VOICE_ANSWERED + STR_AND
+                                       + STR_LOG_TYPE + STR_LESS_THAN + STR_EQUAL + STR_VIDEO_BLOCKED + STR_RIGHT_BRACKET;
+               } else if (value->toString().compare(STR_CALL_VOICE) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_ANSWERED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_OUTGOING + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_MISSED_UNCHECKED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_MISSED_CHECKED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_REJECTED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VOICE_BLOCKED + STR_RIGHT_BRACKET;
-               } else if (value->toString().compare("vt") == 0) {
+               } else if (value->toString().compare(STR_CALL_VIDEO) == 0) {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_ANSWERED + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_OUTGOING + STR_OR
                                        + STR_LOG_TYPE + STR_EQUAL + STR_VIDEO_MISSED_UNCHECKED + STR_OR
@@ -220,14 +223,14 @@ std::string CallHistoryFilter::convertAttribute(std::string &name, AnyPtr& value
                } else {
                        query = STR_LEFT_BRACKET + STR_LOG_TYPE + "=0" + STR_RIGHT_BRACKET;
                }
-       } else if (name.compare("remoteParty") == 0) {
+       } else if (name.compare("remoteParties.remoteParty") == 0) {
                query = STR_LEFT_BRACKET + STR_NUMBER + STR_EQUAL + STR_S_QUOTATION + value->toString() + STR_S_QUOTATION + STR_RIGHT_BRACKET;
-       } else if (name.compare("contactId") == 0) {
+       } else if (name.compare("remoteParties.contactId") == 0) {
                query = STR_LEFT_BRACKET + STR_CONTACT_ID + STR_EQUAL + STR_S_QUOTATION + value->toString() + STR_S_QUOTATION + STR_RIGHT_BRACKET;
        } else if (name.compare("startTime") == 0) {
                std::string dateStr ("");
                if(value->getType() == PrimitiveType_Time) {
-                       tm date = DPL::DynamicPointerCast< Any_T<tm> >(value)->getValue();
+                       tm date = value->getDateTm();
                        std::stringstream time;
                        time << mktime(&date);
                        dateStr = time.str();
index 99e4f76..d05c83a 100755 (executable)
 namespace TizenApis {
 namespace Platform {
 namespace Call {
+
+#define STR_TIZEN_TEL                  "tizen.tel"
+#define STR_TIZEN_XMPP                 "tizen.xmpp"
+#define STR_TIZEN_SIP                  "tizen.sip"
+
+#define STR_CALL                               "call"
+#define STR_CALL_VOICE                 "call.voice"
+#define STR_CALL_VIDEO                 "call.video"
+#define STR_TIZEN_EMERGENCY            "call.emergency"
+
+#define STR_DIALED                     "dialed"
+#define STR_RECEIVED                   "received"
+#define STR_MISSED_NEW                 "missed-new"
+#define STR_MISSED                     "missed"
+#define STR_REJECTED                   "rejected"
+#define STR_BLOCKED                    "blocked"
+
+#define STR_BASE_QUERY                 "SELECT id, log_type, related_id, number, log_time, data1 FROM phonelogs"
+
 class CallHistoryFilter: public Api::Tizen::IFilterVisitor
 {
 private:
@@ -43,9 +62,8 @@ public:
        void visitPostComposite(Api::Tizen::FilterType& type, int depth);
 
        void visitAttribute(std::string& attrName,
+                       Api::Tizen::MatchFlag& matchFlag,
                        Api::Tizen::AnyArrayPtr& values,
-                       std::string& matchFlag,
-                       bool caseSensitive,
                        int depth);
 
        void visitAttributeRange(std::string& attrName,
@@ -64,4 +82,4 @@ typedef DPL::SharedPtr<CallHistoryFilter> CallHistoryFilterPtr;
 }
 }
 }
-#endif
\ No newline at end of file
+#endif
diff --git a/src/platform/Tizen/Call/CallManager.cpp b/src/platform/Tizen/Call/CallManager.cpp
new file mode 100755 (executable)
index 0000000..0d5f77a
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * 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 <call.h>
+#include <dpl/log/log.h>
+#include <API/Account/AccountServices.h>
+#include "CallManager.h"
+
+using namespace WrtDeviceApis::Commons;
+using namespace TizenApis::Api::Call;
+using namespace TizenApis::Api::Account;
+using namespace DPL;
+
+namespace TizenApis {
+namespace Platform {
+namespace Call {
+
+CallManager::CallManager()
+{
+       if (tel_init() == TAPI_API_SUCCESS)
+               LogDebug("TAPI init success");
+}
+
+CallManager::~CallManager()
+{
+       tel_deinit();
+}
+
+bool CallManager::isCallInProgress()
+{
+       int ret;
+       call_state_e state;
+       bool result = false;
+
+       ret = call_get_voice_call_state(&state);
+
+       if (ret == CALL_ERROR_NONE) {
+               switch (state) {
+               case CALL_STATE_IDLE :
+                       result = false;
+                       break;
+               case CALL_STATE_CONNECTING:
+               case CALL_STATE_ACTIVE:
+                       result = true;
+                       break;
+               }
+       } else {
+               LogDebug("Call state changed cb error cause(" << ret << ")");
+       }
+
+       return result;
+
+}
+
+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->getServiceTypeId());
+               StringArrayPtr tags(filter->getTags());
+
+               if (typeId.compare("tizen.tel") != 0) {
+                       ThrowMsg(UnsupportedException, "Not supported value : serviceTypeId");
+               }
+
+               for (size_t cnt = 0; cnt < tags->size(); cnt++) {
+                       if (((*tags)[cnt]).compare("call") == 0
+                               ||((*tags)[cnt]).compare("call.voice") == 0
+                               || ((*tags)[cnt]).compare("call.video") == 0
+                               || ((*tags)[cnt]).compare("call.emergency") == 0)  {
+                               continue;
+                       } else {
+                               ThrowMsg(UnsupportedException, "Not supported value : tags");
+                       }
+               }
+
+               AccountServicesArrayPtr accountServicesList(new AccountServicesArray());
+               AccountServicesPtr callServices(new AccountServices());
+
+               callServices->setServiceTypeId("tizen.tel");
+               StringArrayPtr supportTags(new StringArray());
+               supportTags->push_back("call.voice");
+               supportTags->push_back("call.video");
+               supportTags->push_back("call.emergency");
+               callServices->setTags(*supportTags);
+
+               accountServicesList->push_back(callServices);
+               event->setResult(accountServicesList);
+
+               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
+       } catch (const UnsupportedException& ex) {
+               LogError("Exception: " << ex.GetMessage());
+               event->setExceptionCode(ExceptionCodes::UnsupportedException);
+               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
+       } catch (const PlatformException& ex) {
+               LogError("Exception: " << ex.GetMessage());
+               event->setExceptionCode(ExceptionCodes::PlatformException);
+               EventRequestReceiver<EventGetCallService>::ManualAnswer(event);
+       }
+}
+
+}
+}
+}
+
diff --git a/src/platform/Tizen/Call/CallManager.h b/src/platform/Tizen/Call/CallManager.h
new file mode 100755 (executable)
index 0000000..655b534
--- /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. 
+ */
+
+#ifndef TIZENAPIS_PLATFORM_CALLMANAGER_H_
+#define TIZENAPIS_PLATFORM_CALLMANAGER_H_
+
+#include <map>
+#include <vector>
+#include <dpl/shared_ptr.h>
+#include <dpl/noncopyable.h>
+#include <TapiCommon.h>
+#include <API/Call/ICallManager.h>
+#include <API/Call/CallFactory.h>
+#include <API/Call/EventGetCallService.h>
+#include <app.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Call {
+
+class CallManager : public Api::Call::ICallManager
+{
+public:
+       CallManager();
+       ~CallManager();
+
+       /**
+       * Tell whether is there is a call going on.
+       * @return true if there is at least one call in the following states:
+       * 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);
+
+};
+
+}
+}
+}
+
+#endif
diff --git a/src/platform/Tizen/Call/CallService.cpp b/src/platform/Tizen/Call/CallService.cpp
new file mode 100755 (executable)
index 0000000..34b7f48
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * 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 "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("tel://");
+               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, "com.samsung.phone"); //org.tizen.phone
+
+               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
new file mode 100755 (executable)
index 0000000..899fb18
--- /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. 
+ */
+
+#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 44b9422..ce5e904 100755 (executable)
@@ -1,21 +1,33 @@
 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)
 pkg_search_module(capicallhistory REQUIRED capi-social-call-log)
+pkg_search_module(capi-appfw-application REQUIRED capi-appfw-application)
 pkg_search_module(glib REQUIRED glib-2.0)
 pkg_search_module(libpcrecpp REQUIRED libpcrecpp)
 
 
 set(INCLUDES_PLATFORM_IMPLEMENTATION_CALL
+  ${account_INCLUDE_DIRS}
+  ${tapi_INCLUDE_DIRS}
   ${contacts-service_INCLUDE_DIRS}
+  ${capicall_INCLUDE_DIRS}
   ${capicallhistory_INCLUDE_DIRS}
+  ${capi-appfw-application_INCLUDE_DIRS}  
   ${glib_INCLUDE_DIRS}
   ${libpcrecpp_INCLUDE_DIRS}
   PARENT_SCOPE
 )
 
 set(LIBS_PLATFORM_IMPLEMENTATION_CALL
+  ${account_LIBRARIES}
+  ${tapi_LIBRARIES}
   ${contacts-service_LIBRARIES}
+  ${capicall_LIBRARIES}
   ${capicallhistory_LIBRARIES}
+  ${capi-appfw-application_LIBRARIES}  
   ${glib_LIBRARIES}
   ${libpcrecpp_LIBRARIES}
   PARENT_SCOPE
@@ -23,7 +35,10 @@ set(LIBS_PLATFORM_IMPLEMENTATION_CALL
 
 set(SRCS_PLATFORM_IMPLEMENTATION_CALL
   ${CURRENT_PATH}/CallHistory.cpp
+  ${CURRENT_PATH}/CallHistoryEntry.cpp
   ${CURRENT_PATH}/CallHistoryFilter.cpp
   ${CURRENT_PATH}/CallHistoryQuery.c
+  ${CURRENT_PATH}/CallManager.cpp
+  ${CURRENT_PATH}/CallService.cpp
   PARENT_SCOPE
 )
index ac14b7a..6941586 100755 (executable)
@@ -62,23 +62,13 @@ static PropertyStructArray properties =
        {"isFavorite",                          PrimitiveType_Boolean},
        {"ringtoneURI",                         PrimitiveType_String},
        {"categories",                          PrimitiveType_String},
-       {0,     PrimitiveType_Notype}
-};
-
-static MatchFlagStrArray matchFlag
-{
-       "EXACTLY",
-       "CONTAINS",
-       "STARTSWITH",
-       "ENDSWITH",
-       "EXISTS",
-       0
+       {0,     PrimitiveType_NoType}
 };
 
 FilterValidatorPtr ContactFilterValidatorFactory::getContactFilterValidator()
 {
     static FilterValidatorPtr theInstance =
-               FilterValidatorPtr(new FilterValidator(properties, matchFlag));
+               FilterValidatorPtr(new FilterValidator(properties));
     return theInstance;
 }
 
index e19183c..a6e8b9e 100755 (executable)
@@ -398,27 +398,27 @@ void ContactSearchEngine::visitPostComposite(FilterType& type, int depth)
        query_set_condition_append(m_contact_query_service, RIGHT_BRACKET);
 }
 
-void ContactSearchEngine::visitAttribute(string& attrName, AnyArrayPtr& matchValues, string& matchFlag, bool caseSensitive, int depth)
+void ContactSearchEngine::visitAttribute(string& attrName, MatchFlag& matchFlag, AnyArrayPtr& matchValues, int depth)
 {
        contact_attribute_e attr;
        attr = getPlatformAttr(attrName);
 
        string matchValueStr;
 
-       if(matchFlag == "EXISTS")
+       if(matchFlag == MATCH_EXISTS)
        {
                query_set_condition(m_contact_query_service, attr, EXISTS, NULL);
        }
-       else if(attrName == "id" && (matchFlag == "" || matchFlag == "EXACTLY"))
+       else if(attrName == "id" && matchFlag == MATCH_EXACTLY)
        {
                visitAttributeID(matchValues);
        }
        else if(matchValues->size() == 1)
        {
                condition_e cond;
-               if(matchFlag == "EXACTLY")
+               if(matchFlag == MATCH_EXACTLY)
                        cond = EQUAL;
-               else if (matchFlag == "STARTSWITH" || matchFlag == "ENDSWITH")
+               else if (matchFlag == MATCH_STARTSWITH || matchFlag == MATCH_ENDSWITH)
                        cond = LIKE;
                else
                        cond = EQUAL;
@@ -430,9 +430,9 @@ void ContactSearchEngine::visitAttribute(string& attrName, AnyArrayPtr& matchVal
        else if(matchValues->size() > 1)
        {
                condition_e cond;
-               if(matchFlag == "EXACTLY")
+               if(matchFlag == MATCH_EXACTLY)
                        cond = EQUAL;
-               else if (matchFlag == "STARTSWITH" || matchFlag == "ENDSWITH")
+               else if (matchFlag == MATCH_STARTSWITH || matchFlag == MATCH_ENDSWITH)
                        cond = LIKE;
                else
                        cond = EQUAL;
@@ -459,9 +459,9 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV
        string initialValueStr;
        string endValueStr;
 
-       if(initialValue->getType() == PrimitiveType_Time)
+       if(initialValue->isType(PrimitiveType_Time))
        {
-               tm date = DPL::DynamicPointerCast< Any_T<tm> >(initialValue)->getValue();
+               tm date = initialValue->getDateTm();
                initialValueStr = toDateDbStr(date);
        }
        else
@@ -469,9 +469,9 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV
                initialValueStr = initialValue->toString();
        }
 
-       if(endValue->getType() == PrimitiveType_Time)
+       if(endValue->isType(PrimitiveType_Time))
        {
-               tm date = DPL::DynamicPointerCast< Any_T<tm> >(endValue)->getValue();
+               tm date = endValue->getDateTm();
                endValueStr = toDateDbStr(date);
        }
        else
@@ -490,9 +490,9 @@ void ContactSearchEngine::visitAttributeRange(string& attrName, AnyPtr& initialV
 void ContactSearchEngine::visitAttributeEach(contact_attribute_e attr, AnyPtr& matchValue, condition_e flag)
 {
        string valueStr;
-       if(matchValue->getType() == PrimitiveType_Time)
+       if(matchValue->isType(PrimitiveType_Time))
        {
-               tm date = DPL::DynamicPointerCast< Any_T<tm> >(matchValue)->getValue();
+               tm date = matchValue->getDateTm();
                valueStr = toDateDbStr(date);
        }
        else
index 825e649..ff8fc42 100755 (executable)
@@ -65,9 +65,8 @@ public:
        virtual void visitInComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
        virtual void visitPostComposite(TizenApis::Api::Tizen::FilterType& type, int depth);
        virtual void visitAttribute(std::string& attrName,
+                       TizenApis::Api::Tizen::MatchFlag& matchFlag,
                        TizenApis::Api::Tizen::AnyArrayPtr& matchValues,
-                       std::string& matchFlag,
-                       bool caseSensitive,
                        int depth);
        virtual void visitAttributeRange(std::string& attrName,
                        TizenApis::Api::Tizen::AnyPtr& initialValue,
diff --git a/src/platform/Tizen/Mediacontent/MediaFilterValidator.cpp b/src/platform/Tizen/Mediacontent/MediaFilterValidator.cpp
new file mode 100755 (executable)
index 0000000..2132e58
--- /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 "MediaFilterValidator.h"
+#include <dpl/log/log.h>
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent{
+
+static PropertyStructArray folderProperties =
+{
+       {"id",                                  PrimitiveType_String},
+       {"folderURL",                   PrimitiveType_String},
+       {"storageType",                 PrimitiveType_String},
+       {"title",                               PrimitiveType_String},
+       {"modifiedDate",                PrimitiveType_Time},
+       {0,     PrimitiveType_NoType}
+};
+
+static PropertyStructArray mediaProperties =
+{
+       {"folder.id",                   PrimitiveType_String},
+       {"folder.title",                PrimitiveType_String},
+       {"folder.folderURL",    PrimitiveType_String},
+       {"folder.storageType",  PrimitiveType_String},
+       {"id",                                  PrimitiveType_String},
+       {"type",                                PrimitiveType_String},
+       {"mimeType",                    PrimitiveType_String},
+       {"title",                               PrimitiveType_String},
+       {"fileURL",                             PrimitiveType_String},
+       {"thumbnailURL",                PrimitiveType_String},
+       {"description",                 PrimitiveType_String},  
+       {"rating",                              PrimitiveType_Int},     
+       {"fileURL",                             PrimitiveType_String},
+       {"createdDate",                 PrimitiveType_Time},
+       {"releasedDate",                PrimitiveType_Time},
+       {"modifiedDate",                PrimitiveType_Time},
+       {"geolocation.latitude",        PrimitiveType_Double},
+       {"geolocation.longitude",       PrimitiveType_Double},  
+       {"album",                               PrimitiveType_String},  
+       {"artist",                              PrimitiveType_String},  
+       {"width",                               PrimitiveType_String},  
+       {"height",                              PrimitiveType_String},          
+       {"playedTime",                  PrimitiveType_Long},            
+       {"playCount",                   PrimitiveType_Long},            
+       {"genre",                               PrimitiveType_String},                  
+       {"artist",                              PrimitiveType_String},                          
+       {0,     PrimitiveType_NoType}
+};
+
+FilterValidatorPtr MediaFilterValidatorFactory::getMediaFilterValidator(QueryType value)
+{
+       static FilterValidatorPtr theFolderInstance;
+       static FilterValidatorPtr theMediaInstance;
+
+    if(value == QUERY_FOLDER)
+    {
+           theFolderInstance = FilterValidatorPtr(new FilterValidator(folderProperties));
+           return theFolderInstance;
+       }
+       else if(value == QUERY_MEDIA)
+       {
+               theMediaInstance = FilterValidatorPtr(new FilterValidator(mediaProperties));
+               return theMediaInstance;
+       }
+          
+   
+}
+
+} // Media
+} // Platform
+} // TizenApis
diff --git a/src/platform/Tizen/Mediacontent/MediaFilterValidator.h b/src/platform/Tizen/Mediacontent/MediaFilterValidator.h
new file mode 100755 (executable)
index 0000000..bf3b70d
--- /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 _PLATFORM_MEDIA_CONTENT_FILTER_VALIDATOR_H_
+#define _PLATFORM_MEDIA_CONTENT_FILTER_VALIDATOR_H_
+
+#include <API/Filter/FilterValidator.h>
+
+
+using namespace TizenApis::Api::Tizen;
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+
+       
+class MediaFilterValidatorFactory : private DPL::Noncopyable
+{
+       public:
+       typedef enum _QueryType
+       {
+               QUERY_FOLDER, 
+               QUERY_MEDIA 
+       }QueryType;
+       
+private:
+       MediaFilterValidatorFactory()
+       {
+       }
+
+public:
+       static FilterValidatorPtr getMediaFilterValidator(QueryType value);
+};
+
+} // Mediacontent
+} // Platform
+} // TizenApis
+
+#endif // _PLATFORM_MEDIA_CONTENT_FILTER_VALIDATOR_H_
\ No newline at end of file
diff --git a/src/platform/Tizen/Mediacontent/MediaSearchVisitor.cpp b/src/platform/Tizen/Mediacontent/MediaSearchVisitor.cpp
new file mode 100755 (executable)
index 0000000..078f524
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+* 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 "time.h"
+#include <iomanip>
+#include <Commons/Exception.h>
+#include "MediaSearchVisitor.h"
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+
+const string STR_LEFT_BRACKET(" (");
+const string STR_RIGHT_BRACKET(") ");
+const string STR_AND(" AND ");
+const string STR_OR(" OR ");
+const string STR_GREATER_THAN (">");
+const string STR_LESS_THAN ("<");
+const string STR_EQUAL ("=");
+const string STR_S_QUOTATION ("'");
+const string STR_PERCENT ("%");
+
+
+
+
+typedef enum
+{
+       MEDIA_ID = 0,
+       MEDIA_TITLE,
+       MEDIA_FILEPATH,
+       MEDIA_THUMBNAILPATH,
+       MEDIA_CREATEDDATE,
+       MEDIA_MODIFIEDDATE,
+       MEDIA_DESCRIPTION,
+       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"},
+               {"folderURL",           "folder_path"},
+               {"title",                       "title"},
+               {"storageType",         "storage_type"},                
+               {"modifiedDate",        "modified_date"},                               
+};
+
+map<string, string> MediaSearchVisitor::attrMediaEnumMap = {
+//media folder attributes.
+               {"folder.id",                   "folder_uuid"},
+               {"folder.title",                "folder_name"},         
+               {"folder.folderURL",    "folder_path"},
+               {"folder.storageType",  "storage_type"},        
+//media item attribues.
+               {"id",                          "media_uuid"},
+               {"type",                        "content_type"},
+//             {"mimeType",            "mime_type"},
+               {"title",                       "display_name"},                
+               {"fileURL",                     "path"},
+               {"thumbnailURL",        "thumbnail_path"},              
+               {"description",         "description"},         
+               {"rating",                      "rating"},      
+               {"createdDate",         "created_date"},        
+               {"releasedDate",        "released_date"},       
+               {"modifiedDate",        "modified_date"},                       
+//media image,video,audio attribues.
+               {"geolocation.latitude",        "latitude"}, 
+               {"geolocation.longitude",       "longitude"}, 
+               {"album",                       "album"}, 
+               {"artist",                      "artist"}, 
+               {"width",                       "width"}, 
+               {"height",                      "height"},
+               {"playedTime",          "last_played_time"},            
+               {"playCount",           "played_count"},                
+               {"genre",                       "genre"},
+               {"artist",                      "artist"},
+};
+
+
+MediaSearchVisitor::MediaSearchVisitor()
+{
+
+}
+
+MediaSearchVisitor::~MediaSearchVisitor()
+{
+
+}
+
+void MediaSearchVisitor::visitPreComposite(FilterType& type, int depth)
+{
+       m_query = m_query + STR_LEFT_BRACKET;
+}
+
+void MediaSearchVisitor::visitInComposite(FilterType& type, int depth)
+{
+       if(type == UNION_FILTER)
+               m_query = m_query + STR_OR;
+       else if(type == INTERSECTION_FILTER)
+               m_query = m_query + STR_AND;
+}
+
+void MediaSearchVisitor::visitPostComposite(FilterType& type, int depth)
+{
+       m_query = m_query + STR_RIGHT_BRACKET;
+}
+
+
+string MediaSearchVisitor::getPlatformAttr(string attrName)
+{
+       string platformAttr;
+       map<string, string>::iterator pos;
+
+       if( queryType == QUERY_FOLDER)
+       {
+               pos = attrFolderEnumMap.find(attrName);
+               
+               if(attrFolderEnumMap.end() != pos)
+               {
+                       platformAttr = pos->second;
+               }
+               else
+               {
+                       ThrowMsg(UnsupportedException, "Attribute(" << attrName << ") is not supported.");
+               }
+       }
+       else if(queryType == QUERY_MEDIA)
+       {
+               pos = attrMediaEnumMap.find(attrName);
+               
+               if(attrMediaEnumMap.end() != pos)
+               {
+                       platformAttr = pos->second;
+               }
+               else
+               {
+                       ThrowMsg(UnsupportedException, "Attribute(" << attrName << ") is not supported.");
+               }
+
+       }
+       return platformAttr;
+}
+
+
+void MediaSearchVisitor::visitAttribute(string& attrName, MatchFlag& matchFlag, AnyArrayPtr& matchValues, int depth)
+{
+       string attrPlatform = getPlatformAttr(attrName);
+       if(matchValues == NULL)
+       {
+               return ;
+       }       
+
+       if(matchValues->size() == 1)
+       {
+               AnyPtr matchValue = matchValues->at(0);
+
+               m_query =  convertAttribute(attrPlatform, matchValue, matchFlag);
+       }
+       else if(matchValues->size() > 1)
+       {
+               AnyArray::iterator iter;
+               m_query.append(STR_LEFT_BRACKET);
+               for(iter = matchValues->begin(); iter != matchValues->end(); iter++)
+               {
+                       AnyPtr matchValue = *iter;
+                       if(iter != matchValues->begin())
+                       {
+                               m_query.append(STR_OR);
+                       }
+                       m_query.append(convertAttribute(attrPlatform, matchValue, matchFlag));
+               }
+               m_query.append(STR_RIGHT_BRACKET);
+       }
+}
+
+string MediaSearchVisitor::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;
+
+       return ss.str();
+}
+
+string MediaSearchVisitor::convertAttribute(string &attrName, AnyPtr& matchValue, MatchFlag& matchFlag)
+{
+       string valueStr;
+       string operatorStr;
+       string conditionStr;
+
+
+       condition_e cond;
+       string matchValueStr;
+
+       if(attrName.compare("content_type")==0)
+       {
+               if(matchValue->toString().compare("IMAGE")==0)
+                       matchValueStr = "1";
+               if(matchValue->toString().compare("VIDEO")==0)
+                       matchValueStr = "2";
+               if(matchValue->toString().compare("AUDIO")==0)
+                       matchValueStr = "3";                    
+               //Todo. another case throw the exeption.
+       }
+       else
+       {
+               matchValueStr = matchValue->toString();
+       }\r
+
+       if(matchValue->getType() == PrimitiveType_Time)
+       {
+               tm date = matchValue->getDateTm();
+               valueStr = toDateDbStr(date);
+               cond = EQUAL;
+       }
+       else
+       {
+               //STARTSWITH('%, ENDSWITH, EXISTS
+               //valueStr = matchValue->toString();
+       
+               ostringstream os;
+
+               if(matchFlag == MATCH_STARTSWITH)
+               {
+                       cond = LIKE;
+                       os << STR_S_QUOTATION << matchValueStr << STR_PERCENT << STR_S_QUOTATION;
+               }
+               else if( matchFlag == MATCH_ENDSWITH )
+               {
+                       cond = LIKE;
+                       os << STR_S_QUOTATION <<  STR_PERCENT << matchValueStr << STR_S_QUOTATION;
+               }
+               else if(  matchFlag ==  MATCH_CONTAINS )
+               {
+                       cond = LIKE;
+                       os << STR_S_QUOTATION <<  STR_PERCENT << matchValueStr << STR_PERCENT << STR_S_QUOTATION;
+               }
+               else
+               {
+                       cond = EQUAL;
+                       os << STR_S_QUOTATION << matchValueStr << STR_S_QUOTATION;
+               }
+               
+               valueStr = os.str();
+       
+       }
+       operatorStr = operatorKey[cond];
+
+       conditionStr = STR_LEFT_BRACKET + attrName + operatorStr + valueStr + STR_RIGHT_BRACKET;
+
+       return conditionStr;
+}
+
+
+void MediaSearchVisitor::visitAttributeRange(string& attrName,AnyPtr& initialValue,AnyPtr& endValue,int depth)
+{
+
+       string str;
+       string initialValueStr;
+       string endValueStr;
+
+
+       if(initialValue != NULL) 
+       {
+               if(initialValue->getType() == PrimitiveType_Time) 
+               {
+                       tm date = initialValue->getDateTm();
+                       std::stringstream time;
+                       time << mktime(&date);
+                       initialValueStr = time.str();
+               } 
+               else 
+               {
+                       initialValueStr = initialValue->toString();
+               }
+       }
+
+       if (endValue != NULL) 
+       {
+               if(endValue->getType() == PrimitiveType_Time) 
+               {
+                       tm date = endValue->getDateTm();
+                       std::stringstream time;
+                       time << mktime(&date);
+                       endValueStr = time.str();
+
+               }
+               else 
+               {
+                       endValueStr = endValue->toString();
+               }
+       }
+
+       if (initialValue != NULL && endValue == NULL) 
+       {
+               str = STR_LEFT_BRACKET + attrName + STR_GREATER_THAN + STR_EQUAL + STR_S_QUOTATION + initialValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
+       }
+       else if(initialValue == NULL && endValue != NULL) 
+       {
+               str = STR_LEFT_BRACKET + attrName + STR_LESS_THAN + STR_S_QUOTATION + endValueStr + STR_S_QUOTATION + STR_RIGHT_BRACKET;
+       } 
+       else if (initialValue != NULL && endValue != NULL) 
+       {
+               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;
+       }
+
+       m_query = str;
+
+}
+
+string MediaSearchVisitor::getResult() const
+{
+       return m_query;
+}      
+
+void MediaSearchVisitor::setQueryType(QueryType value)
+{
+       queryType = value;
+}
+
+
+
+
+} // Contact
+} // Platform
+} // TizenApis
diff --git a/src/platform/Tizen/Mediacontent/MediaSearchVisitor.h b/src/platform/Tizen/Mediacontent/MediaSearchVisitor.h
new file mode 100755 (executable)
index 0000000..fcb0046
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+* 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 _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_
+#define _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_
+
+#include <map>
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <API/Filter/IFilter.h>
+#include <API/Filter/IFilterVisitor.h>
+#include <API/Filter/SortMode.h>
+
+#include <API/Mediacontent/IMediacontent.h>
+
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace std;
+
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+       
+typedef enum
+{
+       EQUAL,
+       NOT_EQUAL,
+       GREATER_THAN,
+       LESS_THAN,
+       GREATER_THAN_OR_EQUAL,
+       LESS_THAN_OR_EQUAL,
+       LIKE,
+       EXISTS,
+       CONDITION_MAX
+}condition_e;
+
+static string operatorKey[] =
+{
+       " = ",
+       " != ",
+       " > ",
+       " < ",
+       " >= ",
+       " <= ",
+       " like "
+};
+
+class MediaSearchVisitor : public TizenApis::Api::Tizen::IFilterVisitor
+{
+public:
+       typedef enum _QueryType { QUERY_FOLDER, QUERY_MEDIA } QueryType;
+
+       
+       MediaSearchVisitor();
+       virtual ~MediaSearchVisitor();
+
+       virtual void visitPreComposite(FilterType& type, int depth);
+       virtual void visitInComposite(FilterType& type, int depth);
+       virtual void visitPostComposite(FilterType& type, int depth);
+       virtual void visitAttribute(string& attrName, MatchFlag& matchFlag, AnyArrayPtr& matchValues, int depth);
+       virtual void visitAttributeRange(string& attrName,AnyPtr& initialValue,AnyPtr& endValue,int depth);
+
+       string getPlatformAttr(string attrName);
+       string getResult() const;
+
+       void setQueryType(QueryType value);
+       
+private:
+       string toDateDbStr(const tm &date) const;
+       string convertAttribute(string &attrname, AnyPtr& matchValue, MatchFlag& matchFlag);
+               
+private:
+       QueryType queryType;
+       string m_query; 
+       static map<string, string> attrFolderEnumMap;
+       static map<string, string> attrMediaEnumMap;
+
+};
+
+typedef DPL::SharedPtr<MediaSearchVisitor> MediaSearchVisitorPtr;
+
+} // Mediacontent
+} // Platform
+} // TizenApis
+
+#endif // _PLATFORM_MEDIA_CONTENT_SEARCH_VISITOR_H_
diff --git a/src/platform/Tizen/Mediacontent/MediaWrapper.cpp b/src/platform/Tizen/Mediacontent/MediaWrapper.cpp
new file mode 100644 (file)
index 0000000..b99d3f7
--- /dev/null
@@ -0,0 +1,136 @@
+/*
+* 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 <string.h>
+#include <algorithm>
+#include <pcrecpp.h>
+#include <dpl/log/log.h>
+#include <Commons/Exception.h>
+#include "MediaWrapper.h"
+#include "Mediacontent.h"
+
+using namespace WrtPlugins::Api;
+
+
+
+namespace WrtPlugins {
+namespace Platform {
+MediaWrapper::MediaWrapper() :
+    m_platformEvent(NULL),
+    m_abstractEvent(NULL)
+{
+    LogDebug("entered");
+    m_abstractEvent = CalendarEventPtr(new CalendarEvent());
+    if (!m_abstractEvent) {
+        ThrowMsg(Commons::UnknownException, "abstract object is not created");
+    }
+}
+
+MediaWrapper::MediaWrapper(media_info_h media) :
+    m_platformEvent(NULL),
+    m_abstractEvent(event)
+{
+    LogDebug("entered");
+}
+
+MediaWrapper::MediaWrapper()
+{
+    LogDebug("entered");
+    freePlatformEvent();
+}
+
+void EventWrapper::displayAbstractEvent()
+{
+    m_abstractEvent->display();
+}
+
+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(
+                 m_platformEvent, CAL_VALUE_GMT_START_DATE_TIME,
+                 CAL_TZ_FLAG_GMT));
+    LogDebug("event end time: " << calendar_svc_struct_get_time(m_platformEvent,
+                                                                CAL_VALUE_GMT_END_DATE_TIME,
+                                                                CAL_TZ_FLAG_GMT));
+    LogDebug("event location: " << calendar_svc_struct_get_str(m_platformEvent,
+                                                               CAL_VALUE_TXT_LOCATION));
+    LogDebug("event summary: " << calendar_svc_struct_get_str(m_platformEvent,
+                                                              CAL_VALUE_TXT_SUMMARY));
+    LogDebug("event description: " << calendar_svc_struct_get_str(
+                 m_platformEvent, CAL_VALUE_TXT_DESCRIPTION));
+
+    LogDebug("event isAllDay: " << calendar_svc_struct_get_int(
+                 m_platformEvent, CAL_VALUE_INT_ALL_DAY_EVENT));
+    LogDebug("event organizer: " << calendar_svc_struct_get_str(m_platformEvent,
+                                                               CAL_VALUE_TXT_ORGANIZER_NAME));
+    LogDebug("event lastModifiedDate: " << calendar_svc_struct_get_time(
+                 m_platformEvent, CAL_VALUE_GMT_LAST_MODIFIED_TIME,
+                 CAL_TZ_FLAG_GMT));
+    LogDebug("event visibility: " << calendar_svc_struct_get_int(
+                 m_platformEvent, CAL_VALUE_INT_SENSITIVITY));    
+    LogDebug("event availability: " << calendar_svc_struct_get_int(
+                 m_platformEvent, CAL_VALUE_INT_BUSY_STATUS));
+
+    GList *categoryList = NULL;
+    if (CAL_SUCCESS != calendar_svc_struct_get_list(m_platformEvent,
+                                     CAL_VALUE_LST_MEETING_CATEGORY,
+                                     &categoryList)) {
+        LogError("cannot read category list");
+        return;
+    }
+    cal_value* category = NULL;
+    for (; categoryList; categoryList = g_list_next(categoryList)) {
+        category = static_cast<cal_value*>(categoryList->data);
+        char* categoryName = calendar_svc_value_get_str(category, "category_name");
+        if (NULL == categoryName) {
+            LogError("cannot read category name");
+            return;
+        }
+        LogDebug("event categories: " << categoryName);
+    }
+
+    LogDebug("event uid: " << calendar_svc_struct_get_str(m_platformEvent,
+                                                               CAL_VALUE_TXT_UID));
+    LogDebug("event recurrenceId: " << calendar_svc_struct_get_time(
+                 m_platformEvent, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_GMT));
+
+    GList *attendees = NULL;
+    if (CAL_SUCCESS != calendar_svc_struct_get_list(m_platformEvent,
+                                     CAL_VALUE_LST_ATTENDEE_LIST,
+                                     &attendees)) {
+        LogError("cannot read attendee list");
+        return;
+    }
+    cal_value* attendee = NULL;
+    for (; attendees; attendees = g_list_next(attendees)) {
+        attendee = static_cast<cal_value*>(attendees->data);
+        char* attendeeName = calendar_svc_value_get_str(attendee, CAL_VALUE_TXT_ATTENDEE_DETAIL_NAME);
+        if (NULL == attendeeName) {
+            LogError("cannot read attendee name");
+            return;
+        }
+        LogDebug("event attendees: " << attendeeName);
+    }
+
+    LogDebug("event repeat frequency: " << calendar_svc_struct_get_int(
+                 m_platformEvent, CAL_VALUE_INT_REPEAT_TERM));
+}
+
+}
+}
diff --git a/src/platform/Tizen/Mediacontent/MediaWrapper.h b/src/platform/Tizen/Mediacontent/MediaWrapper.h
new file mode 100644 (file)
index 0000000..c33dac8
--- /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 _SLP20_MEDIA_WRAPPER_H_
+#define _SLP20_MEDIA_WRAPPER_H_
+
+#include <string>
+#include <dpl/shared_ptr.h>
+#include <media_content.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+
+
+namespace WrtPlugins {
+namespace Platform {
+class MediaWrapper
+{
+  public:
+    MediaWrapper();
+    explicit MediaWrapper(media_info_h media);
+    virtual ~MediaWrapper();
+
+  private:
+    void displayAbstractMedia();     //only for debugging
+    void displayPlatformMedia();     //only for debugging
+
+    Api::MediacontentMediaPtr m_media;
+};
+
+}
+}
+#endif /* _SLP20_EVENT_WRAPPER_H_ */
diff --git a/src/platform/Tizen/Mediacontent/Mediacontent.cpp b/src/platform/Tizen/Mediacontent/Mediacontent.cpp
new file mode 100644 (file)
index 0000000..06a7ceb
--- /dev/null
@@ -0,0 +1,715 @@
+/*
+* 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 "Mediacontent.h"
+#include "MediacontentManager.h"
+#include "MediaFilterValidator.h"
+#include "MediaSearchVisitor.h"
+
+#include <mm_file.h>
+#include <mm_error.h>
+
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+
+#define MEDIA_DEBUG 0
+
+const string SELECT_FOLDER_QUERY = 
+       "select uuid, path, title, storage_type,modified_date from (select uuid, path, folder_name as title, storage_type,modified_date from visual_folder where valid=1 union select _id, path, folder_name as title, storage_type,modified_date from audio_folder) where 1 ";
+
+const string VIEW_MEDIA_QUERY_WITH_FOLDER =
+       "select 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, folder_name, folder_path from \
+(select media_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 from visual_media join \
+       (select * from \
+               (select media_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 \
+               union all \
+               select media_uuid, longitude, latitude, description, width, height, datetaken as released_date, null as orientation, album, artist, last_played_time,duration from video_meta)) \
+on uuid=media_uuid \
+union all \
+       select audio_id, folder_id 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 from audio_media) \
+join ( select uuid as folder_id, path as folder_path, folder_name, modified_date as folder_modified_date, storage_type from visual_folder \
+union all \
+       select _id as folder_id, path, folder_name, modified_date, storage_type from audio_folder) \
+on folder_uuid=folder_id where 1 ";
+
+const string SELECT_MEDIA_ID_WITH_FOLDER = 
+       "select item_id from item_view where folder_uuid=";
+const string SELECT_EXTRA_AUDIO = 
+       "select copyright,bitrate,track_num,size from audio_media where audio_id=";
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent{
+
+Mediacontent::Mediacontent()
+{
+    LogDebug("entered");
+
+//     int ret;
+
+       db_connnect_count++;
+
+       db_util_open(MEDIA_DB_PATH, &hDBCt, 0);
+       LogDebug("hDBCt:" << hDBCt);            
+}
+
+Mediacontent::~Mediacontent()
+{
+    LogDebug("entered");
+       int ret;
+       db_connnect_count--;
+       if(db_connnect_count == 0)
+       {
+               ret = db_util_close(hDBCt);
+               if(ret != SQLITE_OK)
+                       ret = -1;
+               else
+                       hDBCt = NULL;
+       }
+}
+
+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);
+
+       return tm_date;
+}      
+
+
+void Mediacontent::convertToPlatformFolder(folder_s &media_folder, MediacontentFolderPtr& newFolder)
+{
+       if(media_folder.folder_uuid != NULL)
+       {
+               newFolder->setFolderUUID(media_folder.folder_uuid);
+       }
+       if(media_folder.folder_path != NULL)
+       {
+               newFolder->setFolderName(media_folder.folder_name);
+       }
+       if(media_folder.folder_name != NULL)
+       {
+               newFolder->setFolderPath(media_folder.folder_path);
+       }
+
+       newFolder->setFolderModifiedDate(toDateTm(media_folder.modified_date));
+
+       string storageType;
+       
+       if(media_folder.storage_type == 0)
+       {
+               storageType = "INTERNAL";
+       }
+       else if( media_folder.storage_type == 1)
+       {
+               storageType = "EXTERNAL";
+       }
+       else
+       {
+               storageType = "UNKNOWN";
+       }
+       newFolder->setFolderStorageType(storageType);
+}
+
+
+
+string Mediacontent::makeQuerySortMode(SortModeArrayPtr attr)
+{
+       string query("");
+       string attriName;
+       int cnt = 0;
+       SortModeArray::iterator it = attr->begin();
+       
+       for (;it!=attr->end(); ++it) 
+       {
+               attriName = (*it)->getAttributeName();
+               //convert to attribue's name
+               MediaSearchVisitor visitor;
+               attriName = visitor.getPlatformAttr(attriName);
+               if (attriName.compare("") != 0) 
+               { 
+                       if (cnt == 0) 
+                       {
+                               query.append(" ORDER BY ");
+                       } else 
+                       {
+                               query.append(", ");
+                       }
+                       query.append(attriName);
+
+                       if ((*it)->getOrder() == Api::Tizen::ASCENDING_SORT_ORDER) 
+                       {
+                               query.append(" ASC");
+                       } 
+                       else 
+                       {
+                               query.append(" DESC");
+                       }
+                       cnt++;
+               }
+       }
+
+       return query;
+}
+
+
+
+void Mediacontent::OnRequestReceived(const IEventFindFolderPtr &eFolder)
+{
+    LogDebug("entered");
+
+       string projection;
+       string sortMode;
+       string limitOffset;
+       string condition;
+       string query(SELECT_FOLDER_QUERY);
+
+       //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);
+
+               visitor->setQueryType(MediaSearchVisitor::QUERY_FOLDER);
+               filter->travel(IVisitor);
+               condition = visitor->getResult();
+
+               query.append(" and ");
+               query.append(condition);
+       }
+
+       if(eFolder->getSortModesIsSet()) 
+       {
+               sortMode = makeQuerySortMode(eFolder->getSortModes());  
+
+               query.append(sortMode);
+       }
+       
+       //set limit/offset
+       if (eFolder->getLimitIsSet()) 
+       {
+               limitOffset.append(" LIMIT ");
+               std::stringstream limitStream;
+               limitStream << eFolder->getLimit();
+               limitOffset.append(limitStream.str());
+               if(eFolder->getOffsetIsSet()) 
+               {
+                       limitOffset.append(" OFFSET ");
+                       std::stringstream offsetStream;
+                       offsetStream << eFolder->getOffset();
+                       limitOffset.append(offsetStream.str());
+               }
+
+               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);
+               while( sqlite3_step(pStmt) == SQLITE_ROW)
+               {
+                       media_folder.folder_uuid = (char *)sqlite3_column_text(pStmt, 0);
+                       media_folder.folder_path = (char *)sqlite3_column_text(pStmt, 1);
+                       media_folder.folder_name = (char *)sqlite3_column_text(pStmt, 2);
+                       media_folder.storage_type = sqlite3_column_int(pStmt, 3);
+                       media_folder.modified_date = sqlite3_column_int(pStmt, 4);      
+
+                       MediacontentFolderPtr newFolder(new MediacontentFolder());
+                       convertToPlatformFolder(media_folder, newFolder);
+
+                       string queryMediaId(SELECT_MEDIA_ID_WITH_FOLDER);
+                       queryMediaId.append("'");
+                       queryMediaId.append(media_folder.folder_uuid);
+                       queryMediaId.append("'");
+                       sqlite3_stmt* pStmt1 = NULL;
+                       if(sqlite3_prepare_v2(hDBCt, (char *)(queryMediaId.c_str()), strlen((char *)(queryMediaId.c_str())), &pStmt1, NULL) == SQLITE_OK)
+                       {
+                               MediaIdListPtr newMediaIdList(new MediaIdList());
+                               //sqlite3_bind_text(pStmt1, 1, media_folder.folder_uuid,strlen(media_folder.folder_uuid), SQLITE_TRANSIENT);
+                               LogDebug("execute 111111 [" << queryMediaId  << "]");
+                               while( sqlite3_step(pStmt1) == SQLITE_ROW)
+                               {
+                                       string mediaId = (char *)sqlite3_column_text(pStmt1, 0);
+                                       LogDebug("execute mediaId [" << mediaId << "]");
+                                       newMediaIdList->push_back(mediaId);
+                               }
+                               newFolder->setMediaIdList(newMediaIdList);
+                               sqlite3_finalize(pStmt1);
+                       }
+
+                       eFolder->addFolder(newFolder);
+               }
+               sqlite3_finalize(pStmt);
+               eFolder->setResult(true);
+
+       }
+       catch (const Exception &ex)
+       {
+               LogError("Exception: " << ex.DumpToString());
+               eFolder->setResult(false);
+       }
+       eFolder->setCancelAllowed(true);
+}
+
+
+void Mediacontent::OnRequestReceived(const IEventFindMediaPtr &eMedia)
+{
+    LogDebug("OnRequestReceived::IEventFindMediaPtr entered");
+
+       string projection;
+       string sortMode;
+       string limitOffset;
+       string condition;
+       
+       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);
+
+               if(!success)
+                       ThrowMsg(InvalidArgumentException, "Invalid filter arguments.");
+
+               IFilterVisitorPtr IVisitor = DPL::StaticPointerCast<IFilterVisitor>(visitor);
+
+               visitor->setQueryType(MediaSearchVisitor::QUERY_MEDIA);
+               filter->travel(IVisitor);
+               condition = visitor->getResult();
+               query.append(" and ");
+               query.append(condition);                
+       }
+
+       if(eMedia->getSortModesIsSet()) 
+       {
+               sortMode = makeQuerySortMode(eMedia->getSortModes());   
+
+               query.append(sortMode);
+       }
+       if (eMedia->getLimitIsSet()) 
+       {
+               limitOffset.append(" LIMIT ");
+               std::stringstream limitStream;
+               limitStream << eMedia->getLimit();
+               limitOffset.append(limitStream.str());
+               if(eMedia->getOffsetIsSet()) 
+               {
+                       limitOffset.append(" OFFSET ");
+                       std::stringstream offsetStream;
+                       offsetStream << eMedia->getOffset();
+                       limitOffset.append(offsetStream.str());
+               }
+
+               query.append(limitOffset);
+       }
+       
+       LogDebug("execute condition [" << condition << "]");
+       LogDebug("execute projection [" << projection << "]");
+       LogDebug("execute sortMode [" << sortMode << "]");
+       LogDebug("execute limitOffset [" << limitOffset << "]");        
+       LogDebug("execute query [" << query << "]");
+       
+
+       int ret;
+       
+    try
+       {
+               sqlite3_stmt* pStmt = NULL;
+               int content_type;
+               ret = sqlite3_prepare_v2(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)
+                       {
+
+                               MediacontentImage *newImage(new MediacontentImage());
+                               readImageFromDB(pStmt,newImage);
+                               eMedia->addMedia(newImage);
+                       }
+                       else if(content_type == MEDIA_TYPE_VIDEO)
+                       {
+                               MediacontentVideo *newVideo(new MediacontentVideo());
+                               readVideoFromDB(pStmt,newVideo);
+                               eMedia->addMedia(newVideo);
+                       }
+                       else if(content_type == MEDIA_TYPE_AUDIO)
+                       {
+                               MediacontentAudio *newVAudio(new MediacontentAudio());
+                               readAudioFromDB(pStmt,newVAudio);
+                               eMedia->addMedia(newVAudio);
+
+                       }
+
+               }
+               sqlite3_finalize(pStmt);
+               eMedia->setResult(true);
+
+       }
+    catch (const Exception &ex)
+    {
+        LogError("Exception: " << ex.DumpToString());
+        eMedia->setResult(false);
+    }
+
+    eMedia->setCancelAllowed(true);
+
+}
+
+
+void Mediacontent::OnRequestReceived(const IEventUpdateMediaPtr &eMedia)
+{
+    LogDebug("OnRequestReceived::IEventUpdateMediaPtr entered");
+
+       try
+       {
+               MediacontentMediaPtr mediaPtr = eMedia->getMediaItem();
+               string type  = mediaPtr->getMediaType();
+               
+               if(type.compare("IMAGE")==0)
+               {
+                       LogDebug("Image11");
+                       MediacontentImagePtr imagePtr = DPL::DynamicPointerCast<MediacontentImage>(mediaPtr);
+                       if(imagePtr != NULL)
+                       {
+                               LogDebug("Image22");
+                       }
+               }
+               if(type.compare("VIDEO")==0)
+               {
+                       LogDebug("Video11");
+                       MediacontentVideoPtr videoPtr = DPL::DynamicPointerCast<MediacontentVideo>(mediaPtr);
+                       if(videoPtr != NULL)
+                       {
+                               LogDebug("video22");
+                       }                       
+               }
+               if(type.compare("AUDIO")==0)
+               {
+                       LogDebug("Audio11");
+                       MediacontentAudioPtr audioPtr = DPL::DynamicPointerCast<MediacontentAudio>(mediaPtr);
+                       if(audioPtr != NULL)
+                       {
+                               LogDebug("audio22");
+                       }                       
+               }
+
+               eMedia->setResult(true);
+       }
+    catch (const Exception &ex)
+    {
+        LogError("Exception: " << ex.DumpToString());
+        eMedia->setResult(false);
+    }
+
+    eMedia->setCancelAllowed(true);
+
+}
+
+
+
+void Mediacontent::readImageFromDB(sqlite3_stmt* pStmt, MediacontentImage* newImage)
+{
+       char* tmp;
+       if(pStmt != NULL)
+       {
+
+               tmp = (char*)sqlite3_column_text(pStmt,0);
+               if( tmp != NULL)
+                       newImage->setMediaUUID(tmp);
+
+               newImage->setMediaType("IMAGE");
+       
+               //setMimeType //2
+               tmp = (char*)sqlite3_column_text(pStmt,3);
+               if( tmp != NULL)
+                       newImage->setDisplayName(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,4);
+               if( tmp != NULL)
+                       newImage->setFilePath(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,5);
+               if( tmp != NULL)
+                       newImage->setThumbnailPath(tmp);
+
+               newImage->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
+               newImage->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
+               newImage->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
+
+               tmp = (char*)sqlite3_column_text(pStmt,9);
+               if( tmp != NULL)
+                       newImage->setDescription(tmp);
+
+               newImage->setFavorite(sqlite3_column_int(pStmt,10));    
+               newImage->setImageLatitude(sqlite3_column_double(pStmt,15));
+               newImage->setImageLongitude(sqlite3_column_double(pStmt,16));   
+               newImage->setImageWidth(sqlite3_column_int(pStmt,17));
+               newImage->setImageHeight(sqlite3_column_int(pStmt,18));
+               int orientation = (sqlite3_column_int(pStmt,19));
+               string orientationStr;
+               switch(orientation)
+               {
+                       case 1: 
+                               orientationStr = "NORMAL";
+                               break;
+                       case 2: 
+                               orientationStr = "FLIP_HORIZONTAL";
+                               break;
+                       case 3: 
+                               orientationStr = "ROTATE_180";
+                               break;
+                       case 4: 
+                               orientationStr = "FLIP_VERTICAL";
+                               break;
+                       case 5: 
+                               orientationStr = "TRANSPOSE";
+                               break;
+                       case 6: 
+                               orientationStr = "ROTATE_90";
+                               break;
+                       case 7: 
+                               orientationStr = "TRANSVERSE";
+                               break;
+                       case 8: 
+                               orientationStr = "ROTATE_270";
+                               break;
+               }               
+               newImage->setImageOrientation(orientationStr);
+       }
+       
+}
+
+
+
+void Mediacontent::readVideoFromDB(sqlite3_stmt* pStmt, MediacontentVideo* newVideo)
+{
+       char* tmp;
+       if(pStmt != NULL)
+       {
+
+               tmp = (char*)sqlite3_column_text(pStmt,0);
+               if( tmp != NULL)
+                       newVideo->setMediaUUID(tmp);
+
+               newVideo->setMediaType("VIDEO");
+
+               //setMimeType 
+               tmp = (char*)sqlite3_column_text(pStmt,3);
+               if( tmp != NULL)
+                       newVideo->setDisplayName(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,4);
+               if( tmp != NULL)
+                       newVideo->setFilePath(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,5);
+               if( tmp != NULL)
+                       newVideo->setThumbnailPath(tmp);
+
+               newVideo->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
+               newVideo->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
+               newVideo->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
+
+               tmp = (char*)sqlite3_column_text(pStmt,9);
+               if( tmp != NULL)
+                       newVideo->setDescription(tmp);
+
+               newVideo->setFavorite(sqlite3_column_int(pStmt,10));    
+
+               tmp = (char*)sqlite3_column_text(pStmt,11);
+               if( tmp != NULL)
+                       newVideo->setVideoAlbum(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,12);
+               if( tmp != NULL)                        
+                       newVideo->setVideoArtist(tmp);
+
+               newVideo->setVideoPlayedTime(sqlite3_column_int(pStmt,13));     
+               newVideo->setVideoPlayCount(sqlite3_column_int(pStmt,14)); 
+
+               newVideo->setVideoLongitude(sqlite3_column_double(pStmt,15));   
+               newVideo->setVideoLatitude(sqlite3_column_double(pStmt,16));
+               
+               newVideo->setVideoWidth(sqlite3_column_int(pStmt,17));
+               newVideo->setVideoHeight(sqlite3_column_int(pStmt,18));
+       
+               newVideo->setVideoDuration(sqlite3_column_int(pStmt,22));
+
+       }               
+
+}
+
+void Mediacontent::readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAudio)
+{
+       char* tmp;
+       if(pStmt != NULL)
+       {
+
+               tmp = (char*)sqlite3_column_text(pStmt,0);
+               if( tmp != NULL)
+                       newAudio->setMediaUUID(tmp);
+
+               newAudio->setMediaType("AUDIO");
+
+               //setMimeType 
+               tmp = (char*)sqlite3_column_text(pStmt,3);
+               if( tmp != NULL)
+                       newAudio->setDisplayName(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,4);
+               if( tmp != NULL)
+                       newAudio->setFilePath(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,5);
+               if( tmp != NULL)
+                       newAudio->setThumbnailPath(tmp);
+
+               newAudio->setCreatedDate(toDateTm(sqlite3_column_int(pStmt,6)));
+               newAudio->setReleasedDate(toDateTm(sqlite3_column_int(pStmt,7)));
+               newAudio->setModifiedDate(toDateTm(sqlite3_column_int(pStmt,8)));
+
+               tmp = (char*)sqlite3_column_text(pStmt,9);
+               if( tmp != NULL)
+                       newAudio->setDescription(tmp);
+
+               newAudio->setFavorite(sqlite3_column_int(pStmt,10));    
+
+               tmp = (char*)sqlite3_column_text(pStmt,11);
+               if( tmp != NULL)
+                       newAudio->setAudioAlbum(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,12);
+               if( tmp != NULL)                        
+                       newAudio->setAudioArtist(tmp);
+
+               newAudio->setAudioPlayedTime(sqlite3_column_int(pStmt,13));     
+               newAudio->setAudioPlayCount(sqlite3_column_int(pStmt,14));
+
+               tmp = (char*)sqlite3_column_text(pStmt,20);
+               if( tmp != NULL)                        
+                       newAudio->setAudioGenre(tmp);
+
+               tmp = (char*)sqlite3_column_text(pStmt,21);
+               if( tmp != NULL)                        
+                       newAudio->setAudioComposer(tmp);
+
+               newAudio->setAudioDuration(sqlite3_column_int(pStmt,22));
+
+               string queryExtraAudio(SELECT_EXTRA_AUDIO);
+               queryExtraAudio.append("'");
+               queryExtraAudio.append(newAudio->getMediaUUID());
+               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)
+               {
+                       while( sqlite3_step(pStmt1) == SQLITE_ROW)
+                       {
+                               tmp = (char*)sqlite3_column_text(pStmt,0);
+                               if( tmp != NULL)                        
+                                       newAudio->setAudioCopyright(tmp);
+                               newAudio->setAudioBitrate(sqlite3_column_int(pStmt,1));
+                               newAudio->setAudioTrackNum(sqlite3_column_int(pStmt,2));
+                               newAudio->setAudioSize(sqlite3_column_int(pStmt,3));
+                       }
+                       sqlite3_finalize(pStmt1);
+               }
+
+               MMHandleType tag_attrs = 0;
+               LogDebug("AUDIO PATH: " << newAudio->getFilePath());
+               int ret = mm_file_create_tag_attrs(&tag_attrs, newAudio->getFilePath().c_str());
+
+               char *err_attr_name = NULL;
+               char* unSyncText;
+               int unSyncLen;
+               int syncTextNum;                
+               if (ret == MM_ERROR_NONE && tag_attrs) 
+               {
+                       ret = mm_file_get_attrs( tag_attrs,
+                                                                               &err_attr_name,
+                                                                               MM_FILE_TAG_UNSYNCLYRICS, &unSyncText, &unSyncLen,
+                                                                               MM_FILE_TAG_SYNCLYRICS_NUM, &syncTextNum,
+                                                                               NULL);          
+               }
+               if (ret != MM_ERROR_NONE &&  err_attr_name)
+               {
+                       MediacontentLyricsPtr lyricsPtr(new MediacontentLyrics());
+                       if(syncTextNum > 0)
+                       {
+                               lyricsPtr->setMediaLyricsType("SYNCHRONIZED");
+                               for(int i=0; i < syncTextNum; i++)
+                               {       
+                                       unsigned long time_info = 0;
+                                       char * lyrics_info = NULL;
+                                       mm_file_get_synclyrics_info(tag_attrs,i,&time_info,&lyrics_info);
+                                       lyricsPtr->addMediaLyricsTimeStamp(time_info);
+                                       lyricsPtr->addMediaLyricsText(lyrics_info);
+                                       LogDebug("SYNCHRONIZED: " << lyrics_info);
+                               }
+                       }
+                       else
+                       {
+                               LogDebug("UNSYNCHRONIZED: " << unSyncText);
+                               lyricsPtr->setMediaLyricsType("UNSYNCHRONIZED");
+                               lyricsPtr->addMediaLyricsTimeStamp(0);
+                               lyricsPtr->addMediaLyricsText(unSyncText);
+       
+                       }
+                       newAudio->setAudioLyrics(lyricsPtr);
+               }
+               
+       }
+
+}
+
+
+}
+}
+}
diff --git a/src/platform/Tizen/Mediacontent/Mediacontent.h b/src/platform/Tizen/Mediacontent/Mediacontent.h
new file mode 100644 (file)
index 0000000..ba2025a
--- /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. 
+*/
+
+
+
+#ifndef _PLATFORM_MEDIA_CONTENT_H_
+#define _PLATFORM_MEDIA_CONTENT_H_
+
+#include <list>
+#include <ctime>
+#include "API/Mediacontent/IMediacontent.h"
+#include "API/Mediacontent/IEventFindFolder.h"
+#include "API/Mediacontent/IEventFindMedia.h"
+#include "API/Mediacontent/IEventUpdateMedia.h"
+
+#include <API/Mediacontent/MediacontentImage.h>
+#include <API/Mediacontent/MediacontentVideo.h>
+#include <API/Mediacontent/MediacontentAudio.h>
+#include <API/Mediacontent/MediacontentLyrics.h>
+
+
+#include <db-util.h>
+
+#define MEDIA_DB_PATH "/opt/dbspace/.media.db"
+typedef struct _media_folder_s
+{
+       char* folder_uuid;
+       char* folder_path;
+       char* folder_name;
+       int storage_type;       
+       time_t modified_date;
+}folder_s;
+
+
+using namespace TizenApis::Api::Mediacontent;
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+
+class Mediacontent : public Api::Mediacontent::IMediacontent
+{
+
+       public:
+       Mediacontent();
+       virtual ~Mediacontent();
+
+       protected:
+       virtual void OnRequestReceived(const IEventFindMediaPtr &ptr);
+       virtual void OnRequestReceived(const IEventFindFolderPtr &ptr);
+       virtual void OnRequestReceived(const IEventUpdateMediaPtr &ptr);
+
+       private:
+       void convertToPlatformFolder(folder_s &media_folder, MediacontentFolderPtr& newFolder);
+       void readImageFromDB(sqlite3_stmt* pStmt, MediacontentImage* newImage);
+       void readVideoFromDB(sqlite3_stmt* pStmt, MediacontentVideo* newVideo);
+       void readAudioFromDB(sqlite3_stmt* pStmt, MediacontentAudio* newAudio);
+       tm toDateTm(time_t date);
+               
+       string makeQuerySortMode(SortModeArrayPtr attr);
+
+       private:
+       sqlite3 *hDBCt;
+       int db_connnect_count;
+
+};
+
+
+}
+}
+}
+
+#endif /* _PLATFORM_MEDIA_CONTENT_H_ */
diff --git a/src/platform/Tizen/Mediacontent/MediacontentManager.cpp b/src/platform/Tizen/Mediacontent/MediacontentManager.cpp
new file mode 100644 (file)
index 0000000..4804c5f
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+* 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 <algorithm>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/Converter.h>
+
+#include <vector>
+#include "MediacontentManager.h"
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+
+
+MediacontentManager::MediacontentManager()
+{
+    LogDebug("entered");
+}
+
+MediacontentManager::~MediacontentManager()
+{
+
+}
+
+void MediacontentManager::OnRequestReceived(const IEventGetMediacontentPtr &event)
+{
+       LogDebug( "OnRequestReceived::entered");
+    IMediacontentPtr newMediacontent(new Mediacontent());
+    Try
+    {
+               LogDebug( "got Mediacontent \n");
+               event->setMediacontent(newMediacontent);
+               event->setResult(true);
+    }
+    Catch(Exception)
+    {
+        LogError("error occuered during obtaining data");
+        event->setResult(false);
+    }
+    event->setCancelAllowed(true);
+}
+
+}
+}
+}
diff --git a/src/platform/Tizen/Mediacontent/MediacontentManager.h b/src/platform/Tizen/Mediacontent/MediacontentManager.h
new file mode 100644 (file)
index 0000000..b8a7913
--- /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 _PLATFORM_MEDIA_CONTENT_MANAGER_H_
+#define _PLATFORM_MEDIA_CONTENT_MANAGER_H_
+
+#include <vector>
+#include <list>
+#include <dpl/mutex.h>
+#include <API/Mediacontent/IMediacontentManager.h>
+#include "Mediacontent.h"
+
+namespace TizenApis {
+namespace Platform {
+namespace Mediacontent {
+
+class MediacontentManager : public Api::Mediacontent::IMediacontentManager
+{
+       public:
+       MediacontentManager();
+       virtual ~MediacontentManager();
+       
+       protected:
+       virtual void OnRequestReceived(const IEventGetMediacontentPtr &event);
+
+
+       private:
+       static int m_instanceCount;
+       DPL::Mutex m_constructorMutex;
+};
+
+}
+}
+}
+
+#endif /* _PLATFORM_MEDIA_CONTENT_MANAGER_H_ */
diff --git a/src/platform/Tizen/Mediacontent/config.cmake b/src/platform/Tizen/Mediacontent/config.cmake
new file mode 100644 (file)
index 0000000..2b934b8
--- /dev/null
@@ -0,0 +1,27 @@
+get_current_path()
+
+pkg_search_module(glib REQUIRED glib-2.0)
+pkg_search_module(libpcrecpp REQUIRED libpcrecpp)
+pkg_search_module(mm-fileinfo REQUIRED mm-fileinfo)
+
+set(INCLUDES_PLATFORM_IMPLEMENTATION_MEDIACONTENT
+  ${glib_INCLUDE_DIRS}
+  ${libpcrecpp_INCLUDE_DIRS}
+  ${mm-fileinfo_INCLUDE_DIRS}
+  PARENT_SCOPE
+)
+
+set(LIBS_PLATFORM_IMPLEMENTATION_MEDIACONTENT
+  ${glib_LIBRARIES}
+  ${libpcrecpp_LIBRARIES}
+  ${mm-fileinfo_LIBRARIES}  
+  PARENT_SCOPE
+)
+
+set(SRCS_PLATFORM_IMPLEMENTATION_MEDIACONTENT
+  ${CURRENT_PATH}/MediaSearchVisitor.cpp
+  ${CURRENT_PATH}/MediaFilterValidator.cpp
+  ${CURRENT_PATH}/Mediacontent.cpp
+  ${CURRENT_PATH}/MediacontentManager.cpp
+  PARENT_SCOPE
+)
index 1ed0162..1ec4a6c 100755 (executable)
@@ -43,7 +43,12 @@ using namespace std;
 namespace TizenApis {
 namespace Platform {
 namespace Messaging {
-       
+
+Attachment::Attachment()
+{
+    LogDebug("entered");
+}
+
 Attachment::Attachment(const string& fullPath,
         bool isVirtualPath)
 {
@@ -88,6 +93,7 @@ Attachment::Attachment(const std::string& fullPath, bool isVirtualPath, const Ap
 
 std::string Attachment::getRealPath(const std::string &path) const
 {
+
 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
     Try
     {
@@ -101,6 +107,11 @@ std::string Attachment::getRealPath(const std::string &path) const
         ReThrow(WrtDeviceApis::Commons::InvalidArgumentException);
     }
 #endif
+
+       LogDebug(" path = " << path);
+
+       return path;
+
 }
 
 }
index 1a2f99c..fc18974 100755 (executable)
@@ -37,7 +37,7 @@ namespace Messaging {
 class Attachment : public Api::Messaging::IAttachment
 {
   public:
-
+    explicit Attachment();
     explicit Attachment(const std::string& fullPath, bool isVirtualPath);
     explicit Attachment(emf_attachment_info_t* att);
 
index a40b319..c3d9724 100755 (executable)
@@ -36,7 +36,6 @@
 #include <Commons/Exception.h>
 #include <Commons/StringUtils.h>
 #include <API/Messaging/MessageFactory.h>
-#include <API/Messaging/EmailAccountInfo.h>
 #include "Messaging.h"
 #include "Email.h"
 #include "EmailService.h"
@@ -86,13 +85,10 @@ Email::Email(const string& id) :
 
        try {
                if (getIdRef().empty()) {
-                       create();
+                       //exception
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, " message id is invalid");
                }
-               // always read the message (after creation some of attributes change
-               // i.e. body->plain)
-
-               //get account ID
-               
+                               
                reload();
        } catch (const WrtDeviceApis::Commons::PlatformException& ex) {
                LogError("Exception: " << ex.DumpToString());
@@ -107,10 +103,11 @@ Email::Email(const std::string& id, int accountId) :
        LOG_ENTER
 
        try {
-               // always read the message (after creation some of attributes change
-               // i.e. body->plain)
-
-               //get account ID
+               if (getIdRef().empty()) {
+                       //exception
+                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, " message id is invalid");
+               }
+               
                LogDebug("Account ID = " << accountId);
                m_accountId = accountId;
                reload();
@@ -131,8 +128,7 @@ Email::Email(Api::Messaging::EmailAccountInfo& account) : IMessage(EMAIL)
          if (getIdRef().empty()) {
                create(account);
          }
-        // always read the message (after creation some of attributes change
-        // i.e. body->plain)
+       
         reload();
     }
     catch (const WrtDeviceApis::Commons::PlatformException& ex) {
@@ -142,6 +138,25 @@ Email::Email(Api::Messaging::EmailAccountInfo& account) : IMessage(EMAIL)
     LOG_EXIT
 }
 
+Email::Email(const Api::Messaging::FolderType folder) : IMessage(EMAIL)
+{
+    LOG_ENTER
+
+    try {
+         if (folder == Api::Messaging::TEMP_FOLDER) {
+               create();
+         }
+          else {
+             ThrowMsg(WrtDeviceApis::Commons::PlatformException, "Folder Type is miss-matched");
+          }
+    }
+    catch (const WrtDeviceApis::Commons::PlatformException& ex) {
+        LogError("Exception: " << ex.DumpToString());
+    }
+
+    LOG_EXIT
+}
+
 Email::~Email()
 {
     LogDebug("ENTER");
@@ -258,6 +273,15 @@ int Email::isBodyDownloaded()
                return false;
 }
 
+bool Email::hasAttachment()
+{      
+       std::size_t attachmentSize = getAttachmentsCount();
+       if ( attachmentSize > 0)
+                       return true;
+               else
+                       return false;
+}
+
 void Email::readAllData()
 {
     reload();
@@ -328,6 +352,7 @@ void Email::remove()
     EmailService::deleteMail(m_accountId, getIntId());
 }
 
+#if 0
 void Email::create()
 {
     LOG_ENTER
@@ -345,6 +370,15 @@ void Email::create()
 
     LOG_EXIT
 }
+#endif
+
+void Email::create()
+{
+    LOG_ENTER
+    setFolderType(Api::Messaging::TEMP_FOLDER);
+    setMessageStatus(Api::Messaging::MESSAGE_STATUS_CREATED);
+    LOG_EXIT
+}
 
 void Email::create( Api::Messaging::EmailAccountInfo& account )
 {
@@ -355,6 +389,7 @@ void Email::create( Api::Messaging::EmailAccountInfo& account )
        
       LogDebug("account ID : " << m_accountId);
        ScopedMail mail(EmailService::createMail(account));
+       setEmailAccount(account);       //save account
        ScopedMailbox mailbox(EmailService::getMailboxByType(account.getIntId(), EMF_MAILBOX_TYPE_DRAFT));
        setId(convertId(EmailService::addMailToMailbox(mail.Get(), mailbox.Get())));
        setFolderType(Api::Messaging::DRAFTBOX);
@@ -637,6 +672,8 @@ void Email::addMessageToDraft()
 {
     LOG_ENTER
 
+#if 0
+       //check Message Status.
     DPL::Mutex::ScopedLock mx(&m_updateMutex);
 
     if (!m_mail) {
@@ -651,6 +688,42 @@ void Email::addMessageToDraft()
 
     int error = email_update_message(getIntId(), m_mail.Get());        
     LogDebug("add finished, mailId = " << error);              
+#endif
+
+    if ( getUID() > 0 && m_accountId > 0)
+    {  //update
+
+       update();
+       
+    }
+    else
+    {
+               Api::Messaging::EmailAccountInfo account = getEmailAccount();
+               m_accountId = account.getIntId();       //set account ID
+               MailSender::getInstance();
+               
+               LogDebug("account ID : " << m_accountId);       
+               ScopedMail mail(EmailService::createMail(account));
+
+               LogDebug("get mail" );
+               emf_mail_t* ma = mail.Get();
+               if (ma)
+                       LogDebug("UID : " << ma->info->uid);
+               
+               setEmailAccount(account);       //save account
+               ScopedMailbox mailbox(EmailService::getMailboxByType(account.getIntId(), EMF_MAILBOX_TYPE_DRAFT));
+               setId(convertId(EmailService::addMailToMailbox(mail.Get(), mailbox.Get())));
+
+               reload();       //reload mail
+               update(); //update message.
+
+               LogDebug("Folder = " << EmailConverter::toFolderType(m_mailbox->mailbox_type));
+               setFolderType(EmailConverter::toFolderType(m_mailbox->mailbox_type));
+               setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
+               
+               LogDebug("Message ID : " << getUID());
+    }
+
     LOG_EXIT
 }
 
index b9ee5f1..502a9ae 100755 (executable)
@@ -66,6 +66,8 @@ class Email : public Api::Messaging::IEmail
 
     explicit Email( Api::Messaging::EmailAccountInfo& account);
 
+    explicit Email(const Api::Messaging::FolderType folder);   
+
     virtual ~Email();
 
     virtual int send();
@@ -99,6 +101,8 @@ class Email : public Api::Messaging::IEmail
 
     virtual int isBodyDownloaded();
 
+    virtual bool hasAttachment();
+
   private:
     void create();
 
index 0efab2f..3f757ba 100644 (file)
@@ -110,18 +110,18 @@ namespace TizenApis {
                        return retClause;
                }
 
-               void FolderQueryGenerator::visitAttribute(std::string& attrName,
-                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
+               void FolderQueryGenerator::visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
                        LogDebug("values->size():" << values->size());
 
                        Api::Tizen::FilterType filterType = UNION_FILTER;
 
-                       if(matchFlag.compare("EXIST")==0){
+                       if(matchFlag == MATCH_EXISTS){
                                //TODO implement for EXIST
                        }else if(values->size() == 1){
                                AnyPtr matchValue = values->at(0);
-                               visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                               visitAttributeEach(attrName, matchFlag, matchValue, depth);
                        }else{
                                visitPreComposite(filterType, depth);
 
@@ -134,7 +134,7 @@ namespace TizenApis {
                                        }
 
                                        AnyPtr matchValue = *iter;
-                                       visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                                       visitAttributeEach(attrName, matchFlag, matchValue, depth);
                                }
 
                                visitPostComposite(filterType, depth);
@@ -142,24 +142,24 @@ namespace TizenApis {
                        LogDebug(">>>");
                }
 
-               void FolderQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               void FolderQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
-                       if(matchFlag.compare(STRING_MATCH_EXACTLY) == 0){
+                       if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXACTLY");
                                getMatchExactlyClause(attrName, value);
-                       }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                getMatchContainsClause(attrName, value);
-                       }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
+                       }else if(matchFlag== Api::Tizen::MATCH_STARTSWITH){
                                LogDebug("STRING_MATCH_STARTSWITH");
                                getMatchStartsWithClause(attrName, value);
-                       }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                getMatchEndsWithClause(attrName, value);
                        }else{
                                LogDebug("[ERROR]invalid match flag[" << matchFlag << "]");
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" + matchFlag + "]");
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" << matchFlag << "]");
                        }
                        LogDebug(">>>");
                }
index 7314e00..7c4bfea 100644 (file)
@@ -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. 
-*/
+ * 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.
+ */
 /*
  * FolderQueryGenerator.h
  *
 #include <map>
 
 namespace TizenApis {
-       namespace Platform {
-               namespace Messaging {
+namespace Platform {
+namespace Messaging {
 
-               class FolderQueryGenerator: public TizenApis::Api::Tizen::IFilterVisitor{
+class FolderQueryGenerator: public TizenApis::Api::Tizen::IFilterVisitor {
 
-                       public:
-                               enum QueryGeneratorMode{
-                                       MODE_EMAIL,
-                                       MODE_SMS_MMS
-                               };
+public:
+       enum QueryGeneratorMode {
+               MODE_EMAIL, MODE_SMS_MMS
+       };
 
-                       protected:
-                               std::map<std::string, std::string> attributeMap;
+protected:
+       std::map<std::string, std::string> attributeMap;
 
-                       private:
-                               QueryGeneratorMode m_mode;
-                               std::string m_query;
-                               std::vector<std::string> m_queryVector;
+private:
+       QueryGeneratorMode m_mode;
+       std::string m_query;
+       std::vector<std::string> m_queryVector;
 
-                               int m_messageType;
+       int m_messageType;
 
-                               std::vector<std::string> typeVector;
+       std::vector<std::string> typeVector;
 
-                               std::string m_currentType;
+       std::string m_currentType;
 
-                               bool m_folderPathProcessing;
+       bool m_folderPathProcessing;
 
-                               int m_accountId;
-                               std::string m_folderpath;
+       int m_accountId;
+       std::string m_folderpath;
 
-                               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 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 ACCOUNT_ID_NOT_INITIALIZED;
+       static const int ACCOUNT_ID_NOT_INITIALIZED;
 
-                       public:
-                               FolderQueryGenerator();
-                               virtual ~FolderQueryGenerator();
+public:
+       FolderQueryGenerator();
+       virtual ~FolderQueryGenerator();
 
-                               void visitPreComposite(Api::Tizen::FilterType& type, int depth);
-                               void visitInComposite(Api::Tizen::FilterType& type, int depth);
-                               void visitPostComposite(Api::Tizen::FilterType& type, int depth);
-                               void visitAttribute(std::string& attrName,      Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
-                               void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
-                               void visitID(Api::Tizen::AnyArrayPtr &value, int depth);
+       void visitPreComposite(Api::Tizen::FilterType& type, int depth);
+       void visitInComposite(Api::Tizen::FilterType& type, int depth);
+       void visitPostComposite(Api::Tizen::FilterType& type, int depth);
+       void visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                       Api::Tizen::AnyArrayPtr& values, int depth);
+       void visitAttributeRange(std::string& attrName,
+                       Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue,
+                       int depth);
+       void visitID(Api::Tizen::AnyArrayPtr &value, int depth);
 
-                               int getAccountId();
-                               std::string getFolderPath();    
-                               bool isFolderPathExist();
-                               void reset();                           
+       int getAccountId();
+       std::string getFolderPath();
+       bool isFolderPathExist();
+       void reset();
 
-                       protected:
-                               virtual bool getMatchExactlyClause(std::string& attrName, Api::Tizen::AnyPtr& value);
-                               void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);                           
+protected:
+       virtual bool getMatchExactlyClause(std::string& attrName,
+                       Api::Tizen::AnyPtr& value);
+       void visitAttributeEach(std::string& attrName,
+                       Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value,
+                       int depth);
 
-                       private:
-                               std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
-                               std::string getMatchEndsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
-                               std::string getMatchContainsClause(std::string& attrName, Api::Tizen::AnyPtr& value);
+private:
+       std::string getMatchStartsWithClause(std::string& attrName,
+                       Api::Tizen::AnyPtr& value);
+       std::string getMatchEndsWithClause(std::string& attrName,
+                       Api::Tizen::AnyPtr& value);
+       std::string getMatchContainsClause(std::string& attrName,
+                       Api::Tizen::AnyPtr& value);
 
-               };
+};
 
-               typedef DPL::SharedPtr<FolderQueryGenerator> FolderQueryGeneratorPtr;
-       }               // namespace Platform
+typedef DPL::SharedPtr<FolderQueryGenerator> FolderQueryGeneratorPtr;
+} // namespace Platform
 } // namespace WrtPlugins
 }
 #endif
index 0682c79..7bbbb7d 100755 (executable)
@@ -544,18 +544,18 @@ namespace TizenApis {
                        return retClause;
                }
 
-               void MessageQueryGenerator::visitAttribute(std::string& attrName,
-                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth){
+               void MessageQueryGenerator::visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                               Api::Tizen::AnyArrayPtr& values, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], matchFlag:[" << matchFlag << "]");
                        LogDebug("values->size():" << values->size());
 
                        Api::Tizen::FilterType filterType = UNION_FILTER;
 
-                       if(matchFlag.compare("EXIST")==0){
+                       if(matchFlag == MATCH_EXISTS){
                                //TODO implement for EXIST
                        }else if(values->size() == 1){
                                AnyPtr matchValue = values->at(0);
-                               visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                               visitAttributeEach(attrName, matchFlag, matchValue, depth);
                        }else{
                                visitPreComposite(filterType, depth);
 
@@ -568,7 +568,7 @@ namespace TizenApis {
                                        }
 
                                        AnyPtr matchValue = *iter;
-                                       visitAttributeEach(attrName, matchValue, matchFlag, depth);
+                                       visitAttributeEach(attrName, matchFlag, matchValue, depth);
                                }
 
                                visitPostComposite(filterType, depth);
@@ -581,11 +581,11 @@ namespace TizenApis {
 
                        int retMessageType = -1;
 
-                       if(stringType.compare("tizen.sms") ==0){
+                       if(stringType.compare("messaging.sms") ==0){
                                retMessageType = Api::Messaging::SMS;
-                       }else if(stringType.compare("tizen.mms") ==0){
+                       }else if(stringType.compare("messaging.mms") ==0){
                                retMessageType = Api::Messaging::MMS;
-                       }else if(stringType.compare("tizen.email") ==0){
+                       }else if(stringType.compare("messaging.email") ==0){
                                retMessageType = Api::Messaging::EMAIL;
                        }else{
                                MsgLogError("invalid type:[" << stringType << "]");
@@ -597,7 +597,7 @@ namespace TizenApis {
                }
 
 
-               void MessageQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth){
+               void MessageQueryGenerator::visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth){
                        LogDebug("<<< attrName:[" << attrName << "], value:[" << value->toString() << "]");
 
                        if(attrName.compare("type")==0){
@@ -618,21 +618,21 @@ namespace TizenApis {
 //                     }
                        std::string tmpStringBuffer;
 
-                       if(matchFlag.compare(STRING_MATCH_EXCACTLY) == 0){
+                       if(matchFlag == Api::Tizen::MATCH_EXACTLY){
                                LogDebug("STRING_MATCH_EXCACTLY");
                                tmpStringBuffer.append(getMatchExactlyClause(attrName, value));
-                       }else if(matchFlag.compare(STRING_MATCH_CONTAINS) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_CONTAINS){
                                LogDebug("STRING_MATCH_CONTAINS");
                                tmpStringBuffer.append(getMatchContainsClause(attrName, value));
-                       }else if(matchFlag.compare(STRING_MATCH_STARTSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_STARTSWITH){
                                LogDebug("STRING_MATCH_STARTSWITH");
                                tmpStringBuffer.append(getMatchStartsWithClause(attrName, value));
-                       }else if(matchFlag.compare(STRING_MATCH_ENDSWITH) == 0){
+                       }else if(matchFlag == Api::Tizen::MATCH_ENDSWITH){
                                LogDebug("STRING_MATCH_ENDSWITH");
                                tmpStringBuffer.append(getMatchEndsWithClause(attrName, value));
                        }else{
                                LogDebug("[ERROR]invalid match flag[" << matchFlag << "]");
-                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" + matchFlag + "]");
+                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "invalid match flag:[" << matchFlag << "]");
                        }
 //                             else if(iter->find(MATCH_CASESENSITIVE)){               //TODO check case sensitive
 //                             }
index 101973c..cb9e7e4 100755 (executable)
@@ -78,8 +78,8 @@ namespace TizenApis {
                                void visitPreComposite(Api::Tizen::FilterType& type, int depth);
                                void visitInComposite(Api::Tizen::FilterType& type, int depth);
                                void visitPostComposite(Api::Tizen::FilterType& type, int depth);
-                               void visitAttribute(std::string& attrName,
-                                               Api::Tizen::AnyArrayPtr& values, std::string& matchFlag, bool caseSensitive, int depth);
+                               void visitAttribute(std::string& attrName, Api::Tizen::MatchFlag& matchFlag,
+                                               Api::Tizen::AnyArrayPtr& values, int depth);
                                void visitAttributeRange(std::string& attrName, Api::Tizen::AnyPtr& initialValue, Api::Tizen::AnyPtr& endValue, int depth);
 
                                std::string getQuery();
@@ -110,7 +110,7 @@ namespace TizenApis {
 
                                std::string convertToEmfAttrName(std::string attrName);
 
-                               void visitAttributeEach(std::string& attrName, Api::Tizen::AnyPtr& value, std::string& matchFlag, int depth);
+                               void visitAttributeEach(std::string& attrName, Api::Tizen::MatchFlag& matchFlag, Api::Tizen::AnyPtr& value, int depth);
 
                        private:
                                std::string getMatchStartsWithClause(std::string& attrName, Api::Tizen::AnyPtr& value);
index 9dbe3e3..f8ee85b 100755 (executable)
@@ -486,7 +486,7 @@ vector<IMessagePtr> Messaging::queryEmailMessage(const std::string& sqlWhereClau
 
                for(int i=0; i<mailListCount; i++){
                        //Api::Messaging::IMessagePtr msg = MessageFactory::createMessage(EMAIL, mailList[i].mail_id);
-                       Api::Messaging::IMessagePtr msg = MessageFactory::createEmailMessage(mailList[i].mail_id, mailList[i].account_id);
+                       Api::Messaging::IMessagePtr msg = MessageFactory::createEmailMessage(mailList[i].account_id, mailList[i].mail_id);
                        
                        //TODO for debug
                        LogDebug("mailList[i].from:[" << mailList[i].from << "]");
index 6d8af53..58f835f 100755 (executable)
@@ -116,7 +116,7 @@ void MessagingServiceManager::OnRequestReceived(const EventGetMessagingServicePt
                        {
                                MessagingService* messagingService = new MessagingService();
                                messagingService->setMessagingServiceType(Api::Messaging::SMS);
-                               messagingService->setMessagingServiceName("tizen.sms");
+                               messagingService->setMessagingServiceName("messaging.sms");
                                
                                //ToDol: set messaging Service instance.
                                m_messagingServices.push_back(Api::Messaging::IMessagingServicePtr(messagingService));
@@ -125,7 +125,7 @@ void MessagingServiceManager::OnRequestReceived(const EventGetMessagingServicePt
                        {
                                MessagingService* messagingService = new MessagingService();
                                messagingService->setMessagingServiceType(Api::Messaging::MMS);
-                               messagingService->setMessagingServiceName("tizen.mms");
+                               messagingService->setMessagingServiceName("messaging.mms");
                                
                                m_messagingServices.push_back(Api::Messaging::IMessagingServicePtr(messagingService));
                        }
index a39f078..deadb8c 100755 (executable)
@@ -115,7 +115,7 @@ void Mms::createNewMessage()
 
     setMmsType(MULTIPART_MIXED);
     setReadStatus(false);
-    setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
+    setMessageStatus(Api::Messaging::MESSAGE_STATUS_CREATED);
 
     LogDebug("Message created successfully, Id: " << getIdRef());
 }
@@ -350,6 +350,14 @@ void Mms::readBodyAndAttachments(msg_message_t& messageData)
 
 }
 
+bool Mms::hasAttachment()
+{
+       std::size_t attachmentSize = getAttachmentsCount();
+       if ( attachmentSize > 0)
+               return true;
+       else
+               return false;
+}
 
 void Mms::update(bool draftsOnly)
 {
@@ -705,7 +713,10 @@ void Mms::addMessageToDraft()
         }
 
         //releasing platform message structure
-            msg_release_message(&m_messageData);
+        //msg_release_message(&m_messageData);
+
+        setFolderType(Api::Messaging::DRAFTBOX);
+        setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("remove message error");
index 33e1ecf..9dccd89 100755 (executable)
@@ -71,6 +71,8 @@ class Mms : public Api::Messaging::IMms,
 
     virtual void sendCancel(int handle);
 
+    virtual bool hasAttachment();
+
     void setSendingStatusOk();
 
     void setSendingStatusFailed();
index cf6b018..42efa5c 100755 (executable)
@@ -405,6 +405,7 @@ void Sms::createNewMessage()
         tm dateT = getDateTime();
         msg_set_time(m_messageData, mktime(&dateT));
 
+         setMessageStatus(Api::Messaging::MESSAGE_STATUS_CREATED);
         LogDebug("Message created successfully, msgId=" << getId());
     }
 
@@ -632,7 +633,10 @@ void Sms::addMessageToDraft()
         }
 
         //releasing platform message structure
-        msg_release_message(&m_messageData);
+        //msg_release_message(&m_messageData);
+               
+        setFolderType(Api::Messaging::DRAFTBOX);
+        setMessageStatus(Api::Messaging::MESSAGE_STATUS_DRAFT);
     }
     Catch(WrtDeviceApis::Commons::PlatformException) {
         LogError("remove message error");
index a7aa296..dd13eee 100755 (executable)
@@ -191,7 +191,7 @@ int NFCManager::setTagListener(const EventNFCChangedEmitterPtr& emitter,
                LogInfo("failed to set callback of nfc_manager_set_ndef_discovered_cb");
                return result;
        }
-       LogInfo("NFCManager::setNDEFListener : result << " << result);
+       LogInfo("NFCManager::setTagListener : result << " << result);
        return result;
 }
 
@@ -230,6 +230,7 @@ int NFCManager::setNDEFListener(const EventNFCChangedNdefEmitterPtr& emitter) {
                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;
 }
index e2b10b9..e8f834d 100755 (executable)
@@ -107,8 +107,6 @@ nfcTagType NFCUtil::convertTonfcTagType(const unsigned short type) {
 
 unsigned short NFCUtil::convertToTNF(nfcTNF tnf) {
        switch (tnf) {
-               case NFC_TNF_EMPTY:
-                       return static_cast<unsigned short>(NFC_RECORD_TNF_EMPTY);
                case NFC_TNF_WELL_KNOWN:
                        return static_cast<unsigned short>(NFC_RECORD_TNF_WELL_KNOWN);
                case NFC_TNF_MIME_MEDIA:
@@ -121,13 +119,14 @@ unsigned short NFCUtil::convertToTNF(nfcTNF tnf) {
                        return static_cast<unsigned short>(NFC_RECORD_TNF_UNKNOWN);
                case NFC_TNF_UNCHAGNED:
                        return static_cast<unsigned short>(NFC_RECORD_TNF_UNCHAGNED);
+               case NFC_TNF_EMPTY:
+               default:
+                       return static_cast<unsigned short>(NFC_RECORD_TNF_EMPTY);
        }
 }
 
 nfcTNF NFCUtil::convertTonfcTNF(unsigned short tnf) {
        switch (static_cast<nfc_record_tnf_e>(tnf)) {
-               case NFC_RECORD_TNF_EMPTY:
-                       return NFC_TNF_EMPTY;
                case NFC_RECORD_TNF_WELL_KNOWN:
                        return NFC_TNF_WELL_KNOWN;
                case NFC_RECORD_TNF_MIME_MEDIA:
@@ -140,6 +139,9 @@ nfcTNF NFCUtil::convertTonfcTNF(unsigned short tnf) {
                        return NFC_TNF_UNKNOWN;
                case NFC_RECORD_TNF_UNCHAGNED:
                        return NFC_TNF_UNCHAGNED;
+               case NFC_RECORD_TNF_EMPTY:
+               default:
+                       return NFC_TNF_EMPTY;
        }
 }
 
index f834b78..424c967 100755 (executable)
@@ -54,21 +54,7 @@ NdefMessage::NdefMessage(const std::vector<void *> ndefRcords)
 {
        LogDebug("entered");
 
-       if (nfc_ndef_message_create(&handle) != NFC_ERROR_NONE) {
-               handle = NULL;
-               ThrowMsg(PlatformException, "Can't create Ndef Message");
-       }
-
-       for (int i = 0 ; i < static_cast<int>(ndefRcords.size()); i++) {
-               nfc_ndef_record_h appendRecord;
-               if (!_copyNDEFRecord((nfc_ndef_record_h*)&ndefRcords[i], &appendRecord)) {
-                       LogDebug("copyNDEFRecord fail!");
-                       ThrowMsg(PlatformException, "Can't copy Record");
-               }
-
-               if (nfc_ndef_message_append_record(handle, appendRecord) != NFC_ERROR_NONE)
-                       ThrowMsg(PlatformException, "Can't create Ndef Message");
-       }
+       _makeMessage(ndefRcords);
 }
 
 NdefMessage::NdefMessage(const std::vector<unsigned char> rawdata)
@@ -93,6 +79,27 @@ NdefMessage::~NdefMessage()
                nfc_ndef_message_destroy(handle);
 }
 
+void NdefMessage::_makeMessage(const std::vector<void *> ndefRcords) {
+       if (nfc_ndef_message_create(&handle) != NFC_ERROR_NONE) {
+               handle = NULL;
+               ThrowMsg(PlatformException, "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)) {
+                       LogDebug("copyNDEFRecord fail!");
+                       ThrowMsg(PlatformException, "Can't copy Record");
+               }
+
+               if (nfc_ndef_message_append_record(handle, insertRecord) != NFC_ERROR_NONE) {
+                       LogError(i << " record can't be inserted. " << insertRecord << " : " << handle);
+                       ThrowMsg(PlatformException, "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;
@@ -120,6 +127,13 @@ 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");   
+       return (void *)recordHandle;
+}
+
 long NdefMessage::getRecordCount() {
        int count;
        if (nfc_ndef_message_get_record_count(handle, &count) != NFC_ERROR_NONE)
@@ -210,6 +224,15 @@ bool NdefMessage::removeNDEFRecord(const long index) {
        return TRUE;
 }
 
+void NdefMessage::changeAllRecords(const std::vector<void *> ndefRcords) {
+       nfc_ndef_message_h newHandle = handle;
+       handle = NULL;
+
+       _makeMessage(ndefRcords);
+       if (newHandle != NULL)
+               nfc_ndef_message_destroy(newHandle);
+}
+
 }
 }
 }
index 364209c..39aa94f 100755 (executable)
@@ -39,16 +39,18 @@ class NdefMessage : public INdefMessage
        virtual  ~NdefMessage();
 
        virtual void *getHandle();
-       virtual long getRecordCount();
+       virtual void *getRecordHandle(const long index);
        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 removeNDEFRecord(const long index);
-
+       virtual void changeAllRecords(const 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 084fd52..9097886 100755 (executable)
@@ -30,6 +30,11 @@ namespace NFC {
 using namespace Api::NFC;
 using namespace WrtDeviceApis::Commons;
 
+NdefRecord::NdefRecord()
+{
+       handle = NULL;
+}
+
 NdefRecord::NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload)
 {
        LogDebug("entered");
@@ -54,16 +59,6 @@ NdefRecord::NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::ve
        }
 }
 
-NdefRecord::NdefRecord(void *recordhandle)
-{
-       LogDebug("entered");
-
-       handle = (nfc_ndef_record_h)recordhandle;
-
-       if (recordhandle == NULL)
-               ThrowMsg(PlatformException, "Record Handler is Null Pointer.");
-}
-
 NdefRecord::NdefRecord(const std::string &text, const std::string &langCode, const short encodeType)
 {
        LogDebug("entered");
@@ -128,27 +123,46 @@ void *NdefRecord::getHandle() {
 NdefRecordProperties NdefRecord::getNDEFRecordProperties() {
        LogDebug("entered");
        NdefRecordProperties props;
-       nfc_record_tnf_e tnf;
-       unsigned char *typeName, *id;
-       int typeSize, idSize;
        NFCUtil Util;
 
+       props.tnf = getTNF();
+       LogDebug("tnf : " << props.tnf);
+       props.typeName = getTypeName();
+       props.id = getID();
+       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");
 
+       NFCUtil Util;
+       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");
 
+       NFCUtil Util;
+       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");
 
-       props.tnf = Util.convertTonfcTNF(static_cast<unsigned short>(tnf));
-       LogDebug("tnf : " << props.tnf);
-       props.typeName = Util.toVector(typeName, typeSize);
-       props.id = Util.toVector(id, idSize);
-       LogDebug("typeName : " << Util.byteToString(props.typeName));
-
-       return props;
+       NFCUtil Util;
+       return Util.toVector(id, idSize);
 }
 
 bool NdefRecord::getText(char **text) {
index a1a9189..f3f0481 100755 (executable)
@@ -33,21 +33,23 @@ class NdefRecord : public INdefRecord
 {
        friend class  NFCFactory;
     public:
+               NdefRecord();
                NdefRecord(const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
-               NdefRecord(void *recordhandle);
                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);
        virtual  ~NdefRecord();
        virtual void *getHandle();
        virtual NdefRecordProperties getNDEFRecordProperties();
+       virtual nfcTNF getTNF();
+       virtual std::vector<unsigned char> getTypeName();
+       virtual std::vector<unsigned char> getID();
        virtual std::vector<unsigned char> getPayload();
        virtual bool getText(char **text);
        virtual bool getLangCode(char **landCode);
        virtual bool getEncodeType(nfcTextEncodeUTF *encodeType);
        virtual bool getUri(char **uri);
        virtual bool getMimeType(char **mimeType);
-
     private:
        nfc_ndef_record_h handle;
        nfc_encode_type_e _convertToEncodeType(const nfcTextEncodeUTF type);
index 0d254a7..f228e11 100644 (file)
@@ -114,6 +114,7 @@ bool Systeminfo::isPropertyValid(JSContextRef context, JSValueRef property)
     mapProperties::iterator it = (*m_Property).find(l_property);
     if (it == (*m_Property).end()) {
         LogError("not existing property");
+        Throw(InvalidArgumentException);        
         return false;
     }
 
index 9ae5e61..ff1c7cb 100755 (executable)
@@ -1,4 +1,5 @@
 include_config_file(DBus)
+include_config_file(Mediacontent)
 include_config_file(Calendar)
 include_config_file(Contact)
 include_config_file(Geocoder)
index 4f6b8fc..8373cb8 100755 (executable)
@@ -29,7 +29,7 @@
 #include <Commons/RegexUtils.h>
 #include "JSAccount.h"
 #include "AccountConverter.h"
-#include "JSAccountService.h"
+//#include "JSAccountService.h"
 #include "JSAccountServiceType.h"
 #include "JSAccountManager.h"
 #include "JSFeatureArray.h"
@@ -100,19 +100,23 @@ JSValueRef AccountConverter::toJSValueRef(
     return toJSValueRef_(arg, &AccountConverter::toJSValueRefAccount, this);
 }
 
-JSValueRef AccountConverter::toJSValueRefAccountService(const IAccountServicePtr& arg)
-{
-    LogDebug("entered");
-    AccountServicePrivObject *priv = new AccountServicePrivObject(m_context, arg);
-    return JSObjectMake(m_context, JSAccountService::getClassRef(), priv);
-}
+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");
+               }
 
-JSValueRef AccountConverter::toJSValueRef(const std::vector<IAccountServicePtr> &arg)
-{
-    LogDebug("entered");
-    return toJSValueRef_(arg, &AccountConverter::toJSValueRefAccountService, this);
-}
+//             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)
 {
@@ -169,20 +173,68 @@ AccountServicesPtr AccountConverter::toService(const JSValueRef jsValue)
        return result;
 }
 
-AccountServicesArrayPtr AccountConverter::toAccountService(const JSValueRef jsValue)
+AccountServicesArrayPtr AccountConverter::toAccountServiceArray(const JSValueRef jsValue)
 {
-    AccountServicesArrayPtr result(new AccountServicesArray());
+       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));
+       }
 
-    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;
+}
 
-    *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)
@@ -237,45 +289,32 @@ EventAccountPtr AccountConverter::toAccount(const std::string& accountServicePro
 
 EventAccountPtr AccountConverter::toAccount(const JSValueRef account)
 {
-    LogDebug("<<<");
-    EventAccountPtr result(new EventAccount());
-
-    const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
-    const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
-
-    JSObjectRef arg = toJSObjectRef(account);
-
-    JSValueRef displayNameData = JSObjectGetProperty(m_context, arg, displayNameStr.get(), NULL);
-    JSValueRef iconPathData = JSObjectGetProperty(m_context, arg, iconPathStr.get(), NULL);
+       LogDebug("<<<");
+       EventAccountPtr result(new EventAccount());
 
-    if (!JSValueIsUndefined(m_context, displayNameData)) {
-        result->setDisplayName(toString(displayNameData));
-    }
+       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString("displayName"));
+       const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString("iconPath"));
+       const ScopedJSStringRef providerIdStr(JSStringCreateWithUTF8CString("providerId"));
 
-    if (!JSValueIsUndefined(m_context, iconPathData)) {
-        result->setIconPath(toString(iconPathData));
-    }
+       JSObjectRef arg = toJSObjectRef(account);
 
-    result->setProviderName(m_provider);
-/*
-    if (!JSValueIsUndefined(m_context, providerNameData)) {
-        result->setProviderName(toString(providerNameData));
-    }
+       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, emailAddressData)) {
-        result->setEmailAddress(toString(emailAddressData));
-    }
+       if (!JSValueIsUndefined(m_context, displayNameData)) {
+               result->setDisplayName(toString(displayNameData));
+       }
 
-    if (!JSValueIsUndefined(m_context, domainNameData)) {
-        result->setDomainName(toString(domainNameData));
-    }
+       if (!JSValueIsUndefined(m_context, iconPathData)) {
+               result->setIconPath(toString(iconPathData));
+       }
 
-       if (!JSValueIsUndefined(m_context, serviceData)) {
-               AccountServicesArrayPtr m_service = toAccountService(serviceData);
-               result->setService(m_service);
+       if (!JSValueIsUndefined(m_context, providerIdData)) {
+               result->setProviderId(toString(providerIdData));
        }
-*/
-    return result;
+
+       return result;
 }
 
 void AccountConverter::toEventFilterConvertId(
@@ -326,6 +365,10 @@ EventAccountListPtr AccountConverter::toVectorOfAccounts(JSValueRef events)
     return result;
 }
 
+JSValueRef AccountConverter::toJSONString(const std::string& arg){
+       return JSValueMakeFromJSONString(m_context, toJSStringRef(arg));
+}
+
 }
 }
 }
index 9c4e52e..97fee19 100755 (executable)
@@ -53,18 +53,25 @@ class AccountConverter : public Converter
     EventAccountPtr toAccount(const std::string& accountServiceProviderId);
     EventAccountListPtr toVectorOfAccounts(JSValueRef accounts);
 
-       AccountServicesArrayPtr toAccountService(const JSValueRef jsValue);
+       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 toJSValueRefAccountService(const IAccountServicePtr& arg);
     JSValueRef toJSValueRefAccountServiceType(const AccountServiceTypePropertyPtr& arg);
     JSValueRef toJSValueRefAccountServiceProvider(const AccountServiceProviderPropertyPtr& arg);
-    JSValueRef toJSValueRef(const std::vector<IAccountServicePtr> &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.
index ebeb18d..64f509e 100755 (executable)
@@ -7,7 +7,7 @@ set(SRCS
   ResponseDispatcher.cpp
   AccountConverter.cpp
   JSAccount.cpp
-  JSAccountService.cpp
+#  JSAccountService.cpp
   JSAccountManager.cpp
   JSFeatureArray.cpp
   JSAccountServices.cpp
index 7b4e570..e8ab4e8 100755 (executable)
@@ -24,8 +24,9 @@
 #include "JSAccount.h"
 #include "JSFeatureArray.h"
 #include "JSAccountServices.h"
-#include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+
 #include "AccountConverter.h"
 #include "plugin_config.h"
 
@@ -55,9 +56,6 @@ namespace {
 #define ACCOUNT_ATTRIBUTE_SERVICES  "services"
 #define ACCOUNT_ATTRIBUTE_SETTINGS  "settings"
 
-#define ACCOUNT_FUNCTION_GET_SERVICE_BY_ID    "getServiceById"
-#define ACCOUNT_FUNCTION_GET_SERVICE_BY_NAME  "getServiceByName"
-
 }
 
 JSClassDefinition JSAccount::m_classInfo = {
@@ -66,7 +64,7 @@ JSClassDefinition JSAccount::m_classInfo = {
     ACCOUNT_ATTRIBUTE_NAME,
     0,
     m_property,
-    m_function, //m_function,
+    NULL, //m_function,
     initialize,
     finalize,
     NULL, //hasProperty,
@@ -75,31 +73,23 @@ JSClassDefinition JSAccount::m_classInfo = {
     NULL, //deleteProperty,
     NULL, //getPropertyNames,
     NULL, //callAsFunction,
-    NULL, //callAsConstructor,
+    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 },
+    { 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 }
 };
 
-JSStaticFunction JSAccount::m_function[] = {
-       { ACCOUNT_FUNCTION_GET_SERVICE_BY_ID,   JSAccount::getServiceById,   kJSPropertyAttributeNone },
-       { ACCOUNT_FUNCTION_GET_SERVICE_BY_NAME, JSAccount::getServiceByName, kJSPropertyAttributeNone },
-       { 0, 0, 0 }
-};
-
-
-
 JSClassRef JSAccount::m_jsClassRef = JSClassCreate(
         JSAccount::getClassInfo());
 
@@ -148,7 +138,7 @@ void JSAccount::setIEvent(const EventAccountPtr &event,
     }
     Catch(Exception)
     {
-        LogError("Error during replacing account object");
+        AccountLogError("Error during replacing account object");
     }
 }
 
@@ -179,14 +169,18 @@ JSObjectRef JSAccount::createJSAccount(JSContextRef context, EventAccountPtr acc
        return jsValueRef;
 }
 
-void JSAccount::initialize(JSContextRef context,
-        JSObjectRef object)
+void JSAccount::initialize(JSContextRef context, JSObjectRef object)
 {
        LogDebug("<<< ");
 
        AccountPrivateObject *privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(object));
        if (NULL == privateObject) {
-               LogDebug("privateObject is NULL");
+               AccountLogWarning("privateObject is NULL");
+               EventAccountPtr accountPtr(new EventAccount());
+               AccountPrivateObject *priv = new AccountPrivateObject(context, accountPtr);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
        }
 }
 
@@ -205,18 +199,17 @@ JSValueRef JSAccount::getProperty(JSContextRef context,
         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();
+       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());
+               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)) {
@@ -224,18 +217,19 @@ JSValueRef JSAccount::getProperty(JSContextRef context,
                } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_ENABLED)) {
                        return converter->toJSValueRef(account->getEnabled());
                } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_PROVIDER_ID)) {
-                       return converter->toJSValueRef(account->getProviderName());
+                       return converter->toJSValueRef(account->getProviderId());
                } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_CREDENTIAL_ID)) {
-                       return converter->toJSValueRefLong(account->getCredentailId());
+                       return converter->toJSValueRef(account->getCredentailId());
                } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_ATTRIBUTE_SETTINGS)) {
-                       return converter->toJSValueRef(account->getSettings());
+                       std::string settingsString = account->getSettings();
+                       LogDebug("settingsString:[" << settingsString << "]");
+                       return converter->toJSONString(settingsString);
                }
-    }
-    Catch(Exception)
-    {
-        LogError("invalid property");
-    }
-    return JSValueMakeUndefined(context);
+       }Catch(Exception){
+               AccountLogError("invalid property");
+       }
+
+       return JSValueMakeUndefined(context);
 }
 
 bool JSAccount::setProperty(JSContextRef context,
@@ -244,32 +238,45 @@ bool JSAccount::setProperty(JSContextRef context,
         JSValueRef value,
         JSValueRef* exception)
 {
-    LogDebug("entered");
-    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_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;
-        }
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to set incorrect value");
-    }
-    JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-    return false;
+       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,
@@ -303,7 +310,7 @@ JSValueRef JSAccount::getServices(JSContextRef context,
                        return jsResult;
                }
        }       Catch(Exception)        {
-               LogWarning("trying to get incorrect value");
+               AccountLogWarning("trying to get incorrect value");
        }
 
        LogDebug(">>> undefined");
@@ -316,131 +323,89 @@ bool JSAccount::setServices(JSContextRef context,
         JSValueRef value,
         JSValueRef* exception)
 {
-    LogDebug("entered");
-
-    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->toAccountService(value));
-        return true;
-    }
-    Catch(Exception)
-    {
-        LogWarning("trying to set incorrect value");
-    }
-    JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
-    return false;
-}
+       LogDebug("<<<");
 
-JSValueRef JSAccount::getServiceById(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
+       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
        Try{
-                       AccountPrivateObject* privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(thisObject));
-                       assert(privateObject);
-
-                       JSContextRef globalContext = privateObject->getContext();
-                       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_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);
-                       }
+               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");
+       }
 
-                       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");
-                       }
+       JSTizenExceptionFactory::postException(context, exception,
+              JSTizenException::TYPE_MISMATCH_ERROR, "Trying to set incorrect value");
+       return false;
+}
 
-                       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
-                       std::string serviceId = converter->convertTostring(arguments[0]);
-                       LogDebug("<<< serviceId:[" << serviceId << "]");
-
-                       EventAccountPtr account = privateObject->getObject();
-                       AccountServicesArrayPtr services = account->getService();
-                       if (services) {
-                               for(unsigned int i = 0; i < services->size(); i++) {
-                                       std::string tmpServiceId = services->at(i)->getId();
-                                       LogDebug("tmpServiceId:[" << tmpServiceId << "]");
-                                       if(tmpServiceId.compare(serviceId)==0){
-                                               LogDebug(">>> return JSAccoutServices");
-                                               return JSAccountServices::createJSObject(context, services->at(i));
-                                       }
-                               }
+bool JSAccount::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
 
-                               AccountLogWarning("not supported service name:[" << serviceId << "]");
-                       }else{
-                               AccountLogWarning("services is NULL");
-                       }
-               }Catch(Exception){
-                       LogDebug(">>> UNKNOWN EXCEPTION");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                                                                       JSTizenException::UNKNOWN_ERROR, "UNKNOWN EXCEPTION");
-               }
+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);
+       }
 
-               LogDebug(">>> return null");
-               return JSValueMakeNull(context);
-}
+       if (argumentCount > 2) {
+               AccountLogError("Wrong argument count:" << argumentCount);
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count");
+       }
 
-JSValueRef JSAccount::getServiceByName(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
-               const JSValueRef arguments[], JSValueRef* exception) {
        Try{
-               AccountPrivateObject* privateObject = static_cast<AccountPrivateObject*>(JSObjectGetPrivate(thisObject));
-               assert(privateObject);
-
-               JSContextRef globalContext = privateObject->getContext();
-               AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_GET_SERVICE_BY_NAME);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+               AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
 
-               if (argumentCount!=1) {
-                       AccountLogError("Wrong number of parameters.");
-                       return JSTizenExceptionFactory::postException(context, exception,
-                                                       JSTizenException::INVALID_VALUES_ERROR, "Wrong argument count:"+argumentCount);
-               }
+               std::string accountServiceProviderId;
 
                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");
+                       AccountLogError(">>> invalid value argument 0");
+                       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 << "]");
+               accountServiceProviderId = converter->toString(arguments[0]);
+               LogDebug("accountServiceProviderId:[" << accountServiceProviderId << "]");
 
-               EventAccountPtr account = privateObject->getObject();
-               AccountServicesArrayPtr services = account->getService();
-               if (services) {
-                       for(unsigned int i = 0; i < services->size(); i++) {
-                               std::string tmpServiceName = services->at(i)->getName();
-                               LogDebug("tmpServiceName:[" << tmpServiceName << "]");
-                               if(tmpServiceName.compare(serviceName)==0){
-                                       LogDebug(">>> return JSAccoutServices");
-                                       return JSAccountServices::createJSObject(context, services->at(i));
-                               }
+               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);
                        }
 
-                       AccountLogWarning("not supported service name:[" << serviceName << "]");
-               }else{
-                       AccountLogWarning("services is NULL");
+                       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){
-               LogDebug(">>> UNKNOWN EXCEPTION");
-               return JSTizenExceptionFactory::postException(context, exception,
-                                                                                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN EXCEPTION");
+               AccountLogError("UNKNOWN EXCEPTION");
+               JSTizenExceptionFactory::postException(context, exception,
+                               JSTizenException::UNKNOWN_ERROR, "UNKNOWN_ERROR");
        }
 
-       LogDebug(">>> return null");
-       return JSValueMakeNull(context);
-}
-
-bool JSAccount::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
-       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+       AccountLogWarning(">>> return NULL");
+       return NULL;
 }
 
 }
index 212cd69..e94fefd 100755 (executable)
@@ -97,20 +97,12 @@ class JSAccount
         JSValueRef value,
         JSValueRef* exception);
 
-       static JSValueRef getServiceById(JSContextRef context,
+       static JSObjectRef constructor(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);
-
        /**
                 * The callback invoked when an object is used as the target of an 'instanceof' expression.
                 */
@@ -120,11 +112,6 @@ class JSAccount
     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;
index db6fdb6..7269eae 100755 (executable)
 #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 "JSAccountService.h"
 #include "JSAccountServiceType.h"
+#include "JSAccountServices.h"
+#include "JSAccountServiceProvider.h"
+
 #include "AccountConverter.h"
 #include "ResponseDispatcher.h"
 #include "plugin_config.h"
@@ -99,14 +106,18 @@ 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_SERVICES_BY_TAGS,         findServicesByTags,        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 }
 };
 
@@ -135,7 +146,7 @@ void JSAccountManager::finalize(JSObjectRef object)
 
 /**
  *     definition
- * Account addAccount(AccountServiceProviderId providerId, optional AccountProperties? properties);
+ * void addAccount(Account account)
  */
 JSValueRef JSAccountManager::addAccount(JSContextRef context,
         JSObjectRef object,
@@ -152,29 +163,21 @@ JSValueRef JSAccountManager::addAccount(JSContextRef context,
        AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_ADD_ACCOUNT);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
        Try{
-               if (argumentCount > 3) {
-                       LogError("Wrong number of parameters.");
+               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])){
+               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);
-               converter->setProvider(arguments[0]);
-               if(argumentCount>1){
-                       //TODO implement for AccountProperties
-//                     EventAccountPtr account = converter->toAccount(arguments[1]);
-               }
-
-               std::string accountServiceProviderId = converter->convertTostring(arguments[0]);
-               EventAccountPtr account = converter->toAccount(accountServiceProviderId);
-
+               EventAccountPtr account = converter->toAccount(arguments[0]);
 
                if (!account) {
-                       LogError("Failed to get an event.");
+                       AccountLogError("Failed to get an event.");
                        return JSTizenExceptionFactory::postException(context, exception,
                                                                                                        JSTizenException::UNKNOWN_ERROR, "Failed to get an event");
                }
@@ -423,7 +426,6 @@ JSValueRef JSAccountManager::getProviderById(JSContextRef context,
                privateObject->getObject()->getProviderById(dplEvent);
 
                if (dplEvent->getResult()){
-                       LogDebug(">>>");
                        JSValueRef retVal = converter->toJSValueRefAccountServiceProvider(dplEvent->getAccountServiceProviderProperty());
                        LogDebug(">>>");
                        return retVal;
@@ -456,26 +458,154 @@ JSValueRef JSAccountManager::findAccountsByServiceType(JSContextRef context,
     return JSDOMExceptionFactory::UnknownException.make(context, exception);
 }
 
-JSValueRef JSAccountManager::findAccountsByTags(JSContextRef context,
+JSValueRef JSAccountManager::findAccounts(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-    return JSDOMExceptionFactory::UnknownException.make(context, 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::findServicesByTags(JSContextRef context,
+JSValueRef JSAccountManager::findServices(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered");
-    return JSDOMExceptionFactory::UnknownException.make(context, 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,
@@ -485,57 +615,71 @@ JSValueRef JSAccountManager::findProviders(JSContextRef context,
         const JSValueRef arguments[],
         JSValueRef* exception)
 {
-    LogDebug("entered!!!!");
+       LogDebug("<<<");
+
        AccountManagerPrivObject *privateObject = static_cast<AccountManagerPrivObject*>(JSObjectGetPrivate(thisObject));
-    assert(privateObject);
+       assert(privateObject);
 
        JSContextRef globalContext = privateObject->getContext();
-       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_PROVIDERS);
+       AceSecurityStatus status = ACCOUNT_CHECK_ACCESS(globalContext, ACCOUNT_FUNCTION_API_FIND_SERVICETYPES);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-    Try
-    {
-               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());
-                       return JSValueMakeNull(context);
-               }
+       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);
+       AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(globalContext);
 
-               EventAccountPtr account(new EventAccount());
-               std::string value = converter->convertTostring(arguments[0]);
-               account->setServiceTypeId(value);
-               if (!account) {
-                       LogError("Failed to get an event.");
-                       return JSDOMExceptionFactory::UnknownException.make(privateObject->getContext());
+       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);
 
-               IEventFindProvidersPtr dplEvent(new IEventFindProviders());
-               dplEvent->setEvent(account);
-               dplEvent->setForSynchronousCall();
-               privateObject->getObject()->FindProviders(dplEvent);
+               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");
+                               }
 
-               if (dplEvent->getResult())
-                       return converter->toJSValueRefAccount(dplEvent->getEvent());
-               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);
+                               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);
 }
 
 /**
@@ -608,8 +752,8 @@ JSValueRef JSAccountManager::findServiceTypes(JSContextRef context,
                                                                                                                                                        JSTizenException::TYPE_MISMATCH_ERROR, "Unexpected error during adding account");
        }
 
-       AccountLogWarning(">>> return undefined");
-       return JSValueMakeUndefined(context);
+       AccountLogWarning(">>> return null");
+       return JSValueMakeNull(context);
 }
 
 const JSClassRef JSAccountManager::getClassRef()
@@ -648,6 +792,103 @@ JSValueRef JSAccountManager::getTypeProperty(JSContextRef context,
     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);
+}
+
+
 }
 }
 }
index 9cf010d..06c99a8 100755 (executable)
@@ -139,14 +139,14 @@ class JSAccountManager
                const JSValueRef arguments[],
                JSValueRef* exception);
 
-       static JSValueRef findAccountsByTags(JSContextRef context,
+       static JSValueRef findAccounts(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
                const JSValueRef arguments[],
                JSValueRef* exception);
 
-       static JSValueRef findServicesByTags(JSContextRef context,
+       static JSValueRef findServices(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
@@ -172,9 +172,19 @@ class JSAccountManager
             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);
 
 };
 }
index cc6b6cf..02f5b40 100755 (executable)
@@ -185,7 +185,8 @@ JSValueRef JSAccountServices::getProperty(JSContextRef context,
                }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_TAGS)) {
 //                     return converter->toJSValueRef(accountServicePtr->getTags());
                }else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SETTINGS)) {
-                       return converter->toJSValueRef(accountServicePtr->getSettings());
+                       std::string settingsString = accountServicePtr->getSettings();
+                       return converter->toJSONString(settingsString);
                }
        }Catch(WrtDeviceApis::Commons::Exception){
                AccountLogWarning("trying to get incorrect value");
@@ -201,27 +202,31 @@ bool JSAccountServices::setProperty(JSContextRef context,
                JSValueRef value,
                JSValueRef* exception)
 {
-       LogDebug("entered");
-       Try
-       {
+       LogDebug("<<<");
+       Try{
                AccountConverterFactory::ConverterType converter = AccountConverterFactory::getConverter(context);
-               AccountServicesPtr Properties = getPrivData(object);
-
-        if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_NAME)) {
-            std::string serviceName = converter->toString(value);
-            Properties->setName(serviceName);
-            return true;
-        } else if (JSStringIsEqualToUTF8CString(propertyName, ACCOUNT_SERVICES_ATTR_SERVICE_SERVICE_TYPE_ID)) {
-            std::string serviceTypeId = converter->toString(value);
-            Properties->setServiceTypeId(serviceTypeId);
-            return true;
-        }
-
-               return true;
-       }
-       Catch(WrtDeviceApis::Commons::Exception)
-       {
-               LogWarning("trying to set incorrect value");
+               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");
index 3816592..9172d79 100755 (executable)
@@ -202,24 +202,24 @@ void AccountResponseDispatcher::OnAnswerReceived(
         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");
-    }
+//    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/old/JSAccountService.cpp b/src/standards/Tizen/Account/old/JSAccountService.cpp
new file mode 100755 (executable)
index 0000000..d4fc69d
--- /dev/null
@@ -0,0 +1,597 @@
+/*
+ * 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
new file mode 100755 (executable)
index 0000000..523dec3
--- /dev/null
@@ -0,0 +1,163 @@
+/*
+ * 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_ */
+
index 5568f30..b870d5f 100755 (executable)
@@ -185,6 +185,17 @@ static FunctionMapping createAccountFunctions()
                                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,
@@ -196,6 +207,17 @@ static FunctionMapping createAccountFunctions()
                                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,
index f3ba0d9..23bdc4a 100755 (executable)
@@ -32,7 +32,9 @@ namespace Account{
 #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"
index 9b98d5a..d3e67f5 100755 (executable)
@@ -27,6 +27,7 @@
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>
 #include "JSAccountManager.h"
+#include "JSAccount.h"
 
 using namespace TizenApis::Api::Account;
 using namespace WrtDeviceApis::Commons;
@@ -60,10 +61,14 @@ 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::JSAccountManager::getClassRef(),
-        NULL)
+               "Account",
+               TizenApis::Tizen1_0::Account::JSAccount::getClassRef(),
+               NULL)
 PLUGIN_CLASS_MAP_END
 
 #undef PIM
diff --git a/src/standards/Tizen/Alarm/AlarmAbsolute.cpp b/src/standards/Tizen/Alarm/AlarmAbsolute.cpp
new file mode 100755 (executable)
index 0000000..5e1565b
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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 "AlarmAbsolute.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {
+
+AlarmAbsolute::AlarmAbsolute()
+{
+    m_alarmRecurrence = AlarmRecurrencePtr(new AlarmRecurrence());
+    m_isRecurrence = false;
+}
+
+AlarmAbsolute::~AlarmAbsolute()
+{
+}
+
+int AlarmAbsolute::getId() const
+{
+    return m_id;
+}
+
+void AlarmAbsolute::setId(const int id)
+{
+    m_id = id;
+}
+
+bool AlarmAbsolute::isRecurrence()
+{
+    return m_isRecurrence;
+}
+
+void AlarmAbsolute::setIsRecurrence(bool value)
+{
+    m_isRecurrence = value;
+}
+
+AlarmRecurrencePtr AlarmAbsolute::getRecurrence()
+{
+    return m_alarmRecurrence;
+}
+void AlarmAbsolute::setRecurrence(AlarmRecurrencePtr ptr)
+{
+    m_alarmRecurrence->setData(ptr);
+}
+
+void AlarmAbsolute::setDate(struct tm date)
+{
+    LogError("=== Before Assign ===");
+    LogError("[ILOVEFILM] Date  = " << "  Sec : " << date.tm_sec << "  Min : "<< date.tm_min
+    << "  Hour" << date.tm_hour << "Day : " << date.tm_mday << "  MON : " << date.tm_mon 
+    << "  Year : " <<  date.tm_year);
+    m_date = date;
+    LogError("=== After Assign ===");
+    LogError("[ILOVEFILM] Date  = " << "  Sec : " << m_date.tm_sec << "  Min : "<< m_date.tm_min
+    << "  Hour" << m_date.tm_hour << "Day : " << m_date.tm_mday << "  MON : " << m_date.tm_mon 
+    << "  Year : " <<  m_date.tm_year);
+}
+
+struct tm AlarmAbsolute::getDate()
+{
+        LogError("[ILOVEFILM] Date  = " << "  Sec : " << m_date.tm_sec << "  Min : "<< m_date.tm_min
+            << "  Hour" << m_date.tm_hour << "Day : " << m_date.tm_mday << "  MON : " << m_date.tm_mon 
+            << "  Year : " <<  m_date.tm_year);
+    return m_date;
+}
+
+void AlarmAbsolute::setDelay(int delay)
+{
+    m_delay = delay;
+}
+
+int AlarmAbsolute::getDelay()
+{
+    return m_delay;
+}
+
+void AlarmAbsolute::setAlarmType(alarm_type_e type)
+{
+    m_alarmType = type;
+}
+AlarmAbsolute::alarm_type_e AlarmAbsolute::getAlarmType()
+{
+    return m_alarmType;
+}
+
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/Alarm/AlarmAbsolute.h b/src/standards/Tizen/Alarm/AlarmAbsolute.h
new file mode 100755 (executable)
index 0000000..26c74bc
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef TIZENAPIS_API_ALARMABSOLUTE_H_\r
+#define TIZENAPIS_API_ALARMABSOLUTE_H_\r
+\r
+#include <string>\r
+#include <vector>
+#include <dpl/log/log.h>\r
+#include <dpl/shared_ptr.h>\r
+#include <time.h>\r
+#include "AlarmRecurrence.h"\r
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {\r
+\r
+class AlarmAbsolute;\r
+typedef DPL::SharedPtr<AlarmAbsolute> AlarmAbsolutePtr;\r
+typedef std::vector<AlarmAbsolutePtr> AlarmAbsoluteArrayPtr;\r
+\r
+class AlarmAbsolute\r
+{
+  public:\r
+    typedef enum {\r
+        ALARM_TYPE_DELAY,
+        ALARM_TYPE_DATE,
+        ALARM_TYPE_INVALID,
+    } alarm_type_e;
+    \r
+    AlarmAbsolute();\r
+    ~AlarmAbsolute();\r
+    AlarmRecurrencePtr getRecurrence();\r
+    void setRecurrence(AlarmRecurrencePtr ptr);\r
+    void setIsRecurrence(bool value);\r
+    int getId() const;\r
+    void setId(const int id);\r
+    void setDate(struct tm date);\r
+    struct tm getDate();\r
+    void setDelay(int delay);\r
+    int getDelay();\r
+    void setAlarmType(alarm_type_e type);\r
+    alarm_type_e getAlarmType();\r
+    bool isRecurrence();\r
+\r
+  private:\r
+    int m_id;\r
+    int m_delay;\r
+    struct tm m_date;\r
+    bool m_isRecurrence;\r
+    AlarmRecurrencePtr m_alarmRecurrence;\r
+    alarm_type_e m_alarmType;\r
+    \r
+};\r
+\r
+}
+}
+}\r
+\r
+#endif\r
diff --git a/src/standards/Tizen/Alarm/AlarmConverter.cpp b/src/standards/Tizen/Alarm/AlarmConverter.cpp
new file mode 100755 (executable)
index 0000000..59e69e7
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * 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 <vector>
+#include <app.h>
+#include <time.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "AlarmRecurrence.h"
+#include "JSAlarmRecurrence.h"
+#include "AlarmConverter.h"
+
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Tizen1_0::Alarm;
+using namespace TizenApis::Api::Alarm;
+
+AlarmConverter::AlarmConverter(JSContextRef context) : WrtDeviceApis::CommonsJavaScript::Converter(context)
+{
+
+}
+
+AlarmConverter::~AlarmConverter()
+{
+
+}
+
+AlarmRecurrence::alarm_frequency_e AlarmConverter::toRecurrenceFrequency(
+        std::string tizenValue) const
+{
+    if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE))
+        return AlarmRecurrence::MINUTELY_RECURRENCE;
+    else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE))
+        return AlarmRecurrence::HOURLY_RECURRENCE;
+    else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE))
+        return AlarmRecurrence::DAILY_RECURRENCE;
+    else if (!tizenValue.compare(TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE))
+        return AlarmRecurrence::WEEKLY_RECURRENCE;
+
+    return AlarmRecurrence::NO_RECURRENCE;
+}
+
+std::string AlarmConverter::toTizenValue(
+       AlarmRecurrence::alarm_frequency_e frequency ) const
+{
+    switch (frequency) {
+    case AlarmRecurrence::MINUTELY_RECURRENCE:
+        return TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE;
+    case AlarmRecurrence::HOURLY_RECURRENCE:
+        return TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE;
+    case AlarmRecurrence::DAILY_RECURRENCE:
+        return TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE;
+    case AlarmRecurrence::WEEKLY_RECURRENCE:
+        return TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE;
+    default:
+        return "";
+        break;
+    }
+}
+
+
+int toNativeValue(std::vector<std::string> daysOfTheWeek)
+{
+    int nativeValue = 0;
+
+    for( unsigned int i=0; i<daysOfTheWeek.size(); i++ )
+    {
+        if( daysOfTheWeek[i]=="SU" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_SUNDAY;
+        else if( daysOfTheWeek[i]=="MO" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_MONDAY ;
+        else if( daysOfTheWeek[i]=="TU" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_TUESDAY ;
+        else if( daysOfTheWeek[i]=="WE" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_WEDNESDAY;
+        else if( daysOfTheWeek[i]=="TH" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_THURSDAY ;
+        else if( daysOfTheWeek[i]=="FR" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_FRIDAY ;
+        else if( daysOfTheWeek[i]=="SA" )
+            nativeValue = nativeValue | ALARM_WEEK_FLAG_SATURDAY ;
+    }
+    return nativeValue; 
+}
+
+
+service_h AlarmConverter::toService(std::string id)
+{
+    service_h service;
+    service_create(&service);
+    LogError("[ILOVEFILM] Enter AlarmConverter toService std package = "  << id.c_str());    
+
+    service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+    service_set_package(service, id.c_str());
+    return service;
+}
+service_h AlarmConverter::toService(std::string id, std::string page)
+{
+    service_h service;
+    service_create(&service);
+
+    LogError("[ILOVEFILM] Enter AlarmConverter toService std package = "  << id.c_str());    
+    
+    service_set_operation(service, SERVICE_OPERATION_DEFAULT);
+    service_set_package(service, id.c_str());
+    return service;
+}
+}
+}
+}
+
diff --git a/src/standards/Tizen/Alarm/AlarmConverter.h b/src/standards/Tizen/Alarm/AlarmConverter.h
new file mode 100755 (executable)
index 0000000..985560f
--- /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 _JS_TIZEN_ALARM_CONVERTER_H_
+#define _JS_TIZEN_ALARM_CONVERTER_H_
+
+#include <dpl/log/log.h>
+#include <vector>
+#include <string>
+#include <app.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include "AlarmRecurrence.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Alarm;
+
+
+class AlarmConverter : public WrtDeviceApis::CommonsJavaScript::Converter
+{
+public:
+    using Converter::toJSValueRef;
+    explicit AlarmConverter(JSContextRef context);
+    virtual ~AlarmConverter();
+
+    AlarmRecurrence::alarm_frequency_e toRecurrenceFrequency(std::string tizenValue) const;
+    std::string toTizenValue(AlarmRecurrence::alarm_frequency_e frequency ) const;
+    int toNativeValue(std::vector<std::string> daysOfTheWeek);
+    int toNativeValue(int interval);    
+    service_h toService(std::string id);
+    service_h toService(std::string id, std::string page);
+};
+
+typedef ConverterFactory<AlarmConverter> AlarmConverterFactory;
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_ALARM_CONVERTER_H_ */
diff --git a/src/standards/Tizen/Alarm/AlarmRecurrence.cpp b/src/standards/Tizen/Alarm/AlarmRecurrence.cpp
new file mode 100755 (executable)
index 0000000..238d5c7
--- /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 "AlarmRecurrence.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {
+
+AlarmRecurrence::AlarmRecurrence()
+{
+    m_frequency = NO_RECURRENCE;
+    m_interval = 0;
+}
+
+AlarmRecurrence::~AlarmRecurrence()
+{
+}
+
+void AlarmRecurrence::setFrequency(AlarmRecurrence::alarm_frequency_e frequency)
+{
+    m_frequency = frequency;
+}
+
+AlarmRecurrence::alarm_frequency_e AlarmRecurrence::getFrequency()
+{
+    return m_frequency;
+}
+void AlarmRecurrence::setInterval(int interval)
+{
+    m_interval = interval;
+}
+int AlarmRecurrence::getInterval()
+{
+    return m_interval;
+}
+void AlarmRecurrence::setDaysOfTheWeek(std::vector<std::string> daysOfTheWeek)
+{
+    // copy vector
+    m_daysOfTheWeek.clear();
+    m_daysOfTheWeek.assign(daysOfTheWeek.begin(), daysOfTheWeek.end());
+    m_frequency = DAYS_OF_THE_WEEK_RECURRENCE;
+}
+std::vector<std::string> AlarmRecurrence::getDaysOfTheWeek()
+{
+    return m_daysOfTheWeek;
+}
+
+void AlarmRecurrence::setData(AlarmRecurrencePtr ptr)
+{
+    setFrequency(ptr->getFrequency());
+    setInterval(ptr->getInterval());
+    setDaysOfTheWeek(ptr->getDaysOfTheWeek());
+}
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/Alarm/AlarmRecurrence.h b/src/standards/Tizen/Alarm/AlarmRecurrence.h
new file mode 100755 (executable)
index 0000000..04b7209
--- /dev/null
@@ -0,0 +1,51 @@
+#ifndef TIZENAPIS_API_ALARMRECURRENCE_H_\r
+#define TIZENAPIS_API_ALARMRECURRENCE_H_\r
+\r
+#include <string>\r
+#include <vector>
+#include <dpl/log/log.h>\r
+#include <dpl/shared_ptr.h>
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {\r
+\r
+class AlarmRecurrence;\r
+typedef DPL::SharedPtr<AlarmRecurrence> AlarmRecurrencePtr;\r
+\r
+class AlarmRecurrence\r
+{
+  public:\r
+    typedef enum\r
+    {\r
+        NO_RECURRENCE,\r
+        MINUTELY_RECURRENCE = 60,               // The alarm trigger minutely\r
+        HOURLY_RECURRENCE = 3600,               // The alarm trigger hourly\r
+        DAILY_RECURRENCE = 86400,               // The alarm trigger daily\r
+        WEEKLY_RECURRENCE = 604800,              // The alarm trigger weekly\r
+        DAYS_OF_THE_WEEK_RECURRENCE,\r
+        INVALID_RECURRENCE = 1000000,\r
+    } alarm_frequency_e;\r
+    \r
+    AlarmRecurrence();\r
+    ~AlarmRecurrence();\r
+    void setFrequency(AlarmRecurrence::alarm_frequency_e frequency);\r
+    AlarmRecurrence::alarm_frequency_e getFrequency();\r
+    void setInterval(int interval);\r
+    int getInterval();\r
+    void setDaysOfTheWeek(std::vector<std::string> daysOfTheWeek);\r
+    std::vector<std::string> getDaysOfTheWeek();\r
+    void setData(AlarmRecurrencePtr ptr);\r
+\r
+  private:\r
+    alarm_frequency_e m_frequency;\r
+    int m_interval;\r
+    std::vector<std::string> m_daysOfTheWeek;\r
+};\r
+\r
+\r
+}\r
+}
+}\r
+\r
+#endif\r
diff --git a/src/standards/Tizen/Alarm/AlarmRelative.cpp b/src/standards/Tizen/Alarm/AlarmRelative.cpp
new file mode 100755 (executable)
index 0000000..7d2f647
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * 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 "AlarmRelative.h"
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {
+
+AlarmRelative::AlarmRelative()
+{
+    m_alarmRecurrence = AlarmRecurrencePtr(new AlarmRecurrence());
+    m_isRecurrence = false;
+}
+
+AlarmRelative::~AlarmRelative()
+{
+}
+
+int AlarmRelative::getId() const
+{
+    return m_id;
+}
+
+void AlarmRelative::setId(const int id)
+{
+    m_id = id;
+}
+
+bool AlarmRelative::isRecurrence()
+{
+    return m_isRecurrence;
+}
+
+void AlarmRelative::setIsRecurrence(bool value)
+{
+    m_isRecurrence = value;
+}
+
+AlarmRecurrencePtr AlarmRelative::getRecurrence()
+{
+    return m_alarmRecurrence;
+}
+void AlarmRelative::setRecurrence(AlarmRecurrencePtr ptr)
+{
+    m_alarmRecurrence->setData(ptr);
+}
+
+void AlarmRelative::setDate(struct tm date)
+{
+    LogError("=== Before Assign ===");
+    LogError("[ILOVEFILM] Date  = " << "  Sec : " << date.tm_sec << "  Min : "<< date.tm_min
+    << "  Hour" << date.tm_hour << "Day : " << date.tm_mday << "  MON : " << date.tm_mon 
+    << "  Year : " <<  date.tm_year);
+    m_date = date;
+    LogError("=== After Assign ===");
+    LogError("[ILOVEFILM] Date  = " << "  Sec : " << m_date.tm_sec << "  Min : "<< m_date.tm_min
+    << "  Hour" << m_date.tm_hour << "Day : " << m_date.tm_mday << "  MON : " << m_date.tm_mon 
+    << "  Year : " <<  m_date.tm_year);
+}
+
+struct tm AlarmRelative::getDate()
+{
+        LogError("[ILOVEFILM] Date  = " << "  Sec : " << m_date.tm_sec << "  Min : "<< m_date.tm_min
+            << "  Hour" << m_date.tm_hour << "Day : " << m_date.tm_mday << "  MON : " << m_date.tm_mon 
+            << "  Year : " <<  m_date.tm_year);
+    return m_date;
+}
+
+void AlarmRelative::setDelay(int delay)
+{
+    m_delay = delay;
+}
+
+int AlarmRelative::getDelay()
+{
+    return m_delay;
+}
+
+void AlarmRelative::setAlarmType(alarm_type_e type)
+{
+    m_alarmType = type;
+}
+AlarmRelative::alarm_type_e AlarmRelative::getAlarmType()
+{
+    return m_alarmType;
+}
+
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/Alarm/AlarmRelative.h b/src/standards/Tizen/Alarm/AlarmRelative.h
new file mode 100755 (executable)
index 0000000..e971a19
--- /dev/null
@@ -0,0 +1,57 @@
+#ifndef TIZENAPIS_API_ALARMRELATIVE_H_\r
+#define TIZENAPIS_API_ALARMRELATIVE_H_\r
+\r
+#include <string>\r
+#include <vector>
+#include <dpl/log/log.h>\r
+#include <dpl/shared_ptr.h>\r
+#include <time.h>\r
+#include "AlarmRecurrence.h"\r
+
+namespace TizenApis {
+namespace Api {
+namespace Alarm {\r
+\r
+class AlarmRelative;\r
+typedef DPL::SharedPtr<AlarmRelative> AlarmRelativePtr;\r
+typedef std::vector<AlarmRelativePtr> AlarmRelativeArrayPtr;\r
+\r
+class AlarmRelative\r
+{
+  public:\r
+    typedef enum {\r
+        ALARM_TYPE_DELAY,
+        ALARM_TYPE_DATE,
+        ALARM_TYPE_INVALID,
+    } alarm_type_e;
+    \r
+    AlarmRelative();\r
+    ~AlarmRelative();\r
+    AlarmRecurrencePtr getRecurrence();\r
+    void setRecurrence(AlarmRecurrencePtr ptr);\r
+    void setIsRecurrence(bool value);\r
+    int getId() const;\r
+    void setId(const int id);\r
+    void setDate(struct tm date);\r
+    struct tm getDate();\r
+    void setDelay(int delay);\r
+    int getDelay();\r
+    void setAlarmType(alarm_type_e type);\r
+    alarm_type_e getAlarmType();\r
+    bool isRecurrence();\r
+\r
+  private:\r
+    int m_id;\r
+    int m_delay;\r
+    struct tm m_date;\r
+    bool m_isRecurrence;\r
+    AlarmRecurrencePtr m_alarmRecurrence;\r
+    alarm_type_e m_alarmType;\r
+    \r
+};\r
+\r
+}
+}
+}\r
+\r
+#endif\r
diff --git a/src/standards/Tizen/Alarm/CMakeLists.txt b/src/standards/Tizen/Alarm/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..4ba0e7b
--- /dev/null
@@ -0,0 +1,34 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-alarm")
+
+pkg_search_module(alarm REQUIRED capi-appfw-application)
+
+include_directories(${alarm_INCLUDE_DIRS})
+
+set(SRCS
+  AlarmAbsolute.cpp
+  AlarmConverter.cpp
+  AlarmRecurrence.cpp
+  AlarmRelative.cpp
+  JSAbstractAlarm.cpp
+  JSAlarmAbsolute.cpp
+  JSAlarmManager.cpp
+  JSAlarmRecurrence.cpp
+  JSAlarmRelative.cpp
+  plugin_initializer.cpp
+  ../Common/JSTizenException.cpp
+  ../Common/TizenExceptionData.cpp
+  ../Common/JSTizenExceptionFactory.cpp
+)
+set(CMAKE_INSTALL_RPATH
+    ${CMAKE_INSTALL_RPATH}
+    "${CMAKE_INSTALL_PREFIX}/tizen-1.0-alarm"
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  ${LIBS_COMMON}
+  ${alarm_LIBRARIES}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION tizen-1.0-alarm)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION tizen-1.0-alarm)
diff --git a/src/standards/Tizen/Alarm/JSAbstractAlarm.cpp b/src/standards/Tizen/Alarm/JSAbstractAlarm.cpp
new file mode 100755 (executable)
index 0000000..2212824
--- /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.
+ */
+
+#include <cassert>
+#include <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <app.h>
+#include <time.h>
+#include "JSAbstractAlarm.h"
+
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSAbstractAlarm::m_jsClassRef = NULL;
+
+JSClassDefinition JSAbstractAlarm::m_jsClassInfo = {
+               0,
+               kJSClassAttributeNone,
+               "AbstractAlarm",
+               NULL,
+               NULL,
+               NULL,
+               initialize,
+               finalize,
+               NULL, //hasProperty,
+               NULL, //getProperty,
+               NULL, //setProperty,
+               NULL, //deleteProperty,Geolocation
+               NULL, //getPropertyNames,
+               NULL,
+               NULL, // constructor
+               hasInstance,
+               NULL
+};
+const JSClassRef JSAbstractAlarm::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAbstractAlarm::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSAbstractAlarm::initialize(JSContextRef context, JSObjectRef object) 
+{
+
+}
+void JSAbstractAlarm::finalize(JSObjectRef object) 
+{
+
+}
+
+bool JSAbstractAlarm::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+} // Alarm
+} // Tizen1_0 
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Alarm/JSAbstractAlarm.h b/src/standards/Tizen/Alarm/JSAbstractAlarm.h
new file mode 100755 (executable)
index 0000000..5083ff3
--- /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 _JS_TIZEN_ABSTRACTALARM
+#define _JS_TIZEN_ABSTRACTALARM
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+class JSAbstractAlarm {
+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;
+};
+
+}// Alarm
+} // Tizen1_0
+} // TizenApis
+
+#endif
diff --git a/src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp b/src/standards/Tizen/Alarm/JSAlarmAbsolute.cpp
new file mode 100755 (executable)
index 0000000..a8a8921
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "AlarmAbsolute.h"
+#include "AlarmRecurrence.h"
+#include "AlarmConverter.h"
+#include <app.h>
+#include <time.h>
+#include "JSAlarmRecurrence.h"
+#include "JSAbstractAlarm.h"
+#include "JSAlarmAbsolute.h"
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Alarm;
+
+JSClassRef JSAlarmAbsolute::m_jsClassRef = NULL;
+
+JSClassDefinition JSAlarmAbsolute::m_jsClassInfo = {
+               0,
+               kJSClassAttributeNone,
+               "AlarmAbsolute",
+               JSAbstractAlarm::getClassRef(),
+               m_property,
+               m_function,
+               initialize,
+               finalize,
+               NULL, //hasProperty,
+               NULL, //getProperty,
+               NULL, //setProperty,
+               NULL, //deleteProperty,Geolocation
+               NULL, //getPropertyNames,
+               NULL,
+               constructor, // constructor
+               hasInstance,
+               NULL
+};
+
+JSStaticFunction JSAlarmAbsolute::m_function[] = { 
+        { "getNextScheduledDate",JSAlarmAbsolute::getNextScheduledDate,kJSPropertyAttributeNone },
+        { 0, 0, 0 }
+};
+
+JSStaticValue JSAlarmAbsolute::m_property[] = {
+       { "id", getId, NULL, kJSPropertyAttributeReadOnly },
+       { "recurrenceRule", getRecurrenceRule, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }                                                                                            
+};
+
+const JSClassRef JSAlarmAbsolute::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAlarmAbsolute::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSAlarmAbsolute::initialize(JSContextRef context, JSObjectRef object) 
+{
+
+}
+void JSAlarmAbsolute::finalize(JSObjectRef object) 
+{
+
+}
+
+bool JSAlarmAbsolute::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+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);
+    bool isRecurrence = false; 
+    
+    if(argumentCount < 1)
+    {
+        LogWarning("Argument is not corrent");
+    }
+    
+    if( validator.isDate(arguments[0]))
+    {   
+        // date
+        date = converter.toDateTm(arguments[0]);
+        LogWarning("Argument is not corrent");
+    }
+    
+    if(argumentCount == 2)
+    {
+        // TODO : check it is TimeDuration object.
+        #if 0
+        if(JSValueIsObjectOfClass(ctx, arguments[1], JSAlarmRecurrence::getClassRef()))
+        {
+            // TODO : Get interval from TimeUnit 
+            isRecurrence = true;
+        }
+        #endif
+    }
+    
+    if(isRecurrence == true) {
+        return JSValueToObject(ctx, createJSObject(ctx, date, interval), exception);
+    }
+    else
+    {
+        return JSValueToObject(ctx, createJSObject(ctx, date), exception);
+    }
+
+
+}
+AlarmAbsolutePtr JSAlarmAbsolute::getPrivData(JSObjectRef object)
+{
+       JSAlarmAbsolutePriv *priv = static_cast<JSAlarmAbsolutePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       AlarmAbsolutePtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+
+JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, const int id)
+{
+    AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute());
+    
+    privateData->setId(id);
+
+    JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+}
+
+JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date, int interval)
+{
+    AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute());
+
+    privateData->setDate(date);
+
+    JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+
+}
+
+JSValueRef JSAlarmAbsolute::createJSObject(JSContextRef context, struct tm date)
+{
+    AlarmAbsolutePtr privateData = AlarmAbsolutePtr(new AlarmAbsolute());
+    privateData->setDate(date);
+    
+    JSAlarmAbsolutePriv *priv = new JSAlarmAbsolutePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+
+}
+
+JSValueRef JSAlarmAbsolute::getNextScheduledDate(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{ 
+    struct tm date;
+    Converter converter(ctx);
+    int id;
+    Try
+    {
+        AlarmAbsolutePtr privateData = getPrivData(object);
+        id = privateData->getId();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    
+    int err = alarm_get_scheduled_date(id, &date);
+
+    JSValueRef result = converter.toJSValueRef(date);
+
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+    return result;     
+}
+
+JSValueRef JSAlarmAbsolute::getId(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    Converter converter(ctx);
+    int id;
+    Try
+    {
+        AlarmAbsolutePtr privateData = getPrivData(object);
+        id = privateData->getId();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(id);
+}
+
+
+JSValueRef JSAlarmAbsolute::getRecurrenceRule(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    #if 0
+    Converter converter(ctx);
+    int interval;
+    Try
+    {
+        AlarmPtr privateData = getPrivData(object);
+        interval = privateData->getRecurrence();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(interval);
+    #endif
+
+}
+
+} // Alarm
+} // Tizen1_0 
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Alarm/JSAlarmAbsolute.h b/src/standards/Tizen/Alarm/JSAlarmAbsolute.h
new file mode 100755 (executable)
index 0000000..c1afbae
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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_ALARM
+#define _JS_TIZEN_ALARM
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Application/IApplication.h>
+#include "AlarmAbsolute.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace TizenApis::Api::Alarm;
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AlarmAbsolutePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAlarmAbsolutePriv;
+
+class JSAlarmAbsolute {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    static JSValueRef createJSObject(JSContextRef context, const int id);
+    static JSValueRef createJSObject(JSContextRef context, struct tm date, int interval);
+    static JSValueRef createJSObject(JSContextRef context, struct tm date);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+
+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 getNextScheduledDate(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+private:
+    static Api::Alarm::AlarmAbsolutePtr getPrivData(JSObjectRef object);
+   
+    static JSValueRef getId(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception);
+
+    static JSValueRef getRecurrenceRule(JSContextRef context,
+                                                JSObjectRef object,
+                                                JSStringRef propertyName,
+                                                JSValueRef* exception);
+
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+    static JSStaticFunction m_function[];
+    static JSStaticValue m_property[];
+
+};
+
+}// Alarm
+} // Tizen1_0
+} // TizenApis
+
+#endif
diff --git a/src/standards/Tizen/Alarm/JSAlarmManager.cpp b/src/standards/Tizen/Alarm/JSAlarmManager.cpp
new file mode 100755 (executable)
index 0000000..938947d
--- /dev/null
@@ -0,0 +1,447 @@
+/*
+ * 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 <vector>
+#include <app.h>
+#include <time.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+
+#include "AlarmAbsolute.h"
+#include "AlarmConverter.h"
+#include "JSAlarmManager.h"
+#include "JSAlarmAbsolute.h"
+
+using namespace std;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Tizen1_0::Alarm;
+using namespace TizenApis::Api::Alarm;
+
+#if 0
+using TizenApis::Api::Alarm::Alarm;
+using TizenApis::Tizen1_0::Alarm::JSAlarm;
+class JSAlarm;
+#endif
+
+#if 0
+using namespace std;
+using namespace DPL;
+using namespace TizenApis::Api::Alarm;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::CommonsJavaScript;
+#endif
+
+
+static bool alarm_iterate_callback(int alarm_id, void *user_data)
+{
+    vector<int> *alarmIds = reinterpret_cast<vector<int>*>(user_data);
+   
+    alarmIds->push_back(alarm_id);
+    return true;
+}
+
+
+JSClassRef JSAlarmManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSAlarmManager::m_jsClassInfo = {
+        0,
+        kJSClassAttributeNone,
+        "AlarmManager",
+        NULL,
+        NULL,
+        m_function,
+        initialize,
+        finalize,
+        NULL, //hasProperty,
+        NULL, //getProperty,
+        NULL, //setProperty,
+        NULL, //deleteProperty,Geolocation
+        NULL, //getPropertyNames,
+        NULL,
+        NULL, // constructor
+        hasInstance,
+        NULL
+};
+
+JSStaticFunction JSAlarmManager::m_function[] = {    
+        { "add",JSAlarmManager::add,kJSPropertyAttributeNone },
+        { "remove",JSAlarmManager::remove,kJSPropertyAttributeNone },
+        { "getAlarms",JSAlarmManager::getAlarms,kJSPropertyAttributeNone },
+        { 0, 0, 0 }
+};
+
+const JSClassRef JSAlarmManager::getClassRef() 
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAlarmManager::getClassInfo() 
+{
+    return &m_jsClassInfo;
+}
+
+void JSAlarmManager::initialize(JSContextRef ctx, JSObjectRef object) 
+{
+    
+}
+void JSAlarmManager::finalize(JSObjectRef object) 
+{
+        
+}
+
+bool JSAlarmManager::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception) {
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSAlarmManager::add(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+
+    #if 0
+    service_h service;
+    char *package;
+    Alarm::alarm_type_e type = Alarm::ALARM_TYPE_INVALID;
+    struct tm startDate;
+    int delay;
+    AlarmRecurrencePtr recurrencePtr;
+    int interval = 0;
+    int id;
+    
+    LogError("[ILOVEFILM] Enter add");
+    
+    Validator check(ctx, exception);
+    AlarmConverter converter(ctx);
+
+    LogError("[ILOVEFILM] Enter add2");
+    if(argumentCount < 2) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    } 
+    LogError("[ILOVEFILM] Enter add3");
+    if(!JSValueIsObjectOfClass(ctx, arguments[0], JSAlarmAbsolute::getClassRef())) {
+       ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    }
+    
+    // need to know
+    // 1. type(delay, date)
+    // 2. weekly or time
+    // 3. convert freqeuncy to second    
+
+   // 1. GetAlarmPrivate Data
+    LogError("[ILOVEFILM] Enter add4");
+    JSObjectRef alarmObj = JSValueToObject(ctx, arguments[0], exception);
+    
+    LogError("[ILOVEFILM] Enter add5");
+    JSAlarmPriv *priv = static_cast<JSAlarmPriv*>(JSObjectGetPrivate(alarmObj));
+    if (!priv) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    }
+    LogError("[ILOVEFILM] Enter add6");
+    AlarmAbsolutePtr alarmPtr = priv->getObject();
+    if (!alarmPtr) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    } 
+
+    LogError("[ILOVEFILM] Enter add7");
+
+    type = alarmPtr->getAlarmType();
+    if(type == Alarm::ALARM_TYPE_DELAY)
+    {
+        LogError("[ILOVEFILM] Enter add8 get Date");
+        delay = alarmPtr->getDelay();
+    }
+    else if(type == Alarm::ALARM_TYPE_DATE)
+    {
+         LogError("[ILOVEFILM] Enter add8 get Delay");
+        startDate = alarmPtr->getDate();
+
+    }
+
+    if(type == Alarm::ALARM_TYPE_DELAY)
+    {
+        service = converter.toService(converter.toString(arguments[1]));
+        if(alarmPtr->isRecurrence())
+        {
+            recurrencePtr = alarmPtr->getRecurrence();
+        }
+        else
+        {
+            int err = alarm_schedule_after_delay(service, delay, 0, &id);
+            alarmPtr->setId(id);
+        }      
+        
+    } else if(type == Alarm::ALARM_TYPE_DATE)
+    {
+        LogError("[ILOVEFILM] Enter add9");
+        service = converter.toService(converter.toString(arguments[1]));
+        if(alarmPtr->isRecurrence())
+        {
+            LogError("[ILOVEFILM] Enter add10");
+            recurrencePtr = alarmPtr->getRecurrence();
+            int err = alarm_schedule_at_date(service, &startDate, 0, &id);
+        }
+        else
+        {
+            char *package;
+            service_get_package(service, &package);
+            struct tm current;
+            alarm_get_current_time(&current);
+            LogError("[ILOVEFILM] Current Date  = " << "Sec : " << current.tm_sec << "  Min : "<< current.tm_min
+                << "  Hour : " << current.tm_hour << "  Day : " << current.tm_mday << "  MON : " << current.tm_mon 
+                << "  Year : " <<  current.tm_year);
+
+            LogError("[ILOVEFILM] Enter add11 service package = " << package);
+            LogError("[ILOVEFILM] Date  = " << "Sec : " << startDate.tm_sec << "  Min : "<< startDate.tm_min
+                << "  Hour : " << startDate.tm_hour << "  Day : " << startDate.tm_mday << "  MON : " << startDate.tm_mon 
+                << "  Year : " <<  startDate.tm_year);
+            int err = alarm_schedule_at_date(service, &startDate, 0, &id);
+            LogError("[ILOVEFILM] Enter add12 error code " << err );
+
+           
+            LogError("[ILOVEFILM] Enter add12 error code ALARM_ERROR_INVALID_PARAMETER = " << ALARM_ERROR_INVALID_PARAMETER );
+            LogError("[ILOVEFILM] Enter add12 error code ALARM_ERROR_INVALID_DATE = " << ALARM_ERROR_INVALID_DATE );
+            LogError("[ILOVEFILM] Enter add12 error code ALARM_ERROR_CONNECTION_FAIL = " << ALARM_ERROR_CONNECTION_FAIL );
+            
+        }
+        
+        alarmPtr->setId(id);
+    }
+    #endif
+}
+
+
+JSValueRef JSAlarmManager::remove(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    int err;
+
+    if(argumentCount < 1 || !JSValueIsString(ctx, arguments[0])) 
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+
+    Converter converter(ctx);
+    // todo : check exception or error
+    string stringID = converter.toString(arguments[0]);
+    
+    int id = atoi(stringID.c_str());
+
+    err = alarm_cancel(id);
+
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+
+    return JSValueMakeUndefined(ctx);
+
+}
+
+
+JSValueRef JSAlarmManager::getAlarms(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    int error;
+    vector<int> alarmIds;
+    error = alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds);
+
+    if(error != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+
+#if 0
+    AlarmArrayPtr alarmObjectArrary;
+    for(int i = 0; i < alarmIds.size(); i++)
+    {
+        TizenApis::Tizen1_0::Alarm::JSAlarmAbsolute::createJSObject(ctx, alarmIds[i]);
+    } 
+#endif
+    
+}
+
+#if 0
+JSValueRef JSAlarmManager::createAlarm(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    struct tm date;
+    int id;
+    service_h service;
+    char *package;
+
+    Validator check(ctx,exception);
+
+    if(argumentCount < 3) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if(JSValueIsNumber(ctx, arguments[1])) {
+        return createAfterDelay(ctx, object, thisObject, argumentCount, arguments, exception);
+    }
+
+    if(check.isCallback(arguments[0]) | check.isNullOrUndefined(arguments[0])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if(!check.isDate(arguments[1])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if(!JSValueIsNumber(ctx, arguments[2])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+    
+    AlarmConverter alarmConverter(ctx);
+    date = alarmConverter.toDateTm(arguments[1]);
+    int period = (int)JSValueToNumber(ctx, arguments[2], exception);
+    service = alarmConverter.toService(arguments[0]);
+    int err = alarm_schedule_at_date(service, &date, period, &id);
+    
+    service_destroy(service);
+    
+    if(err != ALARM_ERROR_NONE) {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+    
+    return alarmConverter.toJSValueRef(id);
+}
+
+
+
+JSValueRef JSAlarmManager::createAfterDelay(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    struct tm date;
+    int id;
+    service_h service;
+    char *package;
+
+    Validator check(ctx,exception);
+
+    if(argumentCount < 3) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if(check.isCallback(arguments[0]) | check.isNullOrUndefined(arguments[0])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if( !JSValueIsNumber(ctx, arguments[1])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    if(!JSValueIsNumber(ctx, arguments[2])) {
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    }
+
+    AlarmConverter alarmConverter(ctx);
+    int delay = (int)JSValueToNumber(ctx, arguments[1], exception);
+    int period = (int)JSValueToNumber(ctx, arguments[2], exception);
+    service = alarmConverter.toService(arguments[0]);
+
+    int err = alarm_schedule_after_delay(service, delay, period, &id);
+
+    service_destroy(service);
+
+    if(err != ALARM_ERROR_NONE) {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+    
+    return alarmConverter.toJSValueRef(id);
+}
+
+JSValueRef JSAlarmManager::cancelAlarm(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    int err;
+
+    if(argumentCount < 1 || !JSValueIsNumber(ctx, arguments[0])) 
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+
+    int id = (int)JSValueToNumber(ctx, arguments[0], exception);
+
+    err = alarm_cancel(id);
+
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+
+    return JSValueMakeUndefined(ctx);
+}
+
+
+JSValueRef JSAlarmManager::getAlarmIDs(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    vector<int> alarmIds;
+    alarm_foreach_registered_alarm(alarm_iterate_callback, &alarmIds);
+    
+    Converter converter(ctx);
+    return converter.toJSValueRef(alarmIds);    
+}
+
+
+JSValueRef JSAlarmManager::getNextScheduledDate(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if(argumentCount < 1 || !JSValueIsNumber(ctx, arguments[0])) 
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+    
+    struct tm date;
+    Converter converter(ctx);
+    int id = (int)JSValueToNumber(ctx, arguments[0], exception);
+    int err = alarm_get_scheduled_date(id, &date);
+
+    JSValueRef result = converter.toJSValueRef(date);
+    
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+
+    return result;
+}
+
+
+JSValueRef JSAlarmManager::getReccurentSecond(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    if(argumentCount < 1 || !JSValueIsNumber(ctx, arguments[0])) 
+        return JSDOMExceptionFactory::TypeMismatchException.make(ctx, exception);
+
+    int period;
+    Converter converter(ctx);
+    int id = (int)JSValueToNumber(ctx, arguments[0], exception);
+    int err = alarm_get_scheduled_period(id, &period);
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+    
+    return converter.toJSValueRef(period);
+}
+#endif
+
+} // Alarm
+} // Tizen1_0 
+} // TizenApis
+
diff --git a/src/standards/Tizen/Alarm/JSAlarmManager.h b/src/standards/Tizen/Alarm/JSAlarmManager.h
new file mode 100755 (executable)
index 0000000..c56c296
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * 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_ALARM_MANAGER
+#define _JS_TIZEN_ALARM_MANAGER
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+class JSAlarmManager {
+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);
+    
+#if 0
+    static JSValueRef createAlarm(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+    static JSValueRef createAfterDelay(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+       
+    static JSValueRef cancelAlarm(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+    static JSValueRef getAlarmIDs(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+    static JSValueRef getNextScheduledDate(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+    static JSValueRef getReccurentSecond(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+#endif 
+       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);
+                           
+       static JSValueRef getAlarms(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[];
+};
+
+}
+} // Tizen1_0
+} // TizenApis
+
+#endif
diff --git a/src/standards/Tizen/Alarm/JSAlarmRecurrence.cpp b/src/standards/Tizen/Alarm/JSAlarmRecurrence.cpp
new file mode 100755 (executable)
index 0000000..740b567
--- /dev/null
@@ -0,0 +1,424 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "AlarmRecurrence.h"
+#include <app.h>
+#include "JSAlarmRecurrence.h"
+#include "AlarmConverter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
+
+
+JSClassRef JSAlarmRecurrence::m_jsClassRef = NULL;
+
+JSClassDefinition JSAlarmRecurrence::m_jsClassInfo = {
+               0,
+               kJSClassAttributeNone,
+               "JSAlarmRecurrence",
+               NULL,
+               m_property,
+               NULL,
+               initialize,
+               finalize,
+               NULL, //hasProperty,
+               NULL, //getProperty,
+               NULL, //setProperty,
+               NULL, //deleteProperty
+               NULL, //getPropertyNames,
+               NULL,
+               constructor, // constructor
+               hasInstance,
+               NULL
+};
+
+JSStaticValue JSAlarmRecurrence::m_property[] = {
+       { "frequency", getFrequency, setFrequency, kJSPropertyAttributeNone },
+       { "interval", getInterval, setInterval, kJSPropertyAttributeNone },
+       { "daysOfTheWeek", getDaysOfTheWeek, setDaysOfTheWeek, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }                                                                                            
+};
+
+const JSClassRef JSAlarmRecurrence::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAlarmRecurrence::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSAlarmRecurrence::initialize(JSContextRef context, JSObjectRef object) 
+{
+
+}
+
+void JSAlarmRecurrence::finalize(JSObjectRef object) 
+{
+
+}
+
+JSObjectRef JSAlarmRecurrence::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    // Parameter can be 1 or 2.
+        
+    // 1. Parameter : AlarmFrequency
+    // 2. Parameter : interval
+    // 3. Parameter : ByDayValue[]
+    AlarmConverter converter(ctx);
+
+    // return : Should return AlarmRecurrence object
+    if(argumentCount < 1)
+    {
+        return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+    }
+
+    if(argumentCount == 1)
+    {
+        // daysOfTheweek
+        // convert javascript array to string array
+        // How can i check javascript
+        if(!JSIsArrayValue(ctx, arguments[0]))
+        {
+            // exception.
+            return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+        }
+        std::vector<std::string> temp =  converter.toVectorOfStrings(arguments[0]);
+        JSObjectRef obj = createJSObject(ctx, temp);
+        return obj;
+    }
+    else
+    {
+        std::string frequencyStr;
+        int interval;
+        AlarmRecurrence::alarm_frequency_e  frequency;
+        // Should frequency & interval
+        if(!JSValueIsString(ctx, arguments[0]))
+        {
+            return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+        }
+        frequencyStr = converter.toString(arguments[0]);
+
+        frequency = converter.toRecurrenceFrequency(frequencyStr);
+
+        if(frequency == AlarmRecurrence::NO_RECURRENCE)
+        {
+            return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+        }
+
+        if(JSValueIsNumber(ctx, arguments[1]))
+        {
+            return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+        }
+
+        interval = converter.toInt(arguments[1]);
+
+        if(interval <=0)
+        {
+            return converter.toJSObjectRef(TizenApis::Commons::JSTizenExceptionFactory::postException(ctx, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR));
+        }
+
+        JSObjectRef obj = createJSObject(ctx, frequency, interval);
+        return obj;
+       
+    }
+        
+}
+
+bool JSAlarmRecurrence::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+AlarmRecurrencePtr JSAlarmRecurrence::getPrivData(JSObjectRef object)
+{
+       JSAlarmRecurrencePriv*priv = static_cast<JSAlarmRecurrencePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+    
+       AlarmRecurrencePtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSAlarmRecurrence::createJSObject(JSContextRef context, std::vector<std::string> daysOfTheWeek)
+{
+    AlarmRecurrencePtr privateData = AlarmRecurrencePtr(new AlarmRecurrence());
+    privateData->setDaysOfTheWeek(daysOfTheWeek);
+    JSAlarmRecurrencePriv *priv = new JSAlarmRecurrencePriv(context, privateData);
+    JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+     if (NULL == jsObjectRef) {
+        // Exception
+        LogError("JSAlarmRecurrence object creation error");
+        
+    }
+    return jsObjectRef;    
+}
+
+JSObjectRef JSAlarmRecurrence::createJSObject(JSContextRef context, AlarmRecurrence::alarm_frequency_e frequency, int interval)
+{
+    AlarmRecurrencePtr privateData = AlarmRecurrencePtr(new AlarmRecurrence());
+    privateData->setInterval(interval);
+    privateData->setFrequency(frequency);
+    JSAlarmRecurrencePriv *priv = new JSAlarmRecurrencePriv(context, privateData);
+    JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+     if (NULL == jsObjectRef) {
+        // Exception
+        LogError("JSAlarmRecurrence object creation error");
+        
+    }
+    return jsObjectRef;    
+}
+
+
+JSValueRef JSAlarmRecurrence::getFrequency(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception)
+{
+    AlarmConverter converter(ctx);
+    AlarmRecurrence::alarm_frequency_e frequency;
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        frequency = privateData->getFrequency();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(converter.toTizenValue(frequency));   
+}
+
+bool JSAlarmRecurrence::setFrequency(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception)
+{
+    AlarmConverter converter(ctx);
+    std::string frequencyStr;
+    
+    if(!JSValueIsString(ctx, value))
+    {
+        return false;    
+    }
+    
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        frequencyStr = converter.toString(value);
+        privateData->setFrequency(converter.toRecurrenceFrequency(frequencyStr));
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return true;
+}
+               
+JSValueRef JSAlarmRecurrence::getInterval(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception)
+{
+    int interval;
+    Converter converter(ctx);
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        interval = privateData->getInterval();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(interval);
+
+}
+
+bool JSAlarmRecurrence::setInterval(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception)
+{
+    Converter converter(ctx);
+
+    if(!JSValueIsNumber(ctx, value))
+    {
+        return false;
+    }
+    
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        privateData->setInterval(converter.toInt(value));
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return true;
+    
+}
+JSValueRef JSAlarmRecurrence::getDaysOfTheWeek(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception)
+{
+    // todo change to AlarmConverter
+    std::vector<std::string> daysOfTheWeek;
+    Converter converter(ctx);
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        daysOfTheWeek = privateData->getDaysOfTheWeek();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(daysOfTheWeek);
+
+}
+
+bool JSAlarmRecurrence::setDaysOfTheWeek(JSContextRef ctx,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception)
+{
+
+    AlarmConverter converter(ctx);
+    std::vector<std::string> daysOfTheWeek;
+
+    Try
+    {
+        AlarmRecurrencePtr privateData = getPrivData(object);
+        daysOfTheWeek = converter.toVectorOfStrings(value);
+        privateData->setDaysOfTheWeek(daysOfTheWeek);
+     }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(daysOfTheWeek);
+
+}
+
+
+#if 0
+void convertDaysOfTheWeekToFlag(std::vector<string> daysOfTheWeek, char weekFlag[])
+{
+    for( unsigned int i=0; i<daysOfTheWeek.size(); i++ )
+    {
+        if( daysOfTheWeek[i]=="SU" )
+            weekFlag[0] = '1';
+        else if( daysOfTheWeek[i]=="MO" )
+            weekFlag[1] = '1';
+        else if( daysOfTheWeek[i]=="TU" )
+            weekFlag[2] = '1';
+        else if( daysOfTheWeek[i]=="WE" )
+            weekFlag[3] = '1';
+        else if( daysOfTheWeek[i]=="TH" )
+            weekFlag[4] = '1';
+        else if( daysOfTheWeek[i]=="FR" )
+            weekFlag[5] = '1';
+        else if( daysOfTheWeek[i]=="SA" )
+            weekFlag[6] = '1';
+    }
+}
+#endif
+
+#if 0
+JSValueRef JSAlarmRecurrence::getId(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    Converter converter(ctx);
+    int id;
+    Try
+    {
+        AlarmPtr privateData = getPrivData(object);
+        id = privateData->getId();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(id);
+
+}
+
+
+JSValueRef JSAlarmRecurrence::getInterval(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    Converter converter(ctx);
+    int interval;
+    Try
+    {
+        AlarmPtr privateData = getPrivData(object);
+        interval = privateData->getInterval();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(interval);
+
+}
+
+#endif
+
+} // Alarm
+} // Tizen1_0 
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Alarm/JSAlarmRecurrence.h b/src/standards/Tizen/Alarm/JSAlarmRecurrence.h
new file mode 100755 (executable)
index 0000000..3d681db
--- /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.
+ */
+
+#ifndef _JS_TIZEN_ALARMRECURRENCE
+#define _JS_TIZEN_ALARMRECURRENCE
+
+#include <JavaScriptCore/JavaScript.h>
+#include "AlarmRecurrence.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace TizenApis::Api::Alarm;
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AlarmRecurrencePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAlarmRecurrencePriv;
+
+
+#define TIZEN_ALARM_PROPERTY_MINUTELY_RECURRENCE    "MINUTELY"
+#define TIZEN_ALARM_PROPERTY_HOURLY_RECURRENCE   "HOURLY"
+#define TIZEN_ALARM_PROPERTY_DAILY_RECURRENCE    "DAILY"
+#define TIZEN_ALARM_PROPERTY_WEEKLY_RECURRENCE   "WEEKLY"
+
+class JSAlarmRecurrence {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    static JSObjectRef createJSObject(JSContextRef context, std::vector<std::string> daysOfTheWeek);
+    static JSObjectRef createJSObject(JSContextRef context, AlarmRecurrence::alarm_frequency_e frequency, int interval);
+    
+
+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 AlarmRecurrencePtr getPrivData(JSObjectRef object);
+    static JSValueRef getFrequency(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception);
+
+    static bool setFrequency(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception);
+    
+    static JSValueRef getInterval(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception);
+    
+    static bool setInterval(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception);
+    
+    static JSValueRef getDaysOfTheWeek(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception);
+    
+    static bool setDaysOfTheWeek(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef value,
+                                        JSValueRef* exception);
+
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+    static JSStaticValue m_property[];
+};
+
+}// Alarm
+} // Tizen1_0
+} // TizenApis
+
+#endif
diff --git a/src/standards/Tizen/Alarm/JSAlarmRelative.cpp b/src/standards/Tizen/Alarm/JSAlarmRelative.cpp
new file mode 100755 (executable)
index 0000000..ffc66c4
--- /dev/null
@@ -0,0 +1,349 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "AlarmRelative.h"
+#include "AlarmRecurrence.h"
+#include "AlarmConverter.h"
+#include <app.h>
+#include <time.h>
+#include "JSAlarmRecurrence.h"
+#include "JSAbstractAlarm.h"
+#include "JSAlarmRelative.h"
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace std;
+using namespace DPL;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Alarm;
+
+JSClassRef JSAlarmRelative::m_jsClassRef = NULL;
+
+JSClassDefinition JSAlarmRelative::m_jsClassInfo = {
+               0,
+               kJSClassAttributeNone,
+               "AlarmRelative",
+               JSAbstractAlarm::getClassRef(),
+               m_property,
+               m_function,
+               initialize,
+               finalize,
+               NULL, //hasProperty,
+               NULL, //getProperty,
+               NULL, //setProperty,
+               NULL, //deleteProperty,Geolocation
+               NULL, //getPropertyNames,
+               NULL,
+               constructor, // constructor
+               hasInstance,
+               NULL
+};
+
+JSStaticFunction JSAlarmRelative::m_function[] = { 
+        { "getNextScheduledDate",JSAlarmRelative::getNextScheduledDate,kJSPropertyAttributeNone },
+        { 0, 0, 0 }
+};
+
+JSStaticValue JSAlarmRelative::m_property[] = {
+       { "id", getId, NULL, kJSPropertyAttributeReadOnly },
+       { "recurrenceRule", getRecurrenceRule, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }                                                                                            
+};
+
+const JSClassRef JSAlarmRelative::getClassRef() 
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_jsClassInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAlarmRelative::getClassInfo() 
+{
+       return &m_jsClassInfo;
+}
+
+void JSAlarmRelative::initialize(JSContextRef context, JSObjectRef object) 
+{
+
+}
+void JSAlarmRelative::finalize(JSObjectRef object) 
+{
+
+}
+
+bool JSAlarmRelative::hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+
+JSObjectRef JSAlarmRelative::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+    #if 0
+    LogError("[ILOVEFILM] Enter constructor");
+    // 2 Param
+    // 1. Date, Recurrence
+    // 2. Delay, Recurrence
+    struct tm date;
+    AlarmConverter converter(ctx);
+    Validator validator(ctx);
+    AlarmRelative::alarm_type_e alarm_type;
+
+     bool isRecurrence = false;
+       
+    
+    if(argumentCount < 1)
+    {
+        // excpetion
+        LogWarning("Argument is not corrent");
+    }
+
+    int delay;
+    if(JSValueIsNumber(ctx, arguments[0]));
+    {
+        // delay
+        delay = converter.toInt(arguments[0]);
+        alarm_type = Alarm::ALARM_TYPE_DELAY;
+    }  
+    
+    if( validator.isDate(arguments[0]) == true)
+    {   
+        // date
+        date = converter.toDateTm(arguments[0]);
+        alarm_type = Alarm::ALARM_TYPE_DATE;
+    }
+
+    AlarmRecurrencePtr result;
+    
+    if(argumentCount == 2)
+    {
+        if(JSValueIsObjectOfClass(ctx, arguments[1], JSAlarmRecurrence::getClassRef()))
+        {
+             JSObjectRef recurreceObj = JSValueToObject(ctx, arguments[1], exception);
+            
+            JSAlarmRecurrencePriv*priv = static_cast<JSAlarmRecurrencePriv*>(JSObjectGetPrivate(recurreceObj));
+            if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+            }
+
+            result = priv->getObject();
+            if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+            }
+        }
+        isRecurrence = true;
+    }
+
+    if(alarm_type == Alarm::ALARM_TYPE_DELAY)
+    {
+        if(isRecurrence == true) {
+            return JSValueToObject(ctx, createJSObject(ctx, delay, result), exception);
+        }
+        else
+        {
+            return JSValueToObject(ctx, createJSObject(ctx, delay,0), exception);
+        }    
+    }
+    else
+    {
+        if(isRecurrence == true) {
+            return JSValueToObject(ctx, createJSObject(ctx, date, result), exception);
+        }
+        else
+        {
+            return JSValueToObject(ctx, createJSObject(ctx, date), exception);
+        }
+    }
+#endif
+
+}
+AlarmRelativePtr JSAlarmRelative::getPrivData(JSObjectRef object)
+{
+       JSAlarmRelativePriv *priv = static_cast<JSAlarmRelativePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       AlarmRelativePtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+
+JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, const int id)
+{
+    AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
+    
+    privateData->setId(id);
+
+    JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+}
+
+JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, struct tm date, AlarmRecurrencePtr ptr)
+{
+    AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
+
+    JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+
+}
+JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, AlarmRecurrencePtr ptr)
+{
+    AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
+
+    privateData->setDelay(delay);
+    privateData->setRecurrence(ptr);
+    
+    JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+}
+
+
+JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, struct tm date)
+{
+    AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
+   
+    JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+
+}
+JSValueRef JSAlarmRelative::createJSObject(JSContextRef context, int delay, int dummy)
+{
+    AlarmRelativePtr privateData = AlarmRelativePtr(new AlarmRelative());
+    privateData->setDelay(delay);
+   
+    JSAlarmRelativePriv *priv = new JSAlarmRelativePriv(context, privateData);
+
+    JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+    if (NULL == jsValueRef) {
+        LogError("object creation error");
+        return JSValueMakeUndefined(context);
+    }
+    return jsValueRef;
+}
+
+JSValueRef JSAlarmRelative::getNextScheduledDate(JSContextRef ctx, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{ 
+    struct tm date;
+    Converter converter(ctx);
+    int id;
+    Try
+    {
+        AlarmRelativePtr privateData = getPrivData(object);
+        id = privateData->getId();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    
+    int err = alarm_get_scheduled_date(id, &date);
+
+    JSValueRef result = converter.toJSValueRef(date);
+
+    if(err != ALARM_ERROR_NONE)
+    {
+        return JSDOMExceptionFactory::UnknownException.make(ctx, exception);
+    }
+    return result;     
+}
+
+JSValueRef JSAlarmRelative::getId(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    Converter converter(ctx);
+    int id;
+    Try
+    {
+        AlarmRelativePtr privateData = getPrivData(object);
+        id = privateData->getId();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(id);
+}
+
+
+JSValueRef JSAlarmRelative::getRecurrenceRule(JSContextRef ctx,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    #if 0
+    Converter converter(ctx);
+    int interval;
+    Try
+    {
+        AlarmPtr privateData = getPrivData(object);
+        interval = privateData->getRecurrence();
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return converter.toJSValueRef(interval);
+    #endif
+
+}
+
+} // Alarm
+} // Tizen1_0 
+} // TizenApis
+
+
diff --git a/src/standards/Tizen/Alarm/JSAlarmRelative.h b/src/standards/Tizen/Alarm/JSAlarmRelative.h
new file mode 100755 (executable)
index 0000000..049dcda
--- /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.
+ */
+
+#ifndef _JS_TIZEN_ALARMRELATIVE
+#define _JS_TIZEN_ALARMRELATIVE
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Application/IApplication.h>
+#include "AlarmRelative.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Alarm {
+
+using namespace TizenApis::Api::Alarm;
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<AlarmRelativePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAlarmRelativePriv;
+
+class JSAlarmRelative {
+public:
+    static const JSClassDefinition* getClassInfo();
+    static const JSClassRef getClassRef();
+    static JSValueRef createJSObject(JSContextRef context, const int id);
+    static JSValueRef createJSObject(JSContextRef context, struct tm date, AlarmRecurrencePtr ptr);
+    static JSValueRef createJSObject(JSContextRef context, int delay, AlarmRecurrencePtr ptr);
+    static JSValueRef createJSObject(JSContextRef context, struct tm date);
+    static JSValueRef createJSObject(JSContextRef context, int delay, int dummy);
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+
+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 getNextScheduledDate(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+    
+private:
+    static Api::Alarm::AlarmRelativePtr getPrivData(JSObjectRef object);
+   
+    static JSValueRef getId(JSContextRef context,
+                                        JSObjectRef object,
+                                        JSStringRef propertyName,
+                                        JSValueRef* exception);
+
+    static JSValueRef getRecurrenceRule(JSContextRef context,
+                                                JSObjectRef object,
+                                                JSStringRef propertyName,
+                                                JSValueRef* exception);
+
+    static JSClassDefinition m_jsClassInfo;
+    static JSClassRef m_jsClassRef;
+    static JSStaticFunction m_function[];
+    static JSStaticValue m_property[];
+
+};
+
+}// Alarm
+} // Tizen1_0
+} // TizenApis
+
+#endif
diff --git a/src/standards/Tizen/Alarm/config.xml b/src/standards/Tizen/Alarm/config.xml
new file mode 100755 (executable)
index 0000000..95b74a1
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+       <library-name>libwrt-plugins-tizen-1.0-alarm.so</library-name>
+       <feature-install-uri>alarm.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/alarm</name>
+               <device-capability>alarm</device-capability>
+               <Object name="alarm">
+                       <Function name="add"/>
+                       <Function name="cancel"/>
+                       <Function name="getAlarms"/>
+               </Object>
+       </api-feature>
+</plugin-properties>
\ No newline at end of file
diff --git a/src/standards/Tizen/Alarm/plugin_initializer.cpp b/src/standards/Tizen/Alarm/plugin_initializer.cpp
new file mode 100755 (executable)
index 0000000..f4cf46d
--- /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.
+ */
+
+#include <dpl/log/log.h>
+#include <Commons/plugin_initializer_def.h>
+#include "JSAlarmManager.h"
+#include "JSAlarmAbsolute.h"
+#include "JSAlarmRelative.h"
+#include "JSAlarmRecurrence.h"
+
+#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
+
+void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+{
+    LogDebug("[Tizen\\AlarmManager ] on_widget_start_callback (" << widgetId << ")");
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+    LogDebug("[Tizen\\AlarmManager ] on_widget_stop_callback (" << 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,
+        "alarm",
+        TizenApis::Tizen1_0::Alarm::JSAlarmManager::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(
+       WRT_JS_EXTENSION_OBJECT_TIZEN,
+       "AlarmAbsolute",
+       TizenApis::Tizen1_0::Alarm::JSAlarmAbsolute::getClassRef(),
+       NULL) 
+PLUGIN_CLASS_MAP_ADD_CLASS(
+       WRT_JS_EXTENSION_OBJECT_TIZEN,
+       "AlarmRelative",
+       TizenApis::Tizen1_0::Alarm::JSAlarmRelative::getClassRef(),
+       NULL) 
+PLUGIN_CLASS_MAP_END
+
index b43cee8..710fa80 100755 (executable)
@@ -19,6 +19,7 @@
 #include <Tizen/Common/JSTizenException.h>
 #include <JavaScriptCore/JavaScript.h>
 #include "JSApplicationInformation.h"
+#include "JSApplicationContext.h"
 #include "ApplicationAnswerReceiver.h"
 #include "ApplicationConverter.h"
 
@@ -33,12 +34,14 @@ using namespace TizenApis::Commons;
 
 ApplicationAnswerReceiver::ApplicationAnswerReceiver(const CommonsJavaScript::JSCallbackManagerPtr &callbackManager) :
        EventAnswerReceiver<EventListInstalledApplications> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<EventManageApplication> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
        EventAnswerReceiver<EventLaunchService> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),      
        m_callbackManager(callbackManager) {
 }
 
 ApplicationAnswerReceiver::ApplicationAnswerReceiver(const LaunchServicePrivateDataPtr &launchServiceCallbackManager) :
        EventAnswerReceiver<EventListInstalledApplications> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
+       EventAnswerReceiver<EventManageApplication> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
        EventAnswerReceiver<EventLaunchService> (WrtDeviceApis::Commons::ThreadEnum::NULL_THREAD),
        m_privateData(launchServiceCallbackManager) {
        LogDebug("<<<");
@@ -50,17 +53,75 @@ ApplicationAnswerReceiver::~ApplicationAnswerReceiver() {
 void ApplicationAnswerReceiver::OnAnswerReceived(const EventListInstalledApplicationsPtr &event) 
 {
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
-               Try
-               {
-                       ApplicationInformationArrayPtr appinfoArray = event->getApplicationInformationArray();
-                       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(m_callbackManager->getContext());
-                       JSValueRef result = converter->toJSValueRef(appinfoArray);
-                       
-                       m_callbackManager->callOnSuccess(result);
+               if (event->getEventType() == EventListInstalledApplications::APPMANAGER_LIST_INSTALLED_APPLICATIONS) {
+                       Try
+                       {
+                               ApplicationInformationArrayPtr appinfoArray = event->getApplicationInformationArray();
+                               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(m_callbackManager->getContext());
+                               JSValueRef result = converter->toJSValueRef(appinfoArray);
+                               m_callbackManager->callOnSuccess(result);
+                       }
+                       Catch(WrtDeviceApis::Commons::Exception)
+                       {
+                               LogError("error during function executing");
+                               JSContextRef context = m_callbackManager->getContext();
+                               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
+                               m_callbackManager->callOnError(errorObject);
+                       }
+               } else if (event->getEventType() == EventListInstalledApplications::APPMANAGER_LIST_RUNNING_APPLICATIONS) {
+                       Try
+                       {
+                               ApplicationContextArrayPtr appcontextArray = event->getApplicationContextArray();
+                               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(m_callbackManager->getContext());
+                               JSValueRef result = converter->toJSValueRef(appcontextArray);
+                               
+                               m_callbackManager->callOnSuccess(result);
+                       }
+                       Catch(WrtDeviceApis::Commons::Exception)
+                       {
+                               LogError("error during function executing");
+                               JSContextRef context = m_callbackManager->getContext();
+                               JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
+                               m_callbackManager->callOnError(errorObject);
+                       }
+               } else {
+                       LogError("unknow event type");
+                       JSContextRef context = m_callbackManager->getContext();
+                       JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
+                       m_callbackManager->callOnError(errorObject);
                }
-               Catch(WrtDeviceApis::Commons::Exception)
-               {
-                       LogError("error during function executing");
+       }
+       else {
+               LogDebug("Operation failed. Exception code: " << event->getExceptionCode());
+               JSContextRef context = m_callbackManager->getContext();
+               JSValueRef errorObject = NULL;
+
+               WrtDeviceApis::Commons::ExceptionCodes::Enumeration exception = event->getExceptionCode();
+               switch(exception){
+                       case WrtDeviceApis::Commons::ExceptionCodes::NotFoundException:
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::NOT_FOUND_ERROR,"given package is not found");
+                               break;
+                       case WrtDeviceApis::Commons::ExceptionCodes::PlatformException:
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"platform exception");
+                               break;
+                       default:
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
+                               break;
+               }
+               m_callbackManager->callOnError(errorObject);
+       }       
+}
+
+void ApplicationAnswerReceiver::OnAnswerReceived(const EventManageApplicationPtr &event) 
+{
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+               if (event->getEventType() == EventManageApplication::APP_MANAGER_KILL_APPLICATION ||
+                 event->getEventType() == EventManageApplication::APP_MANAGER_HIDE_APPLICATION ||
+                 event->getEventType() == EventManageApplication::APP_MANAGER_LAUNCH_APPLICATION) {
+                       LogDebug("Event Type: " << event->getEventType());
+                       m_callbackManager->callOnSuccess();
+               } else {
+                       LogError("unknow event type");
                        JSContextRef context = m_callbackManager->getContext();
                        JSValueRef errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
                        m_callbackManager->callOnError(errorObject);
@@ -87,12 +148,14 @@ void ApplicationAnswerReceiver::OnAnswerReceived(const EventListInstalledApplica
        }       
 }
 
+
 void ApplicationAnswerReceiver::OnAnswerReceived(const EventLaunchServicePtr &event) 
 {
        LogDebug("<<<");
        LaunchServicePrivateDataPtr privateData =
                DPL::StaticPointerCast<LaunchServicePrivateData>(event->getPrivateData());      
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) 
+       {
                LogDebug("OnAnswerReceived");
                Try
                {
@@ -111,13 +174,13 @@ void ApplicationAnswerReceiver::OnAnswerReceived(const EventLaunchServicePtr &ev
                                if(replyCallbackManager)
                                {
                                        LogDebug("check ApplicationServiceReply");
-                                       ApplicationServiceReplyPtr reply = event->getServiceReply();
+                                       std::vector<ApplicationServiceDataPtr> reply = event->getService()->getServiceDataArray();
 
                                        ApplicationConverterFactory::ConverterType converter = 
                                                ApplicationConverterFactory::getConverter(replyCallbackManager->getContext());
                                        JSValueRef jsObj = converter->toJSValueRef(reply);
 
-                                       replyCallbackManager->callOnSuccess(jsObj);
+                                       replyCallbackManager->callOnSuccess(jsObj);
                                        LogDebug("after replyCallbackManager onsuccess");
                                }
                        }
@@ -127,35 +190,18 @@ void ApplicationAnswerReceiver::OnAnswerReceived(const EventLaunchServicePtr &ev
                                CommonsJavaScript::JSCallbackManagerPtr replyCallbackManager = privateData->getReplyCallbackManager();
                                if(replyCallbackManager)
                                {
-                                       
-                                       LogDebug("check ApplicationServiceReply");
-                                       ApplicationServiceReplyPtr reply = event->getServiceReply();
-
-                                       ApplicationConverterFactory::ConverterType converter = 
-                                               ApplicationConverterFactory::getConverter(replyCallbackManager->getContext());
-                                       JSValueRef jsObj = converter->toJSValueRef(reply);
-
-                                       replyCallbackManager->callOnError(jsObj);
+                                       replyCallbackManager->callOnError();
                                        LogDebug("after replyCallbackManager onfail");
                                }
                        }
-                       else if(event->getCallbackType() == EventLaunchService::APPLICATION_SERVICE_REPLY_CANCEL_CALLBACK)
-                       {
-                               CommonsJavaScript::JSCallbackManagerPtr replyCancelCallbackManager = privateData->getReplyCancelCallbackManager();
-                               if(replyCancelCallbackManager)
-                               {                       
-                                       LogDebug("replyCancelCallbackManager");
-                                       replyCancelCallbackManager->callOnSuccess();
-                                       LogDebug("after replyCallback oncancel");
-                               }
-                       }
                }
                Catch(WrtDeviceApis::Commons::Exception)
                {
                        LogError("error during function executing");
                }
        }
-       else {
+       else 
+       {
                LogDebug("Operation failed. Exception code: " << event->getExceptionCode());
 
                JSValueRef errorObject = NULL;
index a0552a7..b56b52c 100755 (executable)
@@ -23,6 +23,7 @@
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Application/EventListInstalledApplications.h>
 #include <API/Application/EventLaunchService.h>
+#include <API/Application/EventManageApplication.h>
 #include "LaunchServicePrivateData.h"
 
 namespace TizenApis {
@@ -33,6 +34,7 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 
 class ApplicationAnswerReceiver :
         public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventListInstalledApplications>,
+               public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventManageApplication>,
                public WrtDeviceApis::Commons::EventAnswerReceiver< Api::Application::EventLaunchService>
 {
     public:
@@ -42,6 +44,7 @@ class ApplicationAnswerReceiver :
 
     protected:
         void OnAnswerReceived(const Api::Application::EventListInstalledApplicationsPtr &event);
+               void OnAnswerReceived(const Api::Application::EventManageApplicationPtr &event);
                void OnAnswerReceived(const Api::Application::EventLaunchServicePtr &event);
 
     private:
index b370af4..4554785 100755 (executable)
 #include "ApplicationConverter.h"
 #include "JSApplicationInformation.h"
 #include "JSApplicationInformationArray.h"
-#include "JSApplicationServiceExtraDataArray.h"
-#include "JSApplicationServiceExtraData.h"
-#include "JSApplicationServiceRequest.h"
-#include "JSApplicationServiceReply.h"
+#include "JSApplicationContext.h"
+#include "JSApplicationContextArray.h"
+#include "JSApplicationServiceData.h"
+#include "JSApplicationServiceData.h"
+#include "JSApplicationService.h"
+//#include "JSApplicationServiceReply.h"
 
 namespace {
        const char* APPLICATOIN_ATTRIBUTE_NAME = "name";
-       const char* APPLICATOIN_ATTRIBUTE_PACKAGE_NAME = "packageName";
+       const char* APPLICATOIN_ATTRIBUTE_APP_ID = "appId";
+       const char* APPLICATOIN_ATTRIBUTE_CONTEXT_ID = "contextId";
        const char* APPLICATOIN_ATTRIBUTE_ICONF_PATH = "iconPath";
        const char* APPLICATOIN_ATTRIBUTE_VERSION = "version";
        const char* APPLICATOIN_ATTRIBUTE_EXTRA_KEY = "key";
@@ -51,9 +54,9 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::Application;
 
 std::vector<std::string> ApplicationConverter::m_allowedApplicationInformation;
-std::vector<std::string> ApplicationConverter::m_allowedApplicationServiceRequest;
-std::vector<std::string> ApplicationConverter::m_allowedApplicationServiceReply;
-std::vector<std::string> ApplicationConverter::m_allowedApplicationServiceExtraData;
+std::vector<std::string> ApplicationConverter::m_allowedApplicationContext;
+std::vector<std::string> ApplicationConverter::m_allowedApplicationService;
+std::vector<std::string> ApplicationConverter::m_allowedApplicationServiceData;
 
 ApplicationConverter::ApplicationConverter(JSContextRef context) : Converter(context)
 {
@@ -86,19 +89,19 @@ ApplicationInformationPtr ApplicationConverter::toApplicationInformation(const J
        }
 
        const ScopedJSStringRef nameStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_NAME));
-       const ScopedJSStringRef packageStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_PACKAGE_NAME));
+       const ScopedJSStringRef appIdStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_APP_ID));
        const ScopedJSStringRef iconPathStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_ICONF_PATH));
        const ScopedJSStringRef versionStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_VERSION));       
 
        JSObjectRef jsObject = toJSObjectRef(jsValue);
 
        JSValueRef nameData = JSObjectGetProperty(m_context, jsObject, nameStr.get(), NULL);
-       JSValueRef packageData = JSObjectGetProperty(m_context, jsObject, packageStr.get(), NULL);
+       JSValueRef appIdStrData = JSObjectGetProperty(m_context, jsObject, appIdStr.get(), NULL);
        JSValueRef iconPathData = JSObjectGetProperty(m_context, jsObject, iconPathStr.get(), NULL);
        JSValueRef versionData = JSObjectGetProperty(m_context, jsObject, versionStr.get(), NULL);      
 
        std::string name;
-       std::string package;
+       std::string appid;
        std::string iconPath;
        std::string version;    
 
@@ -111,9 +114,9 @@ ApplicationInformationPtr ApplicationConverter::toApplicationInformation(const J
                name = toString(nameData);
                result->setName(name);
        }
-       if (!JSValueIsUndefined(m_context, packageData)) {
-               package = toString(packageData);
-               result->setPackage(package);
+       if (!JSValueIsUndefined(m_context, appIdStrData)) {
+               appid = toString(appIdStrData);
+               result->setAppId(appid);
        }
        if (!JSValueIsUndefined(m_context, iconPathData)) {
                iconPath = toString(iconPathData);
@@ -151,199 +154,240 @@ ApplicationInformationArrayPtr ApplicationConverter::toApplicationInformationArr
     return result;
 }
 
-JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServiceRequestPtr &arg)
+JSValueRef ApplicationConverter::toJSValueRef(const ApplicationContextPtr &arg)
 {
-       LogDebug("entered");
-       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationServiceRequest::getClassRef(), arg);
+       if(arg == NULL)
+       {
+               Throw(Commons::InvalidArgumentException);
+       }
+       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationContext::getClassRef(), arg);
 }
 
-ApplicationServiceRequestPtr ApplicationConverter::toApplicationServiceRequest(const JSValueRef &jsValue)
+
+ApplicationContextPtr ApplicationConverter::toApplicationContext(const JSValueRef &jsValue)
 {
-       if(JSApplicationServiceRequest::isObjectOfClass(m_context, jsValue))
-               return JSApplicationServiceRequest::getApplicationServiceRequest(m_context, jsValue);
+       if(JSApplicationContext::isObjectOfClass(m_context, jsValue))
+               return JSApplicationContext::getApplicationContext(m_context, jsValue);
 
        CommonsJavaScript::Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedApplicationServiceRequest, jsValue)) {
-               LogError("invalid properties in ApplicationServiceRequest object");
+       if (!validator.checkArrayKeys(m_allowedApplicationContext, jsValue)) {
+               LogError("invalid properties in contact object");
                ThrowMsg(Commons::ConversionException, "Wrong attribute");
        }
 
-       const ScopedJSStringRef operationStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_OPERATION));
-       const ScopedJSStringRef uriStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_URI));
-       const ScopedJSStringRef mimeStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_MIME));
-       const ScopedJSStringRef packageStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_PACKAGE_NAME));
-       const ScopedJSStringRef extraDataStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRADATA));   
+       const ScopedJSStringRef appIdStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_APP_ID));
+       const ScopedJSStringRef contextIdStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_CONTEXT_ID));  
 
        JSObjectRef jsObject = toJSObjectRef(jsValue);
 
-       JSValueRef jsoperation = JSObjectGetProperty(m_context, jsObject, operationStr.get(), NULL);
-       JSValueRef jsuri = JSObjectGetProperty(m_context, jsObject, uriStr.get(), NULL);
-       JSValueRef jsmime = JSObjectGetProperty(m_context, jsObject, mimeStr.get(), NULL);
-       JSValueRef jspackage = JSObjectGetProperty(m_context, jsObject, packageStr.get(), NULL);
-       JSValueRef jsextradata = JSObjectGetProperty(m_context, jsObject, extraDataStr.get(), NULL);    
+       JSValueRef appIdStrData = JSObjectGetProperty(m_context, jsObject, appIdStr.get(), NULL);
+       JSValueRef contextIdStrData = JSObjectGetProperty(m_context, jsObject, contextIdStr.get(), NULL);
 
-       std::string operation;
-       std::string uri;
-       std::string mime;
-       std::string package;
-       ApplicationServiceExtraDataArrayPtr extraDataArray;
-       
-       ApplicationServiceRequestPtr result(new ApplicationServiceRequest());
+
+       std::string appid;
+       std::string contextid;
+
+       ApplicationContextPtr result(new ApplicationContext());
        if (!result) {
                Throw(Commons::ConversionException);
        }
 
-       if (!JSValueIsUndefined(m_context, jsoperation)) {
-               operation = toString(jsoperation);
-               LogDebug("operation : "<<operation);
-               result->setOperation(operation);
+       if (!JSValueIsUndefined(m_context, appIdStrData)) {
+               appid = toString(appIdStrData);
+               result->setAppId(appid);
        }
-
-       if (!JSValueIsUndefined(m_context, jsuri)) {
-               uri = toString(jsuri);
-               result->setUri(uri);
+       if (!JSValueIsUndefined(m_context, contextIdStrData)) {
+               contextid = toString(contextIdStrData);
+               result->setContextId(appid);
        }
+       
+       return result;
+}
 
-       if (!JSValueIsUndefined(m_context, jsmime)) {
-               mime = toString(jsmime);
-               result->setMime(mime);
+JSValueRef ApplicationConverter::toJSValueRef(const ApplicationContextArrayPtr &arg)
+{
+       if(arg == NULL)
+       {
+               Throw(Commons::InvalidArgumentException);
        }
+       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationContextArray::getClassRef(), arg);
+}
 
-       if (!JSValueIsUndefined(m_context, jspackage)) {
-               package = toString(jspackage);
-               LogDebug("package : "<<package);
-               result->setPackage(package);
-       }
+ApplicationContextArrayPtr ApplicationConverter::toApplicationContextArray(const JSValueRef &jsValue)
+{
+       if(JSApplicationContextArray::isObjectOfClass(m_context, jsValue))
+               return JSApplicationContextArray::getApplicationContextArray(m_context, jsValue);
 
-       if (!JSValueIsUndefined(m_context, jsextradata)) {
-               extraDataArray = toApplicationServiceExtraDataArray(jsextradata);
-               result->setExtraDataArray(extraDataArray);
-       }
-       LogDebug("done");
-       return result;
+       ApplicationContextArrayPtr result(new ApplicationContextArray());
+
+       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(toApplicationContext(element));
+    }
+    return result;
 }
 
-JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServiceReplyPtr &arg)
+JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServicePtr &arg)
 {
        LogDebug("entered");
-       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationServiceReply::getClassRef(), arg);
+       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationService::getClassRef(), arg);
 }
 
-ApplicationServiceReplyPtr ApplicationConverter::toApplicationServiceReply(const JSValueRef &jsValue)
+ApplicationServicePtr ApplicationConverter::toApplicationService(const JSValueRef &jsValue)
 {
-       if(JSApplicationServiceReply::isObjectOfClass(m_context, jsValue))
-               return JSApplicationServiceReply::getApplicationServiceReply(m_context, jsValue);
+       if(JSApplicationService::isObjectOfClass(m_context, jsValue))
+               return JSApplicationService::getApplicationService(m_context, jsValue);
 
        CommonsJavaScript::Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedApplicationServiceReply, jsValue)) {
-               LogError("invalid properties in ApplicationServiceReply object");
+       if (!validator.checkArrayKeys(m_allowedApplicationService, jsValue)) {
+               LogError("invalid properties in ApplicationService object");
                ThrowMsg(Commons::ConversionException, "Wrong attribute");
        }
 
+       const ScopedJSStringRef operationStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_OPERATION));
+       const ScopedJSStringRef uriStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_URI));
+       const ScopedJSStringRef mimeStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_MIME));
        const ScopedJSStringRef extraDataStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRADATA));   
 
        JSObjectRef jsObject = toJSObjectRef(jsValue);
 
+       JSValueRef jsoperation = JSObjectGetProperty(m_context, jsObject, operationStr.get(), NULL);
+       JSValueRef jsuri = JSObjectGetProperty(m_context, jsObject, uriStr.get(), NULL);
+       JSValueRef jsmime = JSObjectGetProperty(m_context, jsObject, mimeStr.get(), NULL);
        JSValueRef jsextradata = JSObjectGetProperty(m_context, jsObject, extraDataStr.get(), NULL);    
 
-       ApplicationServiceExtraDataArrayPtr extraDataArray;
+       std::string operation;
+       std::string uri;
+       std::string mime;
+       std::vector<ApplicationServiceDataPtr> extraDataArray;
        
-       ApplicationServiceReplyPtr result(new ApplicationServiceReply());
+       ApplicationServicePtr result(new ApplicationService());
        if (!result) {
                Throw(Commons::ConversionException);
        }
 
+       if (!JSValueIsUndefined(m_context, jsoperation)) {
+               operation = toString(jsoperation);
+               LogDebug("operation : "<<operation);
+               result->setOperation(operation);
+       }
+
+       if (!JSValueIsUndefined(m_context, jsuri)) {
+               uri = toString(jsuri);
+               result->setUri(uri);
+       }
+
+       if (!JSValueIsUndefined(m_context, jsmime)) {
+               mime = toString(jsmime);
+               result->setMime(mime);
+       }
+
        if (!JSValueIsUndefined(m_context, jsextradata)) {
-               extraDataArray = toApplicationServiceExtraDataArray(jsextradata);
-               result->setExtraDataArray(extraDataArray);
+               extraDataArray = toApplicationServiceDataArray(jsextradata);
+               result->setServiceDataArray(extraDataArray);
        }
        LogDebug("done");
        return result;
 }
 
-JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServiceExtraDataPtr &arg)
+JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServiceDataPtr &arg)
 {
        LogDebug("entered");
-       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationServiceExtraData::getClassRef(), arg);
+       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationServiceData::getClassRef(), arg);
 }
 
-ApplicationServiceExtraDataPtr ApplicationConverter::toApplicationServiceExtraData(const JSValueRef &jsValue)
+ApplicationServiceDataPtr ApplicationConverter::toApplicationServiceData(const JSValueRef &jsValue)
 {
-       if(JSApplicationServiceExtraData::isObjectOfClass(m_context, jsValue))
-               return JSApplicationServiceExtraData::getApplicationServiceExtraData(m_context, jsValue);
+       if(JSApplicationServiceData::isObjectOfClass(m_context, jsValue))
+               return JSApplicationServiceData::getApplicationServiceData(m_context, jsValue);
 
        CommonsJavaScript::Validator validator(m_context);
-       if (!validator.checkArrayKeys(m_allowedApplicationServiceExtraData, jsValue)) {
+       if (!validator.checkArrayKeys(m_allowedApplicationServiceData, jsValue)) {
                LogError("invalid properties in contact object");
                ThrowMsg(Commons::ConversionException, "Wrong attribute");
        }
 
-       const ScopedJSStringRef extraDataKeyStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRA_KEY));
-       const ScopedJSStringRef extraDataValueStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRA_VALUE));
+       const ScopedJSStringRef serviceDataKeyStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRA_KEY));
+       const ScopedJSStringRef serviceDataValueStr(JSStringCreateWithUTF8CString(APPLICATOIN_ATTRIBUTE_EXTRA_VALUE));
 
        JSObjectRef jsObject = toJSObjectRef(jsValue);
 
-       JSValueRef extraDataKeyData = JSObjectGetProperty(m_context, jsObject, extraDataKeyStr.get(), NULL);
-       JSValueRef extraDataValueData = JSObjectGetProperty(m_context, jsObject, extraDataValueStr.get(), NULL);
+       JSValueRef serviceDataKeyData = JSObjectGetProperty(m_context, jsObject, serviceDataKeyStr.get(), NULL);
+       JSValueRef serviceDataValueData = JSObjectGetProperty(m_context, jsObject, serviceDataValueStr.get(), NULL);
 
-       std::string extraDataKey;
-       std::string extraDataValue;     
-
-       ApplicationServiceExtraDataPtr result(new ApplicationServiceExtraData());
+       ApplicationServiceDataPtr result(new ApplicationServiceData());
        if (!result) {
                Throw(Commons::ConversionException);
        }
 
-       if (!JSValueIsUndefined(m_context, extraDataKeyData)) {
-               extraDataKey = toString(extraDataKeyData);
-               result->setKey(extraDataKey);
+       if (!JSValueIsUndefined(m_context, serviceDataKeyData)) {
+               result->setKey(toString(serviceDataKeyData));
        }
 
-       if (!JSValueIsUndefined(m_context, extraDataValueData)) {
-               extraDataValue = toString(extraDataValueData);
-               result->setValue(extraDataValue);
+       if (!JSValueIsUndefined(m_context, serviceDataValueData)) {
+               result->setValue(toVectorOfStrings(serviceDataValueData));
        }
        return result;
 }
 
-JSValueRef ApplicationConverter::toJSValueRef(const ApplicationServiceExtraDataArrayPtr &arg)
+JSValueRef ApplicationConverter::toJSValueRef(const std::vector<ApplicationServiceDataPtr> &arg)
 {
-       LogDebug("entered");
-       return CommonsJavaScript::JSUtils::makeObject(m_context, JSApplicationServiceExtraDataArray::getClassRef(), arg);
+    JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+
+    if (NULL == jsResult) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+                 "Could not create js array object");
+    }
+
+    for (std::size_t i = 0; i < arg.size(); ++i) {
+        JSValueRef tmpVal = toJSValueRef(arg[i]);
+        if (!JSSetArrayElement(m_context, jsResult, i, tmpVal)) {
+            ThrowMsg(WrtDeviceApis::Commons::UnknownException,
+                     "Could not insert value into js array");
+        }
+    }
+
+    return jsResult;   
 }
 
-ApplicationServiceExtraDataArrayPtr ApplicationConverter::toApplicationServiceExtraDataArray(const JSValueRef &jsValue)
+std::vector<ApplicationServiceDataPtr> ApplicationConverter::toApplicationServiceDataArray(const JSValueRef &jsValue)
 {
-       if(JSApplicationServiceExtraDataArray::isObjectOfClass(m_context, jsValue))
-               return JSApplicationServiceExtraDataArray::getApplicationServiceExtraDataArray(m_context, jsValue);
+       //return  WrtDeviceApis::CommonsJavaScript::Converter::toVectorOfT_(jsValue, &ApplicationConverter::toApplicationServiceData);
+    if (JSValueIsNull(m_context,
+                      jsValue) || JSValueIsUndefined(m_context, jsValue)) {
+        return std::vector<ApplicationServiceDataPtr>();
+    }
 
-       ApplicationServiceExtraDataArrayPtr result(new ApplicationServiceExtraDataArray());
+    if (!JSIsArrayValue(m_context, jsValue)) {
+        ThrowMsg(Commons::ConversionException, "Argument is not an JS array.");
+    }
 
-       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(toApplicationServiceExtraData(element));
+    std::vector<ApplicationServiceDataPtr> result;
+    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(toApplicationServiceData(element));
     }
-    return result;
+    return result;     
 }
 
 bool ApplicationConverter::initializeAllowedProperties()
 {
        m_allowedApplicationInformation.push_back(APPLICATOIN_ATTRIBUTE_NAME);
-       m_allowedApplicationInformation.push_back(APPLICATOIN_ATTRIBUTE_PACKAGE_NAME);
+       m_allowedApplicationInformation.push_back(APPLICATOIN_ATTRIBUTE_APP_ID);
        m_allowedApplicationInformation.push_back(APPLICATOIN_ATTRIBUTE_ICONF_PATH);
        m_allowedApplicationInformation.push_back(APPLICATOIN_ATTRIBUTE_VERSION);       
 
-       m_allowedApplicationServiceRequest.push_back(APPLICATOIN_ATTRIBUTE_OPERATION);  
-       m_allowedApplicationServiceRequest.push_back(APPLICATOIN_ATTRIBUTE_URI);
-       m_allowedApplicationServiceRequest.push_back(APPLICATOIN_ATTRIBUTE_MIME);
-       m_allowedApplicationServiceRequest.push_back(APPLICATOIN_ATTRIBUTE_PACKAGE_NAME);
-       m_allowedApplicationServiceRequest.push_back(APPLICATOIN_ATTRIBUTE_EXTRADATA);
+       m_allowedApplicationService.push_back(APPLICATOIN_ATTRIBUTE_OPERATION); 
+       m_allowedApplicationService.push_back(APPLICATOIN_ATTRIBUTE_URI);
+       m_allowedApplicationService.push_back(APPLICATOIN_ATTRIBUTE_MIME);
+       m_allowedApplicationService.push_back(APPLICATOIN_ATTRIBUTE_EXTRADATA);
 
-       m_allowedApplicationServiceReply.push_back(APPLICATOIN_ATTRIBUTE_EXTRADATA);
+//     m_allowedApplicationServiceReply.push_back(APPLICATOIN_ATTRIBUTE_EXTRADATA);
 
-       m_allowedApplicationServiceExtraData.push_back(APPLICATOIN_ATTRIBUTE_EXTRA_KEY);
-       m_allowedApplicationServiceExtraData.push_back(APPLICATOIN_ATTRIBUTE_EXTRA_VALUE);
+       m_allowedApplicationServiceData.push_back(APPLICATOIN_ATTRIBUTE_EXTRA_KEY);
+       m_allowedApplicationServiceData.push_back(APPLICATOIN_ATTRIBUTE_EXTRA_VALUE);
 
        return true;
 }
index c6a32d1..b1803db 100755 (executable)
@@ -22,9 +22,9 @@
 #include <CommonsJavaScript/Converter.h>
 #include <API/Application/IApplication.h>
 #include <API/Application/ApplicationInformation.h>
-#include <API/Application/ApplicationServiceExtraData.h>
-#include <API/Application/ApplicationServiceRequest.h>
-#include <API/Application/ApplicationServiceReply.h>
+#include <API/Application/ApplicationContext.h>
+#include <API/Application/ApplicationServiceData.h>
+#include <API/Application/ApplicationService.h>
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -40,22 +40,23 @@ public:
        Api::Application::ApplicationInformationPtr toApplicationInformation(const JSValueRef &jsValue);
        JSValueRef toJSValueRef(const Api::Application::ApplicationInformationArrayPtr &arg);
        Api::Application::ApplicationInformationArrayPtr toApplicationInformationArray(const JSValueRef &jsValue);
-       JSValueRef toJSValueRef(const Api::Application::ApplicationServiceRequestPtr &arg);
-       Api::Application::ApplicationServiceRequestPtr toApplicationServiceRequest(const JSValueRef &jsValue);
-       JSValueRef toJSValueRef(const Api::Application::ApplicationServiceReplyPtr &arg);
-       Api::Application::ApplicationServiceReplyPtr toApplicationServiceReply(const JSValueRef &jsValue);
-       JSValueRef toJSValueRef(const Api::Application::ApplicationServiceExtraDataPtr &arg);
-       Api::Application::ApplicationServiceExtraDataPtr toApplicationServiceExtraData(const JSValueRef &jsValue);
-       JSValueRef toJSValueRef(const Api::Application::ApplicationServiceExtraDataArrayPtr &arg);
-       Api::Application::ApplicationServiceExtraDataArrayPtr toApplicationServiceExtraDataArray(const JSValueRef &jsValue);
-
+       JSValueRef toJSValueRef(const Api::Application::ApplicationContextPtr &arg);
+       Api::Application::ApplicationContextPtr toApplicationContext(const JSValueRef &jsValue);
+       JSValueRef toJSValueRef(const Api::Application::ApplicationContextArrayPtr &arg);
+       Api::Application::ApplicationContextArrayPtr toApplicationContextArray(const JSValueRef &jsValue);      
+       JSValueRef toJSValueRef(const Api::Application::ApplicationServicePtr &arg);
+       Api::Application::ApplicationServicePtr toApplicationService(const JSValueRef &jsValue);
+       JSValueRef toJSValueRef(const Api::Application::ApplicationServiceDataPtr &arg);
+       Api::Application::ApplicationServiceDataPtr toApplicationServiceData(const JSValueRef &jsValue);
+       JSValueRef toJSValueRef(const std::vector<Api::Application::ApplicationServiceDataPtr> &arg);
+       std::vector<Api::Application::ApplicationServiceDataPtr> toApplicationServiceDataArray(const JSValueRef &jsValue);
 
 private:
        bool initializeAllowedProperties();
        static std::vector<std::string> m_allowedApplicationInformation;
-       static std::vector<std::string> m_allowedApplicationServiceRequest;
-       static std::vector<std::string> m_allowedApplicationServiceReply;
-       static std::vector<std::string> m_allowedApplicationServiceExtraData;
+       static std::vector<std::string> m_allowedApplicationContext;
+       static std::vector<std::string> m_allowedApplicationService;
+       static std::vector<std::string> m_allowedApplicationServiceData;
 
 };
 
diff --git a/src/standards/Tizen/Application/ApplicationInformationEventCallback.h b/src/standards/Tizen/Application/ApplicationInformationEventCallback.h
new file mode 100755 (executable)
index 0000000..42f02ee
--- /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 TIZENAPIS_TIZEN_APPLICATION_INFORMATION_EVENT_CALLBACK_H_
+#define TIZENAPIS_TIZEN_APPLICATION_INFORMATION_EVENT_CALLBACK_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+struct ApplicationInformationEventCallback
+{
+    JSValueRef onInstalled;
+    JSValueRef onUpdated;
+    JSValueRef onUninstalled;
+       JSValueRef onError;
+
+    ApplicationInformationEventCallback() :
+        onInstalled(NULL),
+        onUpdated(NULL),
+        onUninstalled(NULL),
+        onError(NULL)
+    {
+    }
+};
+
+typedef DPL::SharedPtr<ApplicationInformationEventCallback> ApplicationInformationEventCallbackPtr;
+}
+}
+}
+#endif
diff --git a/src/standards/Tizen/Application/ApplicationInformationEventPrivateData.h b/src/standards/Tizen/Application/ApplicationInformationEventPrivateData.h
new file mode 100755 (executable)
index 0000000..0f7763e
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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_APPLICATION_INFORMATION_EVENT_PRIVATE_DATA_H_
+#define TIZENAPIS_TIZEN_APPLICATION_INFORMATION_EVENT_PRIVATE_DATA_H_
+
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {        
+
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+class ApplicationInformationEventPrivateData : public WrtDeviceApis::Commons::IEventPrivateData
+{
+  public:
+    ApplicationInformationEventPrivateData(const JSCallbackManagerPtr& onInstalled,
+                                                                     const JSCallbackManagerPtr& onUpdated, 
+                                                                     const JSCallbackManagerPtr& onUninstalled):
+        m_onInstalled(onInstalled),
+        m_onUpdated(onUpdated),
+        m_onUninstalled(onUninstalled)
+    {
+    }
+
+    JSCallbackManagerPtr getOnInstalled() const
+    {
+        return m_onInstalled;
+    }
+    JSCallbackManagerPtr getOnUpdated() const
+    {
+        return m_onUpdated;
+    }
+    JSCallbackManagerPtr getOnUninstalled() const
+    {
+        return m_onUninstalled;
+    }
+
+private:
+    JSCallbackManagerPtr m_onInstalled;
+    JSCallbackManagerPtr m_onUpdated;
+    JSCallbackManagerPtr m_onUninstalled;
+};
+
+typedef DPL::SharedPtr<ApplicationInformationEventPrivateData> ApplicationInformationEventPrivateDataPtr;
+}
+}
+}
+#endif
index 8fa7708..35d752f 100755 (executable)
 #include <JavaScriptCore/JavaScript.h>
 #include <CommonsJavaScript/JSCallbackManager.h>
 #include <CommonsJavaScript/Converter.h>
+#include "ApplicationConverter.h"
 #include "JSApplicationInformation.h"
 #include "JSApplicationEvent.h"
 #include "ApplicationListener.h"
+#include "API/Application/ApplicationInformation.h"
+#include "ApplicationInformationEventPrivateData.h"
+
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -49,33 +53,51 @@ ApplicationListener::ApplicationListener() :
 
 void ApplicationListener::onAnswerReceived(const EventInstalledApplicationChangedPtr& event) 
 {
-       JSCallbackManagerPtr callbackManager = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
-       JSContextRef context = callbackManager->getContext();
-       Converter converter(context);
-       
-       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
+       LogError(">>> onAnswerReceived for EventInstalledApplicationChanged");
+       ApplicationInformationEventPrivateDataPtr priveData = DPL::DynamicPointerCast<ApplicationInformationEventPrivateData>(event->getPrivateData());
 
-               Try
-               {               
-                       JSValueRef result = JSApplicationEvent::createJSObject(context, event->getEventCode(), event->getApplicationInformation());
-                       callbackManager->callOnSuccess(result);
+       if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None)
+       {
+               Try 
+               {
+                       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(priveData->getOnInstalled()->getContext());
+                       // TODO: why send event code to string. enum value is enough!!
+                       if (event->getEventCode() == APPLICATON_EVENT_CODE_INSTALLED) 
+                       {
+                               LogError(">>> installed event is come");
+                               JSValueRef result = converter->toJSValueRef(event->getApplicationInformation());
+                               priveData->getOnInstalled()->callOnSuccess(result);
+                       } 
+                       else if (event->getEventCode() == APPLICATON_EVENT_CODE_UPDATED) 
+                       {
+                               LogError(">>> updated event is come");
+                               JSValueRef result = converter->toJSValueRef(event->getApplicationInformation());
+                               priveData->getOnUpdated()->callOnSuccess(result);
+                       }
+                       else if (event->getEventCode() == APPLICATON_EVENT_CODE_UNINSTALLED) 
+                       {
+                               LogError(">>> uninstalled event is come");
+                               JSValueRef result = converter->toJSValueRef(event->getApplicationInformation()->getAppId());
+                               priveData->getOnUninstalled()->callOnSuccess(result);
+                       }
                }
-               Catch(WrtDeviceApis::Commons::Exception)
+               Catch (WrtDeviceApis::Commons::Exception)
                {
                        LogError("error during function executing");
                }
        }
-       else {
+       else 
+       {
                LogDebug("Operation failed. Exception code: " << event->getExceptionCode());
                JSValueRef errorObject = NULL;
 
                WrtDeviceApis::Commons::ExceptionCodes::Enumeration exception = event->getExceptionCode();
                switch(exception){
                        default:
-                               errorObject = JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"unknown error");
+                               errorObject = JSTizenExceptionFactory::makeErrorObject(priveData->getOnInstalled()->getContext(),JSTizenException::UNKNOWN_ERROR,"unknown error");
                                break;
                }
-               callbackManager->callOnError(errorObject);
+               priveData->getOnInstalled()->callOnError(errorObject);
        }       
 }
 
index 7deed12..2110c1d 100755 (executable)
@@ -14,11 +14,11 @@ set(SRCS
   JSApplication.cpp
   JSApplicationInformation.cpp
   JSApplicationInformationArray.cpp
+  JSApplicationContext.cpp
+  JSApplicationContextArray.cpp  
   JSApplicationEvent.cpp
-  JSApplicationServiceExtraData.cpp
-  JSApplicationServiceExtraDataArray.cpp
-  JSApplicationServiceRequest.cpp
-  JSApplicationServiceReply.cpp
+  JSApplicationService.cpp
+  JSApplicationServiceData.cpp
   LaunchServicePrivateData.cpp
   ../Common/JSTizenException.cpp
   ../Common/TizenExceptionData.cpp
index 0b796c5..f848129 100755 (executable)
@@ -27,6 +27,7 @@
 #include <Tizen/Common/JSTizenException.h>
 #include <API/Application/ApplicationFactory.h>
 #include <API/Application/EventListInstalledApplications.h>
+#include <API/Application/EventManageApplication.h>
 #include <API/Application/EventGetApplication.h>
 #include <API/Application/EventLaunchService.h>
 #include "plugin_config.h"
 #include "JSApplication.h"
 #include "ApplicationConverter.h"
 #include "ApplicationServiceReplyCallback.h"
+#include "ApplicationInformationEventCallback.h"
 #include "LaunchServicePrivateData.h"
-#include "JSApplicationServiceRequest.h"
-#include "JSApplicationServiceReply.h"
+#include "ApplicationInformationEventPrivateData.h"
+#include "JSApplicationService.h"
 #include <bundle.h>
 
 namespace TizenApis {
@@ -76,12 +78,18 @@ JSClassDefinition JSApplication::m_classInfo = {
 };
 
 JSStaticFunction JSApplication::m_function[] = {
-               { "listInstalledApplications",JSApplication::listInstalledApplications,kJSPropertyAttributeNone },
-               { "listRunningApplications",JSApplication::listRunningApplications,kJSPropertyAttributeNone },
+               { "launch",JSApplication::launch,kJSPropertyAttributeNone },
+               { "exit",JSApplication::exit,kJSPropertyAttributeNone },
+               { "kill",JSApplication::kill,kJSPropertyAttributeNone },
+               { "hide",JSApplication::hide,kJSPropertyAttributeNone },
+               { "getApplicationInformations",JSApplication::getApplicationInformations,kJSPropertyAttributeNone },
+               { "getRunningApplicationContexts",JSApplication::getRunningApplicationContexts,kJSPropertyAttributeNone },
                { "getApplicationInformation",JSApplication::getApplicationInformation,kJSPropertyAttributeNone },
-               { "addApplicationListChangeListener",JSApplication::addApplicationListChangeListener,kJSPropertyAttributeNone },
-               { "removeApplicationListChangeListener",JSApplication::removeApplicationListChangeListener,kJSPropertyAttributeNone },
-               { "launchService",JSApplication::launchService,kJSPropertyAttributeNone },                      
+               { "getCurrentApplicationContext",JSApplication::getCurrentApplicationContext,kJSPropertyAttributeNone },
+               { "addApplicationInformationEventListener",JSApplication::addApplicationInformationEventListener,kJSPropertyAttributeNone },
+               { "removeApplicationInformationEventListener",JSApplication::removeApplicationInformationEventListener,kJSPropertyAttributeNone },
+               { "launchService",JSApplication::launchService,kJSPropertyAttributeNone },
+               { "getApplicationService",JSApplication::getApplicationService,kJSPropertyAttributeNone },
                { 0, 0, 0 }
 };
 
@@ -121,7 +129,7 @@ bool JSApplication::hasInstance(JSContextRef context,
        return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
-JSValueRef JSApplication::listInstalledApplications(JSContextRef context, 
+JSValueRef JSApplication::launch(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -134,7 +142,260 @@ JSValueRef JSApplication::listInstalledApplications(JSContextRef context,
 
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
                                gContext,
-                               APPLICATION_FUNCTION_API_LIST_INSTALLED_APPLICATIONS);
+                               APPLICATION_FUNCTION_API_LAUNCH);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+    if ((argumentCount < 2) ||
+        (JSValueIsNull(context, arguments[0]) ||
+         JSValueIsUndefined(context, arguments[0]) ||
+         JSObjectIsFunction(context, converter->toJSObjectRef(arguments[0]))) ||
+        (JSValueIsNull(context, arguments[1]) || 
+         JSValueIsUndefined(context, arguments[1]) ||
+         !JSObjectIsFunction(context, converter->toJSObjectRef(arguments[1]))) ||
+        (argumentCount > 2 &&
+         (JSValueIsUndefined(context, arguments[2]) ||
+         !JSObjectIsFunction(context, converter->toJSObjectRef(arguments[2])))) ||
+        (argumentCount > 3 &&
+         (JSValueIsUndefined(context, arguments[3]) ||
+         JSObjectIsFunction(context, converter->toJSObjectRef(arguments[3]))))) {
+        LogError("Wrong callbacks parameters");
+               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]);
+
+       EventManageApplicationPtr event(new EventManageApplication());
+       Try{
+               IApplicationPtr applications(priv->getObject());
+               event->setEventType(EventManageApplication::APP_MANAGER_LAUNCH_APPLICATION);
+               event->setAppId(converter->toString( arguments[0] ));
+               if (argumentCount > 3) {
+                       event->setArgument(converter->toString(arguments[3]));
+               }
+               event->setPrivateData(StaticPointerCast<IEventPrivateData>(callbackManager));
+               event->setForAsynchronousCall(new ApplicationAnswerReceiver(callbackManager));
+               applications->launch(event);
+       }Catch (WrtDeviceApis::Commons::ConversionException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }Catch (WrtDeviceApis::Commons::PendingOperationException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Pending operation failed"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::NullPointerException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeUndefined(context);
+       }Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplication::kill(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+       assert(priv && "Invalid private pointer.");
+       JSContextRef gContext = priv->getContext();
+
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+                               gContext,
+                               APPLICATION_FUNCTION_API_KILL);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+    if ((argumentCount < 2) ||
+        (JSValueIsNull(context,
+                        arguments[0]) ||
+         JSValueIsUndefined(context,
+                             arguments[0]) ||
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[0]))) ||
+        (JSValueIsNull(context,
+                        arguments[1]) ||
+         JSValueIsUndefined(context,
+                             arguments[1]) ||
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[1]))) ||                             
+        (argumentCount > 2 &&
+         !JSValueIsNull(context,
+                        arguments[2]) &&
+         !JSValueIsUndefined(context,
+                             arguments[2]) &&
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[2])))) {
+        LogError("Wrong callbacks parameters");
+               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]);
+
+       EventManageApplicationPtr event(new EventManageApplication());
+       Try{
+               ApplicationContextPtr appContext = converter->toApplicationContext(arguments[0]);
+               
+               IApplicationPtr applications(priv->getObject());
+               event->setEventType(EventManageApplication::APP_MANAGER_KILL_APPLICATION);
+               event->setApplicationContext(appContext);
+               event->setPrivateData(StaticPointerCast<IEventPrivateData>(callbackManager));
+               event->setForAsynchronousCall(new ApplicationAnswerReceiver(callbackManager));
+               applications->kill(event);
+       }Catch (WrtDeviceApis::Commons::ConversionException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }Catch (WrtDeviceApis::Commons::PendingOperationException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Pending operation failed"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::NullPointerException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeUndefined(context);
+       }Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplication::exit(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       LogError("== [WS] enter JSApplication::exit");
+
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+       assert(priv && "Invalid private pointer.");
+       JSContextRef gContext = priv->getContext();
+
+       LogError("== [WS] call ACE");
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+                               gContext,
+                               APPLICATION_FUNCTION_API_EXIT);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       Try{
+               LogError("== [WS] get applications");
+               IApplicationPtr applications(priv->getObject());
+               LogError("== [WS] applications->exit()");
+               applications->exit();
+       } Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+       LogError("exit JSApplication::exit");
+       return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSApplication::hide(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+       assert(priv && "Invalid private pointer.");
+       JSContextRef gContext = priv->getContext();
+
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+                               gContext,
+                               APPLICATION_FUNCTION_API_HIDE);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+    if ((argumentCount < 2) ||
+        (JSValueIsNull(context,
+                        arguments[0]) ||
+         JSValueIsUndefined(context,
+                             arguments[0]) ||
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[0]))) ||
+        (JSValueIsNull(context,
+                        arguments[1]) ||
+         JSValueIsUndefined(context,
+                             arguments[1]) ||
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[1]))) ||                             
+        (argumentCount > 2 &&
+         !JSValueIsNull(context,
+                        arguments[2]) &&
+         !JSValueIsUndefined(context,
+                             arguments[2]) &&
+         !JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[2])))) {
+        LogError("Wrong callbacks parameters");
+               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]);
+
+       EventManageApplicationPtr event(new EventManageApplication());
+       Try{
+               ApplicationContextPtr appContext = converter->toApplicationContext(arguments[0]);
+               
+               IApplicationPtr applications(priv->getObject());
+               event->setEventType(EventManageApplication::APP_MANAGER_HIDE_APPLICATION);
+               event->setApplicationContext(appContext);
+               event->setPrivateData(StaticPointerCast<IEventPrivateData>(callbackManager));
+               event->setForAsynchronousCall(new ApplicationAnswerReceiver(callbackManager));
+               applications->hide(event);
+       }Catch (WrtDeviceApis::Commons::ConversionException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }Catch (WrtDeviceApis::Commons::PendingOperationException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Pending operation failed"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+               return JSValueMakeUndefined(context);
+       }Catch (WrtDeviceApis::Commons::NullPointerException){
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+               return JSValueMakeUndefined(context);
+       }Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSApplication::getApplicationInformations(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+       assert(priv && "Invalid private pointer.");
+       JSContextRef gContext = priv->getContext();
+
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+                               gContext,
+                               APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATIONS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
@@ -187,7 +448,59 @@ JSValueRef JSApplication::listInstalledApplications(JSContextRef context,
        return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSApplication::listRunningApplications(JSContextRef context, 
+JSValueRef JSApplication::getApplicationInformation(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+
+       assert(priv && "Invalid private pointer.");
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+               priv->getContext(),
+               APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATION);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+
+       std::string appid;
+       
+       if ((argumentCount == 0) || ((argumentCount == 1) && JSValueIsNull(context, arguments[0]))) {
+               // skip. return empty string 
+       } else if ((argumentCount == 1) && JSValueIsString(context, arguments[0])) {
+               appid = converter->toString( arguments[0] );
+       } else if (JSValueIsUndefined(context, arguments[0])) {
+               LogError("Wrong package " << JSValueIsNull(context, arguments[0]) <<", "<<JSValueIsUndefined(context, arguments[0]));
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }
+       
+       Try
+    {
+               IApplicationPtr applications(priv->getObject());
+               EventGetApplicationPtr event(new EventGetApplication());
+               event->setEventType(EventGetApplication::APP_MANAGER_GET_INFORMATION);
+               event->setForSynchronousCall();
+               event->setAppId(appid);
+               applications->getApplication(event);
+               if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::NotFoundException) {
+                       return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_FOUND_ERROR, "Given package is not found");                      
+               }
+               return converter->toJSValueRef(event->getApplicationInformation());
+       }Catch (WrtDeviceApis::Commons::ConversionException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error");
+       }Catch (WrtDeviceApis::Commons::NullPointerException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+}
+
+JSValueRef JSApplication::getRunningApplicationContexts(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -201,7 +514,7 @@ JSValueRef JSApplication::listRunningApplications(JSContextRef context,
 
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
                                gContext,
-                               APPLICATION_FUNCTION_API_LIST_RUNNING_APPLICATIONS);
+                               APPLICATION_FUNCTION_API_GET_RUNNING_APPLICATION_CONTEXTS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
@@ -254,7 +567,7 @@ JSValueRef JSApplication::listRunningApplications(JSContextRef context,
        return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSApplication::getApplicationInformation(JSContextRef context, 
+JSValueRef JSApplication::getCurrentApplicationContext(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -266,34 +579,33 @@ JSValueRef JSApplication::getApplicationInformation(JSContextRef context,
        assert(priv && "Invalid private pointer.");
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
                priv->getContext(),
-               APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATION);
+               APPLICATION_FUNCTION_API_GET_CURRENT_APPLICATION_CONTEXT);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
+#if 0
        if(JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0])){
                LogError("Wrong package " << JSValueIsNull(context, arguments[0]) <<", "<<JSValueIsUndefined(context, arguments[0]));
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
        }
-       
-       EventGetApplicationPtr event(new EventGetApplication());
-       JSValueRef jsobj = NULL;
-
-       LogError("TEST");
+#endif
 
+       EventGetApplicationPtr event(new EventGetApplication());
 
        Try
     {
-               std::string package;            
-        package = converter->toString( arguments[0] );
                IApplicationPtr applications(priv->getObject());
+               event->setEventType(EventGetApplication::APP_MANAGER_GET_CONTEXT);
                event->setForSynchronousCall();
-               event->setPackage(package);
-               applications->getApplicationInformation(event);
+               applications->getApplication(event);
                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");
                }
-               jsobj = converter->toJSValueRef(event->getApplicationInformation());
+               return converter->toJSValueRef(event->getApplicationContext());
        }Catch (WrtDeviceApis::Commons::ConversionException){
+               LogError("== [WS] error on type mismatch");
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
        }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error");
@@ -303,10 +615,9 @@ JSValueRef JSApplication::getApplicationInformation(JSContextRef context,
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
-       return jsobj;
 }
 
-JSValueRef JSApplication::addApplicationListChangeListener(JSContextRef context, 
+JSValueRef JSApplication::addApplicationInformationEventListener(JSContextRef context, 
        JSObjectRef object, 
        JSObjectRef thisObject, 
        size_t argumentCount,
@@ -318,60 +629,83 @@ JSValueRef JSApplication::addApplicationListChangeListener(JSContextRef context,
        assert(priv && "Invalid private pointer.");
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
                priv->getContext(),
-               APPLICATION_FUNCTION_API_ADD_APPLICATION_LIST_CHANGE_LISTENER); 
+               APPLICATION_FUNCTION_API_ADD_APPLICATION_INFORMATION_EVENT_LISTENER);   
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-       CommonsJavaScript::Converter converter(context);
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
     if ((argumentCount == 0) ||
         (JSValueIsNull(context,
                         arguments[0]) ||
          JSValueIsUndefined(context,
                              arguments[0]) ||
-         !JSObjectIsFunction(context,
-                             converter.toJSObjectRef(arguments[0]))) ||
+         JSObjectIsFunction(context,
+                             converter->toJSObjectRef(arguments[0]))) ||
         (argumentCount > 1 &&
          !JSValueIsNull(context,
                         arguments[1]) &&
          !JSValueIsUndefined(context,
                              arguments[1]) &&
          !JSObjectIsFunction(context,
-                             converter.toJSObjectRef(arguments[1])))) {
+                             converter->toJSObjectRef(arguments[1])))) {
         LogError("Wrong callbacks parameters");
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
     }
-       JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(priv->getContext());
-       callbackManager->setOnSuccess(arguments[0]);
-       if (argumentCount >= 2)
-               callbackManager->setOnError(arguments[1]);
 
-       Try{
+       JSObjectRef objectCallbacks = converter->toJSObjectRef(arguments[0]);
+
+       ApplicationInformationEventCallback result;
+    result.onInstalled = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onInstalled");
+    result.onUpdated = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onUpdated");
+    result.onUninstalled = JSUtils::getJSPropertyOrUndefined(context, objectCallbacks, "onUninstalled");
+
+       if (argumentCount == 2) {
+               result.onError = arguments[1];
+       } else {
+               result.onError =JSValueMakeUndefined(context);
+       }
+
+       Validator validator(context);
+       if ((!validator.isNullOrUndefined(result.onInstalled) && !validator.isCallback(result.onInstalled)) ||
+               (!validator.isNullOrUndefined(result.onUpdated) && !validator.isCallback(result.onUpdated)) ||
+               (!validator.isNullOrUndefined(result.onUninstalled) && !validator.isCallback(result.onUninstalled))) 
+       {
+               LogError("Application Information Event Callbakc is not set properly!");
+               Throw(InvalidArgumentException);
+       }
+
+       JSCallbackManagerPtr onInstalledCbm = JSCallbackManager::createObject(priv->getContext(), result.onInstalled, result.onError);
+       JSCallbackManagerPtr onUpdatedCbm   = JSCallbackManager::createObject(priv->getContext(), result.onUpdated, result.onError);
+       JSCallbackManagerPtr onUninstalledCbm = JSCallbackManager::createObject(priv->getContext(), result.onUninstalled, result.onError);
+
+       ApplicationInformationEventPrivateDataPtr privData(new ApplicationInformationEventPrivateData(onInstalledCbm, onUpdatedCbm, onUninstalledCbm));
+       Try {
                IApplicationPtr applications(priv->getObject());
                EventInstalledApplicationChangedEmitterPtr emitter(new EventInstalledApplicationChangedEmitter);
                emitter->setListener(&ApplicationListener::getInstance());
-               emitter->setEventPrivateData(StaticPointerCast<EventInstalledApplicationChanged::PrivateDataType>(callbackManager));
-               unsigned long id = applications->addApplicationListChangeListener(emitter);
+               emitter->setEventPrivateData(StaticPointerCast<IEventPrivateData>(privData));
+               unsigned long id = applications->addApplicationInformationEventListener(emitter);
                LogInfo("id = "<<id);
                if(id == 0)
                        Throw(WrtDeviceApis::Commons::UnsupportedException);
 
-               return converter.toJSValueRef(id);
-       }Catch (WrtDeviceApis::Commons::ConversionException){
+               return converter->toJSValueRef(id);
+       } Catch (WrtDeviceApis::Commons::ConversionException){
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
-       }Catch (WrtDeviceApis::Commons::UnsupportedException){
+       } Catch (WrtDeviceApis::Commons::UnsupportedException){
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::NOT_SUPPORTED_ERROR, "Not supported or already registered"); 
-       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
+       } Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               onUpdatedCbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error"));
                return JSValueMakeUndefined(context);
-       }Catch (WrtDeviceApis::Commons::NullPointerException){
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
+       } Catch (WrtDeviceApis::Commons::NullPointerException){
+               onUpdatedCbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context,JSTizenException::UNKNOWN_ERROR,"Unknown error"));
                return JSValueMakeUndefined(context);
-       }Catch(WrtDeviceApis::Commons::Exception){
+       } Catch(WrtDeviceApis::Commons::Exception){
                LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
        }
 }
 
-JSValueRef JSApplication::removeApplicationListChangeListener(JSContextRef context,
+JSValueRef JSApplication::removeApplicationInformationEventListener(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -382,9 +716,9 @@ JSValueRef JSApplication::removeApplicationListChangeListener(JSContextRef conte
     assert(priv && "Invalid private pointer.");
        AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
                priv->getContext(),
-               APPLICATION_FUNCTION_API_REMOVE_APPLICATION_LIST_CHANGE_LISTENER);
+               APPLICATION_FUNCTION_API_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-    CommonsJavaScript::Converter converter(context);
+    ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
     Try
     {
         IApplicationPtr applications = priv->getObject();
@@ -394,8 +728,8 @@ JSValueRef JSApplication::removeApplicationListChangeListener(JSContextRef conte
                        Throw(WrtDeviceApis::Commons::InvalidArgumentException);
                }
 
-               long id = converter.toLong(arguments[0]);
-        applications->removeApplicationListChangeListener(id);
+               long id = converter->toLong(arguments[0]);
+        applications->removeApplicationInformationEventListener(id);
        }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
        }Catch (WrtDeviceApis::Commons::ConversionException){
@@ -428,24 +762,16 @@ JSValueRef JSApplication::launchService(JSContextRef context,
 
        ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
 
-    if ((argumentCount < 2) ||
-    (JSValueIsNull(context,
-                    arguments[0]) ||
-     JSValueIsUndefined(context,
-                         arguments[0]) ||
-        JSValueIsNull(context,
-                    arguments[1]) ||
-     JSValueIsUndefined(context,
-                         arguments[1]) ||                       
-     !JSObjectIsFunction(context,
-                         converter->toJSObjectRef(arguments[1]))) ||
-    (argumentCount > 2 &&
-     !JSValueIsNull(context,
-                    arguments[2]) &&
-     !JSValueIsUndefined(context,
-                         arguments[2]) &&
-     !JSObjectIsFunction(context,
-                         converter->toJSObjectRef(arguments[2])))) {
+    if ((argumentCount < 1) ||
+               (JSValueIsNull(context, arguments[0]) ||
+                JSValueIsUndefined(context, arguments[0]) ||
+                JSObjectIsFunction(context, converter->toJSObjectRef(arguments[0]))) ||
+               ( (argumentCount > 1) &&
+                !JSObjectIsFunction(context, converter->toJSObjectRef(arguments[1]))) ||
+               ( (argumentCount > 2) &&
+                !JSObjectIsFunction(context, converter->toJSObjectRef(arguments[2]))) ||
+               ( (argumentCount > 3) &&
+                JSObjectIsFunction(context, converter->toJSObjectRef(arguments[3])))) {
         LogError("Wrong parameters");
                return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
        }
@@ -456,71 +782,51 @@ JSValueRef JSApplication::launchService(JSContextRef context,
                callbackManager->setOnError(arguments[2]);
 
        try {
-               ApplicationServiceRequestPtr appService;
+               ApplicationServicePtr appService;
                ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
-               appService = converter->toApplicationServiceRequest(arguments[0]);
+               appService = converter->toApplicationService(arguments[0]);
 
-               LogDebug("after toApplicationServiceRequest()");
-               // arguments[3] :  optional ,  onsuccess, onfail, oncancel
                JSCallbackManagerPtr replyCallbackManager;
-               JSCallbackManagerPtr replyCancelCallbackManager;                
                if( argumentCount >3)
                {
                        CommonsJavaScript::Validator validator(gContext);
                        ApplicationServiceReplyCallback result;
 
-                       JSObjectRef obj = JSValueToObject(context, arguments[3],NULL);
+                       JSObjectRef obj = JSValueToObject(context, arguments[3], NULL);
+
+                       result.onsuccess = JSUtils::getJSProperty(context, obj, "onSuccess");
                        
-                       result.onsuccess = JSUtils::getJSProperty(
-                               context, obj, "onsuccess");
                        if (!validator.isNullOrUndefined(result.onsuccess) &&
                                !validator.isCallback(result.onsuccess)) {
                                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Not a valid callback.");
                        }
-                       
-                       result.onfail = JSUtils::getJSProperty(
-                               context, obj, "onfail");
+
+                       result.onfail = JSUtils::getJSProperty(context, obj, "onFailed");
                        if (!validator.isNullOrUndefined(result.onfail) &&
                                !validator.isCallback(result.onfail)) {
                                ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Not a valid callback.");
                        }
-                       
-                       result.oncancel = JSUtils::getJSProperty(
-                               context, obj, "oncancel");
-                       if (!validator.isNullOrUndefined(result.oncancel) &&
-                               !validator.isCallback(result.oncancel)) {
-                               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Not a valid callback.");
-                       }
 
                        if(result.onsuccess || result.onfail)
                        {
                                replyCallbackManager = JSCallbackManager::createObject(priv->getContext(), 
                                                                result.onsuccess, result.onfail);
                        }
-
-                       if(result.oncancel)
-                       {
-                               replyCancelCallbackManager = JSCallbackManager::createObject(priv->getContext(), 
-                                                               result.oncancel, NULL);
-                       }
-
                }
 
-               LogDebug("replyCallback, replyCancel"<<callbackManager<<replyCallbackManager<<replyCancelCallbackManager);
-
+               LogDebug("replyCallback"<<callbackManager<<replyCallbackManager);
                LaunchServicePrivateDataPtr privateData( 
-                       new LaunchServicePrivateData(callbackManager,replyCallbackManager,replyCancelCallbackManager)); 
-
+                       new LaunchServicePrivateData(callbackManager,replyCallbackManager));
 
                LogDebug("after LaunchServicePrivateData()");
 
-
                EventLaunchServicePtr event(new EventLaunchService());
 
                IApplicationPtr applications(priv->getObject());
 
+               event->setEventType(EventLaunchService::APPLICATION_SERVICE_LAUNCH);
                event->setPrivateData(StaticPointerCast<IEventPrivateData> (privateData));
-               event->setServiceRequest(appService); 
+               event->setService(appService); 
                event->setForAsynchronousCall(new ApplicationAnswerReceiver(privateData));
 
                applications->launchService(event);
@@ -542,6 +848,55 @@ JSValueRef JSApplication::launchService(JSContextRef context,
     return JSValueMakeUndefined(context);      
 }
 
+JSValueRef JSApplication::getApplicationService(JSContextRef context, 
+       JSObjectRef object, 
+       JSObjectRef thisObject, 
+       size_t argumentCount,
+       const JSValueRef arguments[], 
+       JSValueRef* exception) 
+{
+       JSApplicationPriv *priv = static_cast<JSApplicationPriv*> (JSObjectGetPrivate(thisObject));
+
+       LogDebug("enter getApplicationService");
+
+       assert(priv && "Invalid private pointer.");
+       AceSecurityStatus status = APPLICATION_CHECK_ACCESS(
+               priv->getContext(),
+               APPLICATION_FUNCTION_API_GET_APPLICATION_SERVICE);
+       TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+       
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+       LogDebug("get EventLaunchServicePtr");
+       EventLaunchServicePtr event(new EventLaunchService());
+       
+       Try
+    {
+               IApplicationPtr applications(priv->getObject());
+               event->setEventType(EventLaunchService::APPLICATION_SERVICE_GET_REQUEST);
+               event->setForSynchronousCall();
+               LogDebug("call getApplicationService");
+               applications->getApplicationService(event);
+               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");
+               }
+               LogDebug("return result");
+               return converter->toJSValueRef(event->getService());
+       }Catch (WrtDeviceApis::Commons::ConversionException){
+               LogError("== [WS] error on type mismatch");
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::TYPE_MISMATCH_ERROR, "Type mistmatch error");
+       }Catch (WrtDeviceApis::Commons::InvalidArgumentException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::INVALID_VALUES_ERROR,"Invalid value error");
+       }Catch (WrtDeviceApis::Commons::NullPointerException){
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }Catch(WrtDeviceApis::Commons::Exception){
+               LogError("Exception: " << _rethrown_exception.GetMessage() << " Code: " << _rethrown_exception.getCode());
+               return JSTizenExceptionFactory::postException(context, exception,JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+}
+
 }
 }
 }
index b3247ae..cf6a64d 100755 (executable)
@@ -50,15 +50,39 @@ private:
        static bool hasInstance(JSContextRef context, JSObjectRef constructor, JSValueRef possibleInstance, JSValueRef* exception);
 
        /**
+        * Launches a application with given application id
+        */
+       static JSValueRef launch(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+        * Kills the application based on application context.
+        */
+       static JSValueRef kill(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+        * hide the application based on application context.
+        */
+       static JSValueRef hide(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+        * exit current application
+        */
+       static JSValueRef exit(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
         * Gets the list of installed packages.
         */
-       static JSValueRef listInstalledApplications(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getApplicationInformations(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Gets the list of running packages.
         */
-       static JSValueRef listRunningApplications(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef getRunningApplicationContexts(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);   
 
        /**
@@ -68,15 +92,21 @@ private:
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
+        * Gets the current application Context
+        */
+       static JSValueRef getCurrentApplicationContext(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
         * Watch for changes on installed applicaiton.
         */
-       static JSValueRef addApplicationListChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef addApplicationInformationEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
         * Unset installed Applications listener
         */
-       static JSValueRef removeApplicationListChangeListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       static JSValueRef removeApplicationInformationEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
@@ -86,6 +116,12 @@ private:
                        const JSValueRef arguments[], JSValueRef* exception);
 
        /**
+        * get request application service
+        */
+       static JSValueRef getApplicationService(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/Application/JSApplicationContext.cpp b/src/standards/Tizen/Application/JSApplicationContext.cpp
new file mode 100755 (executable)
index 0000000..01f102c
--- /dev/null
@@ -0,0 +1,218 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <API/Application/ApplicationContext.h>
+#include "JSApplicationContext.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {        
+       
+using namespace WrtDeviceApis;
+using namespace Api::Application;
+using namespace TizenApis::Commons;
+
+
+namespace {
+const char* APPLICATION_CONTEXT_APP_ID = "appId";
+const char* APPLICATION_CONTEXT_CONTEXT_ID = "contextId";
+
+} //private namespace
+
+JSClassRef JSApplicationContext::m_classRef = NULL;
+
+JSClassDefinition JSApplicationContext::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    "ApplicationContext",
+    0,
+    m_property,
+    0,
+    initialize,
+    finalize,
+    NULL,     //HasProperty,
+    NULL,
+    NULL,     //SetProperty,
+    NULL,     //DeleteProperty,
+    NULL,     //GetPropertyNames,
+    NULL,     //CallAsFunction,
+    NULL,     //CallAsConstructor,
+    NULL,
+    NULL,     //ConvertToType
+};
+
+JSStaticValue JSApplicationContext::m_property[] = {
+    { APPLICATION_CONTEXT_APP_ID, getAppId, setAppId, kJSPropertyAttributeReadOnly },
+       { APPLICATION_CONTEXT_CONTEXT_ID, getContextId, setContextId, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSApplicationContext::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+JSValueRef JSApplicationContext::createJSObject(JSContextRef context,
+               const std::string &appId,
+               const std::string &contextId)
+{
+       ApplicationContextPtr privateData = ApplicationContextPtr(new ApplicationContext());
+
+       privateData->setAppId(appId);
+       privateData->setContextId(contextId);   
+       JSApplicationContextPriv *priv = new JSApplicationContextPriv(context, privateData);
+       JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsValueRef) {
+               LogError("object creation error");
+               return JSValueMakeUndefined(context);
+       }
+       return jsValueRef;
+}
+
+void JSApplicationContext::initialize(JSContextRef context, JSObjectRef object)
+{
+       assert(NULL != JSObjectGetPrivate(object));
+}
+
+void JSApplicationContext::finalize(JSObjectRef object)
+{
+}
+
+bool JSApplicationContext::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+ApplicationContextPtr JSApplicationContext::getPrivData(JSObjectRef object)
+{
+       JSApplicationContextPriv *priv = static_cast<JSApplicationContextPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       ApplicationContextPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+ApplicationContextPtr JSApplicationContext::getApplicationContext(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSApplicationContextPriv *priv = static_cast<JSApplicationContextPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+JSValueRef JSApplicationContext::getAppId(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               CommonsJavaScript::Converter converter(context);
+               ApplicationContextPtr privateData = getPrivData(object);
+               return converter.toJSValueRef(privateData->getAppId());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationContext::setAppId(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef appId,
+               JSValueRef* exception)
+{
+       Try
+       {
+               ApplicationContextPtr 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 JSApplicationContext::getContextId(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               CommonsJavaScript::Converter converter(context);
+               ApplicationContextPtr privateData = getPrivData(object);
+               return converter.toJSValueRef(privateData->getContextId());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationContext::setContextId(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef contextId,
+               JSValueRef* exception)
+{
+       Try
+       {
+               ApplicationContextPtr privateData = getPrivData(object);
+               CommonsJavaScript::Converter converter(context);
+               privateData->setContextId(converter.toString(contextId));
+               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;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Application/JSApplicationContext.h b/src/standards/Tizen/Application/JSApplicationContext.h
new file mode 100755 (executable)
index 0000000..55d8a8c
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * 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_APPLICATION_CONTEXT_H_
+#define TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <dpl/shared_ptr.h>
+#include <API/Application/ApplicationContext.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationContextPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationContextPriv;
+
+class JSApplicationContext {
+public:
+       /*
+       * This initializes this JS class in the JS Engine.
+       */
+       static JSClassRef getClassRef();
+
+       static JSValueRef createJSObject(JSContextRef context,
+                       const std::string &appId,
+                       const std::string &contextId);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static Api::Application::ApplicationContextPtr 
+               getApplicationContext(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 Api::Application::ApplicationContextPtr getPrivData(JSObjectRef object);
+
+       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 getContextId(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setContextId(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef contextId,
+                       JSValueRef* exception);
+
+};
+
+}
+}
+}
+#endif
diff --git a/src/standards/Tizen/Application/JSApplicationContextArray.cpp b/src/standards/Tizen/Application/JSApplicationContextArray.cpp
new file mode 100755 (executable)
index 0000000..364026e
--- /dev/null
@@ -0,0 +1,565 @@
+/*
+ * 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 <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSApplicationContextArray.h"
+#include "ApplicationConverter.h"
+
+
+namespace {
+const char* FUNCTION_CONCAT = "concat";
+const char* FUNCTION_JOIN = "join";
+const char* FUNCTION_POP = "pop";
+const char* FUNCTION_PUSH = "push";
+const char* FUNCTION_REVERSE = "reverse";
+const char* FUNCTION_SHIFT = "shift";
+const char* FUNCTION_SLICE = "slice";
+const char* FUNCTION_SORT = "sort";
+const char* FUNCTION_SPLICE = "splice";
+const char* FUNCTION_TOSTRING = "toString";
+const char* FUNCTION_UNSHIFT = "unshift";
+const char* FUNCTION_VALUEOF = "valueOf";
+const char *ARRAY = "Array";
+const char *ATTRIBUTE_LENGTH = "length";
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {        
+
+using namespace Api::Application;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::CommonsJavaScript;
+       
+JSClassDefinition JSApplicationContextArray::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 JSApplicationContextArray::m_property[] = {
+       { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSApplicationContextArray::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 JSApplicationContextArray::m_jsClassRef = JSClassCreate(
+               JSApplicationContextArray::getClassInfo());
+
+JSValueRef JSApplicationContextArray::getLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               ApplicationContextArrayPtr privateDatas = priv->getObject();
+               if (privateDatas) {
+                       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+                       return converter->toJSValueRef(privateDatas->size());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid conversion");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSObjectRef JSApplicationContextArray::createArray(JSContextRef context,
+               const ApplicationContextArrayPtr &privateDatas)
+{
+       JSApplicationContextArrayPriv *priv = new JSApplicationContextArrayPriv(context, privateDatas);
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassDefinition* JSApplicationContextArray::getClassInfo()
+{
+       return &(m_classInfo);
+}
+
+JSClassRef JSApplicationContextArray::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+bool JSApplicationContextArray::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+ApplicationContextArrayPtr 
+       JSApplicationContextArray::getApplicationContextArray(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSApplicationContextArrayPriv *priv = static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSApplicationContextArray::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+       
+}
+
+void JSApplicationContextArray::finalize(JSObjectRef object)
+{
+       JSApplicationContextArrayPriv* priv =
+               static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+bool JSApplicationContextArray::hasProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName)
+{      
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               ApplicationContextArrayPtr privateDatas = priv->getObject();
+               if (index < privateDatas->size()) {
+                       return true;
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               //not reporting error is intended
+       }
+       return false;
+}
+
+JSValueRef JSApplicationContextArray::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               ApplicationContextArrayPtr privateDatas = priv->getObject();
+               if (index < privateDatas->size()) {
+                       ApplicationContextPtr result = privateDatas->at(index);
+                       if (result) {
+                               return converter->toJSValueRef(result);
+                       }
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationContextArray::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{      
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               ApplicationContextPtr privateData;
+               if (!JSValueIsUndefined(context, value)) {
+                       privateData = converter->toApplicationContext(value);
+               }
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               ApplicationContextArrayPtr privateDatas = priv->getObject();
+               if (!privateDatas) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               if (privateDatas->size() <= index) {
+                       privateDatas->resize(index + 1);
+               }
+               (*privateDatas)[index] = privateData;
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+               JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+       }
+       return false;
+}
+
+JSValueRef JSApplicationContextArray::concat(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               ApplicationContextArrayPtr privateDatas = ApplicationContextArrayPtr(new ApplicationContextArray());
+               JSApplicationContextArrayPriv *newPrivateObject = new JSApplicationContextArrayPriv(context, privateDatas);
+               JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject);
+
+               //copy current privateDatas
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               for (size_t i = 0; i < currentApplicationContexts->size(); ++i) {
+                       privateDatas->push_back(currentApplicationContexts->at(i));
+               }
+
+               //copy submitted arrays
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       if (!JSIsArrayValue(context, arguments[i])) {
+                               Throw(WrtDeviceApis::Commons::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);
+                               privateDatas->push_back(converter->toApplicationContext(att));
+                       }
+               }
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+}
+
+JSValueRef JSApplicationContextArray::join(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               std::string result;
+               std::string separator(",");
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
+                       separator = converter->toString(arguments[0]);
+               }
+               for (size_t i = 0; i < currentApplicationContexts->size(); ++i) {
+                       if (i != 0) {
+                               result += separator;
+                       }
+                       //FIXME : to be changed to support join
+                       //result += currentApplicationContexts->at(i);
+               }
+               return converter->toJSValueRef(result);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+}
+
+JSValueRef JSApplicationContextArray::pop(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{      
+       Try
+       {
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               if (currentApplicationContexts->size() > 0) {
+                       ApplicationContextPtr result = currentApplicationContexts->at(
+                                       currentApplicationContexts->size() - 1);
+                       currentApplicationContexts->pop_back();
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::push(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{      
+       Try
+       {
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       currentApplicationContexts->push_back(converter->toApplicationContext(arguments[i]));
+               }
+               return converter->toJSValueRef(currentApplicationContexts->size());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+}
+
+JSValueRef JSApplicationContextArray::reverse(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       Try
+       {
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               std::reverse(currentApplicationContexts->begin(), currentApplicationContexts->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::shift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       Try
+       {
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               if (currentApplicationContexts->size() > 0) {
+                       ApplicationContextPtr result = currentApplicationContexts->at(0);
+                       currentApplicationContexts->erase(currentApplicationContexts->begin());
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::slice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSValueMakeUndefined(context);
+               }
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               ApplicationContextArrayPtr privateDatas = ApplicationContextArrayPtr(new ApplicationContextArray());
+               JSApplicationContextArrayPriv *newPrivateObject = new JSApplicationContextArrayPriv(
+                               context,
+                               privateDatas);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current privateDatas
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               std::size_t first = converter->toSizeT(arguments[0]);
+               std::size_t last = currentApplicationContexts->size() - 1;
+               if (argumentCount > 1) {
+                       last = converter->toSizeT(arguments[1]);
+                       if (last >= currentApplicationContexts->size()) {
+                               last = currentApplicationContexts->size() - 1;
+                       }
+               }
+               if (first < 0) {
+                       first = 0;
+               }
+               for (size_t i = first; i <= last; ++i) {
+                       privateDatas->push_back(currentApplicationContexts->at(i));
+               }
+
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+}
+
+JSValueRef JSApplicationContextArray::sort(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       Try
+       {
+               //ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+               JSApplicationContextArrayPriv* priv =
+                       static_cast<JSApplicationContextArrayPriv*>(JSObjectGetPrivate(thisObject));
+               ApplicationContextArrayPtr currentApplicationContexts = priv->getObject();
+               std::sort(currentApplicationContexts->begin(), currentApplicationContexts->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::splice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::toString(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return join(context, function, thisObject, 0, arguments, exception);
+}
+
+JSValueRef JSApplicationContextArray::unshift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSApplicationContextArray::valueOf(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return JSValueMakeUndefined(context);
+}
+}
+}
+}
diff --git a/src/standards/Tizen/Application/JSApplicationContextArray.h b/src/standards/Tizen/Application/JSApplicationContextArray.h
new file mode 100755 (executable)
index 0000000..2ba0f70
--- /dev/null
@@ -0,0 +1,174 @@
+/*
+ * 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_APPLICATION_CONTEXT_ARRAY_H_
+#define TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_ARRAY_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Application/ApplicationContext.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Application::ApplicationContextArrayPtr>::Type JSApplicationContextArrayPriv;
+
+class JSApplicationContextArray
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createArray(JSContextRef context,
+            const Api::Application::ApplicationContextArrayPtr &appinfoArray);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static Api::Application::ApplicationContextArrayPtr 
+               getApplicationContextArray(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);
+
+    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 bool checkValue(const std::string &value);
+
+    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
index b6197fa..e288dd8 100755 (executable)
@@ -36,7 +36,7 @@ using namespace TizenApis::Commons;
 
 namespace {
 const char* APPLICATION_INFORMATION_NAME = "name";
-const char* APPLICATION_INFORMATION_PACKAGE_NAME = "packageName";
+const char* APPLICATION_INFORMATION_APP_ID = "appId";
 const char* APPLICATION_INFORMATION_ICONPATH = "iconPath";
 const char* APPLICATION_INFORMATION_VERSION = "version";
 
@@ -66,7 +66,7 @@ JSClassDefinition JSApplicationInformation::m_classInfo = {
 
 JSStaticValue JSApplicationInformation::m_property[] = {
     { APPLICATION_INFORMATION_NAME, getName, setName, kJSPropertyAttributeReadOnly },
-    { APPLICATION_INFORMATION_PACKAGE_NAME, getPackage, setPackage, kJSPropertyAttributeReadOnly },
+    { APPLICATION_INFORMATION_APP_ID, getAppId, setAppId, kJSPropertyAttributeReadOnly },
     { APPLICATION_INFORMATION_ICONPATH, getIconPath, setIconPath, kJSPropertyAttributeReadOnly },
     { APPLICATION_INFORMATION_VERSION, getVersion, setVersion, kJSPropertyAttributeReadOnly },    
     { 0, 0, 0, 0 }
@@ -81,14 +81,14 @@ JSClassRef JSApplicationInformation::getClassRef() {
 
 JSValueRef JSApplicationInformation::createJSObject(JSContextRef context,
                const std::string &name,
-               const std::string &package,
+               const std::string &appId,
                const std::string &iconPath,
                const std::string &version)
 {
        ApplicationInformationPtr privateData = ApplicationInformationPtr(new ApplicationInformation());
 
        privateData->setName(name);
-       privateData->setPackage(package);
+       privateData->setAppId(appId);
        privateData->setIconPath(iconPath);
        privateData->setVersion(version);       
        JSApplicationInformationPriv *priv = new JSApplicationInformationPriv(context, privateData);
@@ -183,7 +183,7 @@ bool JSApplicationInformation::setName(JSContextRef context,
        return false;
 }
 
-JSValueRef JSApplicationInformation::getPackage(JSContextRef context,
+JSValueRef JSApplicationInformation::getAppId(JSContextRef context,
                JSObjectRef object,
                JSStringRef propertyName,
                JSValueRef* exception)
@@ -192,7 +192,7 @@ JSValueRef JSApplicationInformation::getPackage(JSContextRef context,
        {
                CommonsJavaScript::Converter converter(context);
                ApplicationInformationPtr privateData = getPrivData(object);
-               return converter.toJSValueRef(privateData->getPackage());
+               return converter.toJSValueRef(privateData->getAppId());
        }
        Catch(WrtDeviceApis::Commons::Exception)
        {
@@ -201,17 +201,17 @@ JSValueRef JSApplicationInformation::getPackage(JSContextRef context,
        return JSValueMakeUndefined(context);
 }
 
-bool JSApplicationInformation::setPackage(JSContextRef context,
+bool JSApplicationInformation::setAppId(JSContextRef context,
                JSObjectRef object,
                JSStringRef propertyName,
-               JSValueRef package,
+               JSValueRef appId,
                JSValueRef* exception)
 {
        Try
        {
                ApplicationInformationPtr privateData = getPrivData(object);
                CommonsJavaScript::Converter converter(context);
-               privateData->setPackage(converter.toString(package));
+               privateData->setAppId(converter.toString(appId));
                return true;
        }
        Catch(WrtDeviceApis::Commons::Exception)
index 92167b9..f03276c 100755 (executable)
@@ -88,15 +88,15 @@ private:
                        JSValueRef name,
                        JSValueRef* exception);
 
-       static JSValueRef getPackage(JSContextRef context,
+       static JSValueRef getAppId(JSContextRef context,
                        JSObjectRef object,
                        JSStringRef propertyName,
                        JSValueRef* exception);
 
-       static bool setPackage(JSContextRef context,
+       static bool setAppId(JSContextRef context,
                        JSObjectRef object,
                        JSStringRef propertyName,
-                       JSValueRef package,
+                       JSValueRef appId,
                        JSValueRef* exception);
 
 static JSValueRef getIconPath(JSContextRef context,
diff --git a/src/standards/Tizen/Application/JSApplicationService.cpp b/src/standards/Tizen/Application/JSApplicationService.cpp
new file mode 100755 (executable)
index 0000000..5d0c04e
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Commons/Exception.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+
+#include "ApplicationConverter.h"
+#include "JSApplicationService.h"
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+using namespace Api::Application;
+
+namespace {
+const char* APPLICATION_SERVICE_OPERATION = "operation";
+const char* APPLICATION_SERVICE_URI = "uri";
+const char* APPLICATION_SERVICE_MIME = "mime";
+const char* APPLICATION_SERVICE_PACKAGE = "package";
+const char* APPLICATION_SERVICE_DATA = "data";
+
+} //private namespace
+
+JSClassRef JSApplicationService::m_jsClassRef = NULL;
+
+JSClassDefinition JSApplicationService::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    "ApplicationService",
+    0,
+    m_property,
+    0,
+    initialize,
+    finalize,
+    NULL,     //HasProperty,
+    getProperty,
+    NULL,     //SetProperty,
+    NULL,     //DeleteProperty,
+    NULL,     //GetPropertyNames,
+    NULL,     //CallAsFunction,
+    constructor,     //CallAsConstructor,
+    hasInstance,
+    NULL,     //ConvertToType
+};
+
+JSStaticValue JSApplicationService::m_property[] = {
+    { APPLICATION_SERVICE_OPERATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_SERVICE_URI, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_SERVICE_MIME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_SERVICE_PACKAGE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { APPLICATION_SERVICE_DATA, getProperty, NULL, kJSPropertyAttributeReadOnly },
+    { 0, 0, 0, 0 }
+};
+
+const JSClassDefinition* JSApplicationService::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+const JSClassRef JSApplicationService::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+//JSClassRef JSApplicationService::m_jsClassRef = JSClassCreate(
+//        JSApplicationService::getClassInfo());
+
+JSObjectRef JSApplicationService::createJSObject(JSContextRef context,
+        const ApplicationServicePtr &appsvc)
+{
+    JSApplicationServicePriv *priv = new JSApplicationServicePriv(context, appsvc);
+
+    if (!priv) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
+    }
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+
+ApplicationServicePtr JSApplicationService::getApplicationService(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSApplicationServicePriv *priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+ApplicationServicePtr JSApplicationService::getPrivateData(JSObjectRef object)
+{
+       JSApplicationServicePriv* priv = static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+
+void JSApplicationService::initialize(JSContextRef context,JSObjectRef object)
+{
+    LogDebug("Entered. Nothing to do.");
+}
+
+void JSApplicationService::finalize(JSObjectRef object)
+{
+    LogDebug("Entered");
+    JSApplicationServicePriv* priv =
+        static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
+    JSObjectSetPrivate(object, NULL);
+    LogDebug("Deleting ApplicationService object");
+    delete priv;
+}
+
+JSObjectRef JSApplicationService::constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+       // TODO: exception handling
+#if 0
+    if ((argumentCount < 1 && argumentCount > 4) ||
+       (JSValueIsNull(context, arguments[0]) ||
+         JSValueIsUndefined(context, arguments[0]) ||
+         JSObjectIsFunction(context, converter->toJSObjectRef(arguments[0]))) ||
+       ((argumentCount >= 2) &&
+         JSValueIsUndefined(context, arguments[1]) ||
+         JSObjectIsFunction(context, converter->toJSObjectRef(arguments[1]))) ||
+       ((argumentCount >= 3) &&
+         JSValueIsUndefined(context, arguments[2]) ||
+         JSObjectIsFunction(context, converter->toJSObjectRef(arguments[2]))) ||
+       ((argumentCount = 4) && !JSValueIsNull(context, arguments[3]) &&
+         JSIsArrayValue(context, arguments[3]))) {
+         LogError("Wrong callbacks parameters");
+                LogError("===[WS] 2");
+               *exception = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(context,TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+     } 
+#endif
+
+       Try {
+               std::string operation = "";
+               std::string uri = "";
+               std::string mime = "";
+               std::vector<ApplicationServiceDataPtr> serviceData;
+
+               if ((argumentCount > 4) && (argumentCount < 1)) {
+                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong ApplicationService argumentCount");
+               }
+               if (!JSValueIsNull(context, arguments[0]) && JSValueIsString(context, arguments[0])) {
+                       operation = converter->toString(arguments[0]);
+               }
+               if ((argumentCount >= 2) && !JSValueIsUndefined(context, arguments[1])) {
+                       if (!JSValueIsNull(context, arguments[1]) && JSValueIsString(context, arguments[1])) {
+                               uri = converter->toString(arguments[1]);
+                       }                       
+               }               
+               if ((argumentCount >= 3) && !JSValueIsUndefined(context, arguments[2])) {
+                       if (!JSValueIsNull(context, arguments[2]) && JSValueIsString(context, arguments[2])) {
+                               mime = converter->toString(arguments[2]);
+                       }
+               }       
+               if ((argumentCount == 4) && !JSValueIsUndefined(context, arguments[3]) && !JSValueIsNull(context, arguments[3])) {
+                       serviceData = converter->toApplicationServiceDataArray(arguments[3]);
+               }
+
+               ApplicationServicePtr appsvc = ApplicationServicePtr(new ApplicationService(operation, uri, mime, serviceData));
+               if (!appsvc) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               return createJSObject(context, appsvc);
+       } Catch (WrtDeviceApis::Commons::InvalidArgumentException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(context,TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       }
+}
+       
+
+bool JSApplicationService::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+JSValueRef JSApplicationService::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("Enter");
+    JSApplicationServicePriv *priv =
+        static_cast<JSApplicationServicePriv*>(JSObjectGetPrivate(object));
+    assert(priv && "Private object not set.");
+
+    Try     {
+        ApplicationServicePtr appsvc = priv->getObject();
+               ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+        if (JSStringIsEqualToUTF8CString(propertyName, APPLICATION_SERVICE_OPERATION)) {
+            LogDebug(
+                "JSApplicationService::getProperty::operation " <<
+                appsvc->getOperation());
+            return converter->toJSValueRef(appsvc->getOperation());
+        }else if (JSStringIsEqualToUTF8CString(propertyName,
+                                                APPLICATION_SERVICE_URI)) {
+            LogDebug(
+                "JSApplicationService::getProperty ::uri " <<
+                appsvc->getUri());
+            return converter->toJSValueRef(appsvc->getUri());
+        }else if (JSStringIsEqualToUTF8CString(propertyName,
+                                                APPLICATION_SERVICE_MIME)) {
+            LogDebug(
+                "JSApplicationService::getProperty ::mime " <<
+                appsvc->getMime());
+            return converter->toJSValueRef(appsvc->getMime());
+               }else if (JSStringIsEqualToUTF8CString(propertyName,
+                                                                                               APPLICATION_SERVICE_DATA)) {
+                       LogDebug(
+                               "JSApplicationService::getProperty ::extraData ");
+                       return converter->toJSValueRef(appsvc->getServiceDataArray());
+               }
+
+    }
+    Catch(WrtDeviceApis::Commons::Exception) {
+        LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSDOMExceptionFactory::UnknownException.make(context, exception);
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationService::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+} //
+} //TizenApis
+}
diff --git a/src/standards/Tizen/Application/JSApplicationService.h b/src/standards/Tizen/Application/JSApplicationService.h
new file mode 100755 (executable)
index 0000000..83336f8
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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_APPLICATION_SERVICE_H_
+#define TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Application/ApplicationService.h>
+#include "JSApplicationServiceData.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Application::ApplicationServicePtr>::Type JSApplicationServicePriv;
+
+class JSApplicationService {
+public:
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       /**
+         * create an JSObject for callback function(onAnswerReceived).
+         */
+       static JSObjectRef createJSObject(JSContextRef context,
+                          const Api::Application::ApplicationServicePtr &appsvc);
+
+       /**
+        * The Constructor of ApplicationService
+        */
+       static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static Api::Application::ApplicationServicePtr getApplicationService(JSContextRef context, JSValueRef value);
+       /**
+         * return private data
+         */
+       static Api::Application::ApplicationServicePtr getPrivateData(JSObjectRef object);
+
+       /**
+        * Send Success Result
+        */
+       static JSValueRef replyResult(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+        * Send Failure Result
+        */
+       static JSValueRef replyFailure(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+                       const JSValueRef arguments[], 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);
+
+  /**
+     * 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;
+
+};
+
+} //
+} //TizenApis
+}
+#endif
diff --git a/src/standards/Tizen/Application/JSApplicationServiceData.cpp b/src/standards/Tizen/Application/JSApplicationServiceData.cpp
new file mode 100755 (executable)
index 0000000..89fc7ca
--- /dev/null
@@ -0,0 +1,235 @@
+/*
+ * 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/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSApplicationServiceData.h"
+#include "ApplicationConverter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+
+using namespace Api::Application;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+//namespace {
+//     const char* APPLICATION_SERVICE_DATA_KEY = "key";
+//     const char* APPLICATION_SERVICE_DATA_VALUE = "value";
+//}
+
+JSClassRef JSApplicationServiceData::m_classRef = NULL;
+
+JSClassDefinition JSApplicationServiceData::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "ApplicationServiceData",
+       NULL,
+       m_property,
+       m_functions,
+       initialize,
+       finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL,
+       constructor,
+       NULL,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSApplicationServiceData::m_property[] = {
+       { "key", getDataKey, setDataKey, kJSPropertyAttributeNone },
+       { "value", getDataValue, setDataValue, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSApplicationServiceData::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSApplicationServiceData::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+JSValueRef JSApplicationServiceData::createJSObject(JSContextRef context,
+               const std::string &key,
+               const std::vector<std::string> &value)
+{
+       ApplicationServiceDataPtr privateData = ApplicationServiceDataPtr(new ApplicationServiceData());
+
+       privateData->setKey(key);
+       privateData->setValue(value);
+       JSApplicationServiceDataPriv *priv = new JSApplicationServiceDataPriv(context, privateData);
+       JSObjectRef jsValueRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsValueRef) {
+               LogError("object creation error");
+               return JSValueMakeUndefined(context);
+       }
+       return jsValueRef;
+}
+
+JSObjectRef JSApplicationServiceData::constructor(JSContextRef context, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       ApplicationConverterFactory::ConverterType converter = ApplicationConverterFactory::getConverter(context);
+
+       if ((argumentCount == 2) && JSValueIsString(context, arguments[0]) && JSIsArrayValue(context, arguments[1])) {
+               return JSValueToObject(context, createJSObject(context, converter->toString(arguments[0]), converter->toVectorOfStrings(arguments[1])), exception);
+       } else {
+               // throw exception
+               return NULL;
+       }
+}
+
+void JSApplicationServiceData::initialize(JSContextRef context, JSObjectRef object)
+{
+       //assert(NULL != JSObjectGetPrivate(object));
+}
+
+void JSApplicationServiceData::finalize(JSObjectRef object)
+{
+       // TODO : check
+       //delete (JSObjectGetPrivate(object));
+}
+
+bool JSApplicationServiceData::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+ApplicationServiceDataPtr JSApplicationServiceData::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSApplicationServiceDataPriv *priv = static_cast<JSApplicationServiceDataPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(Commons::NullPointerException, "Private object is null");
+       }
+       ApplicationServiceDataPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+ApplicationServiceDataPtr JSApplicationServiceData::getApplicationServiceData(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(Commons::InvalidArgumentException);
+       }
+       JSApplicationServiceDataPriv *priv = static_cast<JSApplicationServiceDataPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+JSValueRef JSApplicationServiceData::getDataKey(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               CommonsJavaScript::Converter converter(context);
+               ApplicationServiceDataPtr privateData = getPrivData(object);
+               return converter.toJSValueRef(privateData->getKey());
+       }
+       Catch(Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationServiceData::setDataKey(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef key,
+               JSValueRef* exception)
+{
+       Try
+       {
+               ApplicationServiceDataPtr privateData = getPrivData(object);
+               CommonsJavaScript::Converter converter(context);
+               privateData->setKey(converter.toString(key));
+               return true;
+       }
+       Catch(Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+       JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+       return false;
+}
+
+JSValueRef JSApplicationServiceData::getDataValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       Try
+       {
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               ApplicationServiceDataPtr privateData = getPrivData(object);
+
+               return converter.toJSValueRef(privateData->getValue());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSApplicationServiceData::setDataValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               ApplicationServiceDataPtr privateData = getPrivData(object);
+               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+               privateData->setValue(converter.toVectorOfStrings(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+       JSDOMExceptionFactory::TypeMismatchException.make(context, exception);
+       return false;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Application/JSApplicationServiceData.h b/src/standards/Tizen/Application/JSApplicationServiceData.h
new file mode 100755 (executable)
index 0000000..d9f9a52
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * 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_APPLICATION_SERVICE_DATA_H_
+#define TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_DATA_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Application/ApplicationServiceData.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Application {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationServiceDataPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationServiceDataPriv;
+
+class JSApplicationServiceData {
+public:
+       /*
+       * This initializes this JS class in the JS Engine.
+       */
+       static JSClassRef getClassRef();
+
+       static JSValueRef createJSObject(JSContextRef context,
+                       const std::string &key,
+                       const std::vector<std::string> &value);
+
+       static JSObjectRef constructor(JSContextRef ctx, 
+                       JSObjectRef constructor, 
+                       size_t argumentCount, 
+                       const JSValueRef arguments[], 
+                       JSValueRef* exception);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static Api::Application::ApplicationServiceDataPtr 
+               getApplicationServiceData(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 Api::Application::ApplicationServiceDataPtr getPrivData(JSObjectRef object);
+
+       static JSValueRef getDataKey(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setDataKey(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef key,
+                       JSValueRef* exception);
+
+       static JSValueRef getDataValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setDataValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+};
+
+}
+} 
+}
+#endif
+
index 518fd51..7197f6f 100755 (executable)
@@ -22,11 +22,9 @@ namespace Tizen1_0 {
 namespace Application {        
 LaunchServicePrivateData::LaunchServicePrivateData(
         const JSCallbackManagerPtr& callbackManager,
-        const JSCallbackManagerPtr& replyCallbackManager,
-        const JSCallbackManagerPtr& replyCancelCallbackManager):
+        const JSCallbackManagerPtr& replyCallbackManager):
     m_callbackManager(callbackManager),
-    m_replyCallbackManager(replyCallbackManager),
-    m_replyCancelCallbackManager(replyCancelCallbackManager)
+    m_replyCallbackManager(replyCallbackManager)
 {
 }
 
@@ -40,13 +38,13 @@ const
 {
     return m_replyCallbackManager;
 }
-
+#if 0
 JSCallbackManagerPtr LaunchServicePrivateData::getReplyCancelCallbackManager()
 const
 {
     return m_replyCancelCallbackManager;
 }
-
+#endif
 }
 }
 }
index a633bf7..645fbc3 100755 (executable)
@@ -32,16 +32,16 @@ class LaunchServicePrivateData : public WrtDeviceApis::Commons::IEventPrivateDat
 {
   public:
     LaunchServicePrivateData(const JSCallbackManagerPtr& callbackManager,
-            const JSCallbackManagerPtr& replayCallbackManager, const JSCallbackManagerPtr& replayCancelCallbackManager);
+            const JSCallbackManagerPtr& replayCallbackManager);
 
     JSCallbackManagerPtr getCallbackManager() const;
     JSCallbackManagerPtr getReplyCallbackManager() const;
-    JSCallbackManagerPtr getReplyCancelCallbackManager() const;        
+//    JSCallbackManagerPtr getReplyCancelCallbackManager() const;      
 
   private:
     JSCallbackManagerPtr m_callbackManager;
     JSCallbackManagerPtr m_replyCallbackManager;
-       JSCallbackManagerPtr m_replyCancelCallbackManager;
+//     JSCallbackManagerPtr m_replyCancelCallbackManager;
 };
 
 typedef DPL::SharedPtr<LaunchServicePrivateData> LaunchServicePrivateDataPtr;
index 2b1dbb9..b811e3f 100755 (executable)
@@ -89,27 +89,60 @@ static FunctionMapping createApplicationFunctions()
      */
     FunctionMapping applicationMapping;
 
-    // listInstalledApplications
-    AceFunction listInstalledApplicationsFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_LIST_INSTALLED_APPLICATIONS,
-            APPLICATION_FUNCTION_API_LIST_INSTALLED_APPLICATIONS,
+    // launch
+    AceFunction launchFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_LAUNCH,
+            APPLICATION_FUNCTION_API_LAUNCH,
             APPLICATION_FEATURES_APPLICATION_MANAGER,
             DEVICE_LIST_APPLICATION_MANAGER);
 
     applicationMapping.insert(std::make_pair(
-                               APPLICATION_FUNCTION_API_LIST_INSTALLED_APPLICATIONS,
-                               listInstalledApplicationsFunc));
+                               APPLICATION_FUNCTION_API_LAUNCH,
+                               launchFunc));
 
-    // listRunningApplications
-    AceFunction listRunningApplicationsFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_LIST_RUNNING_APPLICATIONS,
-            APPLICATION_FUNCTION_API_LIST_RUNNING_APPLICATIONS,
+       // kill
+    AceFunction killFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_KILL,
+            APPLICATION_FUNCTION_API_KILL,
             APPLICATION_FEATURES_APPLICATION_MANAGER,
             DEVICE_LIST_APPLICATION_MANAGER);
 
     applicationMapping.insert(std::make_pair(
-                               APPLICATION_FUNCTION_API_LIST_RUNNING_APPLICATIONS,
-                               listRunningApplicationsFunc));
+                               APPLICATION_FUNCTION_API_KILL,
+                               killFunc));
+
+       // exit
+    AceFunction exitFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_EXIT,
+            APPLICATION_FUNCTION_API_EXIT,
+            APPLICATION_FEATURES_APPLICATION_MANAGER,
+            DEVICE_LIST_APPLICATION_MANAGER);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_EXIT,
+                               exitFunc));
+
+    // hide
+    AceFunction hideFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_HIDE,
+            APPLICATION_FUNCTION_API_HIDE,
+            APPLICATION_FEATURES_APPLICATION_MANAGER,
+            DEVICE_LIST_APPLICATION_MANAGER);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_HIDE,
+                               hideFunc));
+
+    // getApplicationInformations
+    AceFunction getApplicationInformationsFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_APPLICATION_INFORMATIONS,
+            APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATIONS,
+            APPLICATION_FEATURES_APPLICATION_MANAGER,
+            DEVICE_LIST_APPLICATION_MANAGER);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATIONS,
+                               getApplicationInformationsFunc));
 
     // getApplicationInformation
     AceFunction getApplicationInformationFunc = ACE_CREATE_FUNCTION(
@@ -122,27 +155,50 @@ static FunctionMapping createApplicationFunctions()
                                APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATION,
                                getApplicationInformationFunc));
 
-    // addApplicationListChangeListener
-    AceFunction addApplicationListChangeListenerFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_ADD_APPLICATION_LIST_CHANGE_LISTENER,
-            APPLICATION_FUNCTION_API_ADD_APPLICATION_LIST_CHANGE_LISTENER,
+    // getRunningApplicationContexts
+    AceFunction getRunningApplicationContextsFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_RUNNING_APPLICATION_CONTEXTS,
+            APPLICATION_FUNCTION_API_GET_RUNNING_APPLICATION_CONTEXTS,
             APPLICATION_FEATURES_APPLICATION_MANAGER,
             DEVICE_LIST_APPLICATION_MANAGER);
 
     applicationMapping.insert(std::make_pair(
-                               APPLICATION_FUNCTION_API_ADD_APPLICATION_LIST_CHANGE_LISTENER,
-                               addApplicationListChangeListenerFunc));
+                               APPLICATION_FUNCTION_API_GET_RUNNING_APPLICATION_CONTEXTS,
+                               getRunningApplicationContextsFunc));
 
-    // unsetApplicaitonListChangeListener
-    AceFunction unsetApplicaitonListChangeListenerFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_REMOVE_APPLICATOIN_LIST_CHANGE_LISTENER,
-            APPLICATION_FUNCTION_API_REMOVE_APPLICATION_LIST_CHANGE_LISTENER,
+    // getCurrentApplicationContext
+    AceFunction getCurrentApplicationContextFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_CURRENT_APPLICATION_CONTEXT,
+            APPLICATION_FUNCTION_API_GET_CURRENT_APPLICATION_CONTEXT,
             APPLICATION_FEATURES_APPLICATION_MANAGER,
             DEVICE_LIST_APPLICATION_MANAGER);
 
     applicationMapping.insert(std::make_pair(
-                               APPLICATION_FUNCTION_API_REMOVE_APPLICATION_LIST_CHANGE_LISTENER,
-                               unsetApplicaitonListChangeListenerFunc));
+                               APPLICATION_FUNCTION_API_GET_CURRENT_APPLICATION_CONTEXT,
+                               getCurrentApplicationContextFunc));
+
+
+    // addApplicationInformationEventListener
+    AceFunction addApplicationInformationEventListenerFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_ADD_APPLICATION_INFORMATION_EVENT_LISTENER,
+            APPLICATION_FUNCTION_API_ADD_APPLICATION_INFORMATION_EVENT_LISTENER,
+            APPLICATION_FEATURES_APPLICATION_MANAGER,
+            DEVICE_LIST_APPLICATION_MANAGER);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_ADD_APPLICATION_INFORMATION_EVENT_LISTENER,
+                               addApplicationInformationEventListenerFunc));
+
+    // removeApplicationInformationEventListener
+    AceFunction removeApplicationInformationEventListenerFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER,
+            APPLICATION_FUNCTION_API_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER,
+            APPLICATION_FEATURES_APPLICATION_MANAGER,
+            DEVICE_LIST_APPLICATION_MANAGER);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER,
+                               removeApplicationInformationEventListenerFunc));
 
     // launchService
     AceFunction launchServiceFunc = ACE_CREATE_FUNCTION(
@@ -155,6 +211,16 @@ static FunctionMapping createApplicationFunctions()
                                APPLICATION_FUNCTION_API_LAUNCH_SERVICE,
                                launchServiceFunc));
 
+    // getApplicationService
+    AceFunction getApplicationServiceFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_APPLICATION_SERVICE,
+            APPLICATION_FUNCTION_API_GET_APPLICATION_SERVICE,
+            APPLICATION_FEATURES_APPLICATION_SERVICE,
+            DEVICE_LIST_APPLICATION_SERVICE);
+
+    applicationMapping.insert(std::make_pair(
+                               APPLICATION_FUNCTION_API_GET_APPLICATION_SERVICE,
+                               getApplicationServiceFunc));
 
     return applicationMapping;
 }
index 40a09d8..ebf6174 100755 (executable)
 #include <string>\r
 #include <Commons/FunctionDeclaration.h>\r
 \r
-#define APPLICATION_FUNCTION_API_LIST_INSTALLED_APPLICATIONS  "listInstalledApplications"\r
-#define APPLICATION_FUNCTION_API_LIST_RUNNING_APPLICATIONS  "listRunningApplications"\r
-#define APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATION  "getApplicationInformation"\r
-#define APPLICATION_FUNCTION_API_ADD_APPLICATION_LIST_CHANGE_LISTENER "addApplicationListChangeListener"\r
-#define APPLICATION_FUNCTION_API_REMOVE_APPLICATION_LIST_CHANGE_LISTENER  "removeApplicationListChangeListener"\r
-#define APPLICATION_FUNCTION_API_LAUNCH_SERVICE  "launchService"\r
+#define APPLICATION_FUNCTION_API_LAUNCH        "launch"\r
+#define APPLICATION_FUNCTION_API_KILL          "kill"\r
+#define APPLICATION_FUNCTION_API_EXIT          "exit"\r
+#define APPLICATION_FUNCTION_API_HIDE          "hide"\r
+\r
+#define APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATIONS  "getApplicationInformations"\r
+#define APPLICATION_FUNCTION_API_GET_APPLICATION_INFORMATION   "getApplicationInformation"\r
+\r
+#define APPLICATION_FUNCTION_API_GET_RUNNING_APPLICATION_CONTEXTS      "getRunningApplicationContexts"\r
+#define APPLICATION_FUNCTION_API_GET_CURRENT_APPLICATION_CONTEXT       "getCurrentApplicationContext"\r
+\r
+#define APPLICATION_FUNCTION_API_ADD_APPLICATION_INFORMATION_EVENT_LISTENER                    "addApplicationInformationEventListener"\r
+#define APPLICATION_FUNCTION_API_REMOVE_APPLICATION_INFORMATION_EVENT_LISTENER         "removeApplicationInformationEventListener"\r
+\r
+#define APPLICATION_FUNCTION_API_LAUNCH_SERVICE                                "launchService"\r
+#define APPLICATION_FUNCTION_API_GET_APPLICATION_SERVICE       "getApplicationService"\r
 \r
 namespace TizenApis {\r
 namespace Tizen1_0 {\r
index 2d5fd1b..acc3089 100755 (executable)
@@ -19,6 +19,7 @@
 #include <Commons/plugin_initializer_def.h>
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include "JSApplication.h"
+#include "JSApplicationService.h"
 
 void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
        LogDebug("[Tizen1_0\\Application] on_widget_start_callback ("<<widgetId<<")");
@@ -37,4 +38,17 @@ PLUGIN_CLASS_MAP_BEGIN
                "application",
                TizenApis::Tizen1_0::Application::JSApplication::getClassRef(),
                NULL) 
+
+       PLUGIN_CLASS_MAP_ADD_CLASS(
+               "tizen.application",
+               "ApplicationService",
+               TizenApis::Tizen1_0::Application::JSApplicationService::getClassRef(),
+               NULL) 
+
+       PLUGIN_CLASS_MAP_ADD_CLASS(
+               "tizen.application",
+               "ApplicationServiceData",
+               TizenApis::Tizen1_0::Application::JSApplicationServiceData::getClassRef(),
+               NULL) 
+
 PLUGIN_CLASS_MAP_END
index 5df0b6c..04835e3 100644 (file)
@@ -77,7 +77,7 @@ JSStaticValue JSBluetoothServiceHandler::m_properties[] =
 
 JSStaticFunction JSBluetoothServiceHandler::m_function[] =
 {
-       {"unRegister", JSBluetoothServiceHandler::unregisterRFCOMMService, kJSPropertyAttributeNone},
+       {"unregister", JSBluetoothServiceHandler::unregisterRFCOMMService, kJSPropertyAttributeNone},
        { 0, 0, 0 }
 };
 
index 8a039a4..24a1ee2 100755 (executable)
@@ -5,6 +5,7 @@ pkg_search_module(wrt-plugins-widgetdb REQUIRED wrt-plugins-widgetdb)
 set(LIBS_WIDGETDB ${wrt-plugins-widgetdb_LIBRARIES})
 
 add_subdir(Tizen)
+add_subdir(Mediacontent)
 add_subdir(Calendar)
 add_subdir(Contact)
 add_subdir(Geocoder)
@@ -16,9 +17,9 @@ add_subdir(TimeUtil)
 add_subdir(Systeminfo)
 add_subdir(NFC)
 add_subdir(Sensors)
-#add_subdir(Log)
+add_subdir(Log)
 add_subdir(Filesystem)
-add_subdir(Account)
+#add_subdir(Account)
 
 #add_subdir(DeviceInteraction)
 #add_subdir(Accelerometer)
index 41f9158..bc40509 100755 (executable)
@@ -10,19 +10,25 @@ set(SRCS
   JSCalendarEvent.cpp
   JSCalendarTask.cpp
   JSCalendarItemProperties.cpp
-  JSEventId.cpp
+  JSCalendarEventId.cpp
   JSCalendar.cpp
   JSCalendarManager.cpp
-  JSAttendee.cpp
-  JSRecurrenceRule.cpp
-  JSEventAlarm.cpp
+  JSCalendarAttendee.cpp
+  JSCalendarRecurrenceRule.cpp
+  JSCalendarAlarm.cpp
   JSCalendarItemGeo.cpp
   plugin_initializer.cpp
   plugin_config.cpp
   ../Tizen/FilterConverter.cpp
+  ../Tizen/JSAttributeFilter.cpp
+  ../Tizen/JSAttributeRangeFilter.cpp
+  ../Tizen/JSCompositeFilter.cpp
+  ../Tizen/JSAbstractFilterArray.cpp
+  ../Tizen/JSSortMode.cpp
   ../Common/JSTizenException.cpp
   ../Common/TizenExceptionData.cpp
   ../Common/JSTizenExceptionFactory.cpp
+  ../Common/JSGlobalContextFactory.cpp
   ${SRCS_PLATFORM_API_TIMEUTIL}
   ${SRCS_PLATFORM_IMPLEMENTATION_TIMEUTIL}
   ../TimeUtil/JSTimeUtil.cpp
index 36dd0df..7d76c41 100755 (executable)
 #include <CommonsJavaScript/JSUtils.h>
 #include "JSCalendarItem.h"
 #include "JSCalendarItemProperties.h"
-#include "JSEventId.h"
+#include "JSCalendarEventId.h"
 #include "JSCalendarItemGeo.h"
 #include "CalendarConverter.h"
 #include "JSCalendar.h"
 #include "JSCalendarManager.h"
-#include "JSAttendee.h"
-#include "JSRecurrenceRule.h"
-#include "JSEventAlarm.h"
+#include "JSCalendarAttendee.h"
+#include "JSCalendarRecurrenceRule.h"
+#include "JSCalendarAlarm.h"
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include "API/TimeUtil/DurationProperties.h"
 
@@ -79,11 +79,6 @@ JSValueRef CalendarConverter::toJSValueRef(const CalendarEventListPtr &arg)
     return toJSValueRef_(*arg, &CalendarConverter::toJSValueRefItem, this);
 }
 
-JSValueRef CalendarConverter::toJSValueRefItemProperties(const CalendarEventPtr& arg)
-{
-    return JSUtils::makeObject(m_context, JSCalendarItemProperties::getClassRef(), arg);
-}
-
 JSValueRef CalendarConverter::toJSValueRefCalendar(const ICalendarPtr& arg)
 {
     CalendarPrivObject *priv = new CalendarPrivObject(m_context, arg);
@@ -95,20 +90,10 @@ JSValueRef CalendarConverter::toJSValueRef(const std::vector<ICalendarPtr> &arg)
     return toJSValueRef_(arg, &CalendarConverter::toJSValueRefCalendar, this);
 }
 
-JSValueRef CalendarConverter::toJSValueRef(const EventIdPtr& arg)
-{
-    return JSUtils::makeObject(m_context, JSEventId::getClassRef(), arg);
-}
-
-JSValueRef CalendarConverter::toJSValueRef(const CalendarItemGeoPtr& arg)
-{
-    return JSUtils::makeObject(m_context, JSCalendarItemGeo::getClassRef(), arg);
-}
-
 CalendarEvent::EventAlarmType CalendarConverter::toEventAlarmType(std::string alarmMethod)
 const
 {
-    if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SILENT_ALARM))
+    if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM))
         return CalendarEvent::SILENT_ALARM;
     else if (!alarmMethod.compare(TIZEN_CALENDAR_PROPERTY_SOUND_ALARM))
         return CalendarEvent::SOUND_ALARM;
@@ -122,7 +107,7 @@ std::string CalendarConverter::toTizenValue(CalendarEvent::EventAlarmType abstra
 {
     switch (abstractValue) {
     case CalendarEvent::SILENT_ALARM:
-        return TIZEN_CALENDAR_PROPERTY_SILENT_ALARM;
+        return TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM;
     case CalendarEvent::SOUND_ALARM:
         return TIZEN_CALENDAR_PROPERTY_SOUND_ALARM;
     default:
@@ -253,7 +238,7 @@ EventRecurrenceRulePtr CalendarConverter::toEventRecurrenceRule(JSValueRef rrule
         if (!JSValueIsNull(m_context, untilDateData)) {
             result->setEndDate(toDateTimeT(untilDateData));
         } else {
-            result->resetEndDate();
+            result->setEndDate(0);
         }
     }
     if (!JSValueIsUndefined(m_context, occurrenceCountData)) {
@@ -675,7 +660,7 @@ EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee)
     const ScopedJSStringRef groupStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_GROUP));
     const ScopedJSStringRef delegatorURIStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_DELEGATORURI));
     const ScopedJSStringRef delegateURIStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_DELEGATEURI));
-    const ScopedJSStringRef uidStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_UID));
+    const ScopedJSStringRef contactRefStr(JSStringCreateWithUTF8CString(TIZEN_ATTENDEE_CONTACT_REF));
 
     JSObjectRef arg = toJSObjectRef(attendee);
 
@@ -688,7 +673,7 @@ EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee)
     JSValueRef groupData = JSObjectGetProperty(m_context, arg, groupStr.get(), NULL);
     JSValueRef delegatorURIData = JSObjectGetProperty(m_context, arg, delegatorURIStr.get(), NULL);
     JSValueRef delegateURIData = JSObjectGetProperty(m_context, arg, delegateURIStr.get(), NULL);
-    JSValueRef uidData = JSObjectGetProperty(m_context, arg, uidStr.get(), NULL);
+    JSValueRef contactRefData = JSObjectGetProperty(m_context, arg, contactRefStr.get(), NULL);
 
     if (!JSValueIsUndefined(m_context, nameData)) {
         result->setName(toString(nameData));
@@ -717,14 +702,14 @@ EventAttendeePtr CalendarConverter::toAttendee(JSValueRef attendee)
     if (!JSValueIsUndefined(m_context, delegateURIData)) {
         result->setDelegateURI(toString(delegateURIData));
     }
-    if (!JSValueIsUndefined(m_context, uidData)) {
-        result->setPersonId(toString(uidData));
+    if (!JSValueIsUndefined(m_context, contactRefData)) {
+        result->setPersonId(toString(contactRefData));
     }
 
     return result;
 }
 
-EventAttendeeListPtr CalendarConverter::toVectorOfAttendees(JSValueRef attendees)
+EventAttendeeListPtr CalendarConverter::toVectorOfAttendeesFromDictionary(JSValueRef attendees)
 {
     LogDebug("entered");
     EventAttendeeListPtr result(new EventAttendeeList());
@@ -741,19 +726,38 @@ EventAttendeeListPtr CalendarConverter::toVectorOfAttendees(JSValueRef attendees
     return result;
 }
 
+EventAttendeeListPtr CalendarConverter::toVectorOfAttendeesFromReference(JSValueRef attendees)
+{
+    LogDebug("entered");
+    EventAttendeeListPtr result(new EventAttendeeList());
+
+    std::vector<EventAttendeePtr> resultVector;
+    JSObjectRef objArg = toJSObjectRef(attendees);
+    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(JSCalendarAttendee::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+    }
+
+    *result = resultVector;
+    return result;
+}
+
 EventAlarmPtr CalendarConverter::toEventAlarm(JSValueRef alarm)
 {
     LogDebug("entered");
     EventAlarmPtr result(new EventAlarm());
     const ScopedJSStringRef absoluteDateStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE));
     const ScopedJSStringRef beforeStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ALARM_BEFORE));
-    const ScopedJSStringRef methodsStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ALARM_METHODS));
+    const ScopedJSStringRef methodStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ALARM_METHOD));
+    const ScopedJSStringRef descriptionStr(JSStringCreateWithUTF8CString(TIZEN_CALENDAR_ALARM_DESCRIPTION));
 
     JSObjectRef arg = toJSObjectRef(alarm);
 
     JSValueRef absoluteDateData = JSObjectGetProperty(m_context, arg, absoluteDateStr.get(), NULL);
     JSValueRef beforeData = JSObjectGetProperty(m_context, arg, beforeStr.get(), NULL);
-    JSValueRef methodsData = JSObjectGetProperty(m_context, arg, methodsStr.get(), NULL);
+    JSValueRef methodData = JSObjectGetProperty(m_context, arg, methodStr.get(), NULL);
+    JSValueRef descriptionData = JSObjectGetProperty(m_context, arg, descriptionStr.get(), NULL);
 
     if (!JSValueIsUndefined(m_context, absoluteDateData)) {
         TimeUtilConverter timeConverter(m_context);
@@ -763,19 +767,20 @@ EventAlarmPtr CalendarConverter::toEventAlarm(JSValueRef alarm)
         TimeUtilConverter timeConverter(m_context);
         result->setDuration(timeConverter.getDurationPropertis(beforeData));
     }
-    if (!JSValueIsUndefined(m_context, methodsData)) {
-        std::vector<std::string> methods = toVectorOfStrings(methodsData);
+    if (!JSValueIsUndefined(m_context, methodData)) {
+        std::string method = toString(methodData);
         std::vector<CalendarEvent::EventAlarmType> convertedMethods;
-        for (unsigned int i=0; i<methods.size(); i++) {
-            convertedMethods.push_back(toEventAlarmType(methods[i]));
-        }
+        convertedMethods.push_back(toEventAlarmType(method));
         result->setMethods(convertedMethods);
     }
+    if (!JSValueIsUndefined(m_context, descriptionData)) {
+        result->setDescription(toString(descriptionData));
+    }
 
     return result;
 }
 
-EventAlarmListPtr CalendarConverter::toVectorOfEventAlarms(JSValueRef alarms)
+EventAlarmListPtr CalendarConverter::toVectorOfEventAlarmsFromDictionary(JSValueRef alarms)
 {
     LogDebug("entered");
     EventAlarmListPtr result(new EventAlarmList());
@@ -792,6 +797,23 @@ EventAlarmListPtr CalendarConverter::toVectorOfEventAlarms(JSValueRef alarms)
     return result;
 }
 
+EventAlarmListPtr CalendarConverter::toVectorOfEventAlarmsFromReference(JSValueRef alarms)
+{
+    LogDebug("entered");
+    EventAlarmListPtr result(new EventAlarmList());
+
+    std::vector<EventAlarmPtr> resultVector;
+    JSObjectRef objArg = toJSObjectRef(alarms);
+    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(JSCalendarAlarm::getPrivateObject(JSValueToObject(m_context, element, NULL)));
+    }
+
+    *result = resultVector;
+    return result;
+}
+
 CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
 {
     LogDebug("entered");
@@ -890,12 +912,16 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setStatus(CalendarEvent::CONFIRMED_STATUS);
     }
     if (!JSValueIsUndefined(m_context, alarmsData)) {
-        EventAlarmListPtr alarms = toVectorOfEventAlarms(alarmsData);
+        EventAlarmListPtr alarms = toVectorOfEventAlarmsFromReference(alarmsData);
         std::vector<CalendarEvent::EventAlarmType> alarmsType;
         std::vector<long> alarmsTick;
+        std::vector<std::string> alarmsDescription;
+
         for( unsigned int i=0; i<alarms->size(); i++) {
             EventAlarmPtr theAlarm = alarms->at(i);
             alarmsType.push_back(theAlarm->getMethods().at(0));
+            alarmsDescription.push_back(theAlarm->getDescription());
+
             if( 0 < theAlarm->getAbsoluteDate() ) {
                 alarmsTick.push_back(theAlarm->getAbsoluteDate()/60); // minutes only in platform.
             } else {
@@ -934,7 +960,7 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setOrganizer(toString(organizerData));
     }
     if (!JSValueIsUndefined(m_context, attendeesData)) {
-        EventAttendeeListPtr attendees = toVectorOfAttendees(attendeesData);
+        EventAttendeeListPtr attendees = toVectorOfAttendeesFromReference(attendeesData);
         result->setAttendees(attendees);
     }
     if (!JSValueIsUndefined(m_context, geolocationData)) {
@@ -947,7 +973,7 @@ CalendarEventPtr CalendarConverter::toEvent(const JSValueRef event)
         result->setAvailability(toEventAvailability(toString(availabilityData)));
     }
     if (!JSValueIsUndefined(m_context, recurrenceRuleData)) {
-        result->setRecurrenceRule(toEventRecurrenceRule(recurrenceRuleData));
+        result->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(m_context, recurrenceRuleData, NULL)));
     }
     if (!JSValueIsUndefined(m_context, priorityData)) {
         result->setPriority(toTaskPriority(toString(priorityData)));
@@ -1054,7 +1080,9 @@ EventIdListPtr CalendarConverter::toVectorOfEventIds(JSValueRef eventIds)
     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(toEventId(element));
+        EventIdPtr idPtr = JSCalendarEventId::getPrivateObject(JSValueToObject(m_context, element, NULL));
+        idPtr->setCalendarType(CalendarEvent::EVENT_TYPE);
+        resultVector.push_back(idPtr);
     }
 
     *result = resultVector;
index 611e5b3..4f0ccbe 100755 (executable)
@@ -45,7 +45,8 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     TizenApis::Api::Calendar::CalendarEventListPtr toVectorOfEventsFromProperty(JSValueRef events);
     TizenApis::Api::Calendar::CategoryListPtr toCategories(JSValueRef categories);
     TizenApis::Api::Calendar::EventAttendeePtr toAttendee(JSValueRef attendee);
-    TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendees(JSValueRef attendees);
+    TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendeesFromDictionary(JSValueRef attendees);
+    TizenApis::Api::Calendar::EventAttendeeListPtr toVectorOfAttendeesFromReference(JSValueRef attendees);
 
     TizenApis::Api::Calendar::CalendarEvent::EventAlarmType toEventAlarmType(std::string tizenValue) const;
     TizenApis::Api::Calendar::CalendarEvent::EventStatus toEventStatus(std::string tizenValue) const;
@@ -72,12 +73,10 @@ class CalendarConverter : public WrtDeviceApis::CommonsJavaScript::Converter
     JSValueRef toJSValueRef(const TizenApis::Api::Calendar::CalendarEventListPtr &arg);
     JSValueRef toJSValueRefCalendar(const TizenApis::Api::Calendar::ICalendarPtr& arg);
     JSValueRef toJSValueRef(const std::vector<TizenApis::Api::Calendar::ICalendarPtr> &arg);
-       JSValueRef toJSValueRefItemProperties(const TizenApis::Api::Calendar::CalendarEventPtr& arg);
-       JSValueRef toJSValueRef(const TizenApis::Api::Calendar::EventIdPtr& arg);
-       JSValueRef toJSValueRef(const TizenApis::Api::Calendar::CalendarItemGeoPtr& arg);
 
     TizenApis::Api::Calendar::EventAlarmPtr toEventAlarm(JSValueRef alarm);
-    TizenApis::Api::Calendar::EventAlarmListPtr toVectorOfEventAlarms(JSValueRef alarms);
+    TizenApis::Api::Calendar::EventAlarmListPtr toVectorOfEventAlarmsFromDictionary(JSValueRef alarms);
+    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);
index aff4703..cacc84b 100755 (executable)
@@ -22,7 +22,7 @@
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include "CalendarConverter.h"
 #include "JSCalendarItem.h"
-#include "JSEventId.h"
+#include "JSCalendarEventId.h"
 #include "CalendarMultiCallback.h"
 #include <API/Calendar/EventId.h>
 
@@ -244,15 +244,12 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnDeleteEventsChangedPtr
         DPL::StaticPointerCast<CalendarEventsCallbackPrivateData>(event->getPrivateData());
     JSContextRef context = multiCallbacks->getOnEvent()->getContext();
 
-    CalendarConverterFactory::ConverterType converter =
-        CalendarConverterFactory::getConverter(context);
-
     switch (event->getStatus())
     {
         case OnDeleteEventsChanged::EVENT_DELETE_SUCCESS:
         {
             multiCallbacks->getOnEvent()->callOnSuccess(
-                converter->toJSValueRef(event->getEventId()));
+                JSCalendarEventId::createJSCalendarEventId(context, event->getEventId()));
             break;
         }
         case OnDeleteEventsChanged::EVENT_DELETE_FAIL:
@@ -267,7 +264,7 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnDeleteEventsChangedPtr
                         context, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
             }
 
-            JSValueRef eventObject = converter->toJSValueRef(event->getEventId());
+            JSValueRef eventObject = JSCalendarEventId::createJSCalendarEventId(context, event->getEventId());
             JSValueRef obj[] = {errorObject, eventObject};
             multiCallbacks->getOnEvent()->callOnError(obj, 2);
             break;
@@ -401,7 +398,7 @@ void CalendarResponseDispatcher::onAnswerReceived(const OnEventsChangedPtr& even
                     EventIdPtr eventId( new EventId() );
                     eventId->setUId(eventList->at(i)->getUId());
                     eventId->setRecurrenceId(eventList->at(i)->getRecurrenceId());
-                    JSValueRef tmpVal = converter->toJSValueRef(eventId);
+                    JSValueRef tmpVal =JSCalendarEventId::createJSCalendarEventId(context, eventId);
                     if (!JSSetArrayElement(context, jsResult, i, tmpVal)) {
                         ThrowMsg(ConversionException, "Could not create js array element");
                     }
index 656aefd..a635663 100755 (executable)
 #include <API/Calendar/ICalendar.h>
 #include <API/Calendar/EventId.h>
 #include <API/Calendar/CalendarFactory.h>
-#include <API/Calendar/IEventAddEvent.h>
-#include <API/Calendar/IEventAddEvents.h>
-#include <API/Calendar/IEventDeleteEvent.h>
-#include <API/Calendar/IEventDeleteEvents.h>
-#include <API/Calendar/IEventFindEvents.h>
-#include <API/Calendar/IEventUpdateEvent.h>
-#include <API/Calendar/IEventUpdateEvents.h>
-#include <API/Calendar/IEventCreateEventFromString.h>
-#include <API/Calendar/IEventExportEventToString.h>
-#include <API/Calendar/OnAddEventsChanged.h>
-#include <API/Calendar/OnUpdateEventsChanged.h>
-#include <API/Calendar/OnDeleteEventsChanged.h>
-#include <API/Calendar/OnEventsChanged.h>
 
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
@@ -52,7 +39,7 @@
 #include "JSCalendarEvent.h"
 #include "JSCalendarTask.h"
 #include "JSCalendarItemProperties.h"
-#include "JSEventId.h"
+#include "JSCalendarEventId.h"
 #include "plugin_config.h"
 #include "CalendarResponseDispatcher.h"
 #include "CalendarMultiCallback.h"
@@ -115,18 +102,17 @@ JSStaticValue JSCalendar::m_property[] = {
 };
 
 JSStaticFunction JSCalendar::m_function[] = {
-    { "add", add, kJSPropertyAttributeNone },
-    { "addBatch", addBatch, kJSPropertyAttributeNone },
-    { "update", update, kJSPropertyAttributeNone },
-    { "updateBatch", updateBatch, kJSPropertyAttributeNone },
-    { "remove", remove, kJSPropertyAttributeNone },
-    { "removeBatch", removeBatch, kJSPropertyAttributeNone },
-    { "find", find, kJSPropertyAttributeNone },
-    { "convertFromString", convertFromString, kJSPropertyAttributeNone },
-    { "convertToString", convertToString, kJSPropertyAttributeNone },
-    { "addChangeListener", addChangeListener, kJSPropertyAttributeNone },
-    { "removeChangeListener", removeChangeListener, kJSPropertyAttributeNone },
-    { "expandEventRecurrence", expandEventRecurrence, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_ADD, add, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_ADD_BATCH, addBatch, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_UPDATE, update, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_UPDATE_BATCH, updateBatch, kJSPropertyAttributeNone },
+    { 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 },
 
     { 0, 0, 0 }
 };
@@ -205,7 +191,12 @@ JSValueRef JSCalendar::add(JSContextRef context,
 
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(privateObject->getContext());
-        CalendarEventPtr event = converter->toEvent(arguments[0]);
+
+        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) {
             ThrowMsg(ConversionException, "Parameter conversion failed.");
         }
@@ -216,7 +207,7 @@ JSValueRef JSCalendar::add(JSContextRef context,
         calendar->addEvent(dplEvent);
 
         if (dplEvent->getResult()) {
-            return converter->toJSValueRefItem(dplEvent->getEvent());
+            return NULL;
         } else {
             ThrowMsg(UnknownException, "Adding failed by unkown reason.");
         }
@@ -242,7 +233,7 @@ JSValueRef JSCalendar::add(JSContextRef context,
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
+    return NULL;
 }
 
 JSValueRef JSCalendar::addBatch(JSContextRef context,
@@ -278,7 +269,7 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
         if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
-        events = converter->toVectorOfEventsFromProperty(arguments[0]);
+        events = converter->toVectorOfEvents(arguments[0]);
         if (!events) {
             LogError("Failed to create events.");
             ThrowMsg(ConversionException, "Parameter conversion failed.");
@@ -333,7 +324,7 @@ JSValueRef JSCalendar::addBatch(JSContextRef context,
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
     }
 
-    return JSValueMakeNull(context);
+    return NULL;
 }
 
 JSValueRef JSCalendar::update(JSContextRef context,
@@ -362,8 +353,10 @@ JSValueRef JSCalendar::update(JSContextRef context,
         }
 
         if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) {
-            ThrowMsg(ConversionException, "Wrong parameter type.");
-        } else if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarItem::getClassRef())) {
+            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.");
         }
 
@@ -555,15 +548,24 @@ JSValueRef JSCalendar::remove(JSContextRef context,
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
-        if (!JSValueIsObjectOfClass(context, arguments[0], JSEventId::getClassRef())) {
+        if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarEventId::getClassRef())) {
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         EventIdPtr itemId;
-        CalendarConverterFactory::ConverterType converter = CalendarConverterFactory::getConverter(context);
-        itemId = converter->toEventId(arguments[0]);
-        if (!itemId) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
+        JSContextRef globalContext = privateObject->getContext();
+        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.");
+            }
+            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.");
         }
 
         IEventDeleteEventPtr dplEvent(new IEventDeleteEvent());
@@ -643,10 +645,34 @@ JSValueRef JSCalendar::removeBatch(JSContextRef context,
             ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
+        // Pick one array element to determine its type.
+        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.");
+        }
+
         EventIdListPtr itemIds;
-        itemIds = converter->toVectorOfEventIds(arguments[0]);
-        if (!itemIds) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
+        if (JSValueIsObjectOfClass(context, element, JSCalendarEventId::getClassRef())) {
+            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]);
+            for (unsigned int i=0; i<idStrings.size(); i++) {
+                EventIdPtr idPtr( new EventId() );
+                idPtr->setUId(idStrings[i]);
+                idPtr->setCalendarType(CalendarEvent::TASK_TYPE);
+                itemIds->push_back(idPtr);
+            }
+            if (!itemIds) {
+                ThrowMsg(ConversionException, "Parameter conversion failed.");
+            }
+        } else {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
         }
 
         JSValueRef onError = NULL;
@@ -880,7 +906,7 @@ JSValueRef JSCalendar::find(JSContextRef context,
     return JSValueMakeNull(context);
 }
 
-JSValueRef JSCalendar::expandEventRecurrence(JSContextRef context,
+JSValueRef JSCalendar::get(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -888,62 +914,55 @@ JSValueRef JSCalendar::expandEventRecurrence(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_EXPAND_EVENT_RECURRENCE);
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_GET);
 
     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-    JSCallbackManagerPtr cbm(NULL);
-
     Try
     {
-        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
-        if (argumentCount>5 || argumentCount<4) {
+        if (argumentCount!=1) {
             ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        JSValueRef onError =(argumentCount > 4 ? getFunctionOrNull(context, arguments[4]) : NULL);
+        ICalendarPtr calendar = getCalendar(context, thisObject, exception);
         JSContextRef globalContext = privateObject->getContext();
-        cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
 
-        Validator validator(context);
-        if (validator.isCallback(arguments[3])) {
-            cbm->setOnSuccess(arguments[3]);
-        } else if (JSValueIsNull(context, arguments[3]) || JSValueIsUndefined(context, arguments[3])) {
+        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.");
+            }
+            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.");
         }
 
-        JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-        CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
-        if (!event) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
-        }
+        IEventGetPtr dplEvent(new IEventGet());
+        dplEvent->setForSynchronousCall();
+        dplEvent->setItemId(itemId);
+        calendar->get(dplEvent);
 
-        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 (argumentCount>1 ) {
-            startDate = timeConverter.toTZDateTimeT(arguments[1]);
-        }
-        if (argumentCount>2 ) {
-            endDate = timeConverter.toDateTimeT(arguments[2]);
+        // Process the found item.
+        if (dplEvent->getResult()) {
+            LogInfo("Successfully found an item.");
+            return JSCalendarItem::createJSCalendarItem(globalContext, dplEvent->getItem());
+        } else {
+            ThrowMsg(UnknownException, "Getting an item failed by unkown reason.");
         }
-
-        IEventExpandEventRecurrencePtr dplEvent(new IEventExpandEventRecurrence());
-        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
-        dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
-        dplEvent->setEvent(event);
-        dplEvent->setStartDate(startDate);
-        dplEvent->setEndDate(endDate);
-        calendar->expandEventRecurrence(dplEvent);
-
-        return JSValueMakeNull(context);
     }
     Catch(UnsupportedException)
     {
@@ -1039,7 +1058,7 @@ JSValueRef JSCalendar::convertFromString(JSContextRef context,
 
         if (dplEvent->getResult()) {
             LogInfo("Successfully created an event.");
-            return converter->toJSValueRefItemProperties(dplEvent->getEvent());
+            return JSCalendarItemProperties::createJSCalendarItemProperties(globalContext, dplEvent->getEvent());
         } else {
             ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
         }
@@ -1068,107 +1087,6 @@ JSValueRef JSCalendar::convertFromString(JSContextRef context,
     return JSValueMakeNull(context);
 }
 
-JSValueRef JSCalendar::convertToString(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_CONVERT_TO_STRING);
-
-    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.");
-        }
-
-        if (CalendarEvent::EVENT_TYPE==calendar->getType()) {
-            if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarItem::getClassRef())) {
-                ThrowMsg(ConversionException, "First parameter is not a CalendarItem type.");
-            }
-            if (!JSCalendarEvent::validate(context, Converter(context).toJSObjectRef(arguments[0]), NULL)) {
-                ThrowMsg(InvalidArgumentException, "Wrong parameter value.");
-            }
-        } else if(CalendarEvent::TASK_TYPE==calendar->getType()) {
-            if (!JSValueIsObjectOfClass(context, arguments[0], JSCalendarItem::getClassRef())) {
-                ThrowMsg(ConversionException, "First parameter is not a CalendarItem type.");
-            }
-            if (!JSCalendarTask::validate(context, Converter(context).toJSObjectRef(arguments[0]), NULL)) {
-                ThrowMsg(InvalidArgumentException, "Wrong parameter value.");
-            }
-        }
-
-        JSObjectRef arg = JSValueToObject(context, arguments[0], exception);
-        CalendarEventPtr event = JSCalendarItem::getPrivateObject(arg);
-        if (!event) {
-            ThrowMsg(ConversionException, "Parameter conversion failed.");
-        }
-
-        CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
-        CalendarConverter converter(context);
-        if( argumentCount>1 )
-        {
-            if (JSValueIsString(context, arguments[1])) {
-                format = converter.toVObjectFormat(converter.toString(arguments[1]));
-            }
-        }
-
-        IEventExportEventToStringPtr dplEvent(new IEventExportEventToString());
-        dplEvent->setEvent(event);
-        dplEvent->setFormat(format);
-        dplEvent->setForSynchronousCall();
-        calendar->exportEventToString(dplEvent);
-
-        if (dplEvent->getResult()) {
-            return converter.toJSValueRef(dplEvent->getEventString());
-        } else {
-            ThrowMsg(UnknownException, "Converting to string failed by unkown 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 JSValueMakeNull(context);
-}
-
 JSValueRef JSCalendar::addChangeListener(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
index 72d9c1d..1ed11b8 100755 (executable)
@@ -182,16 +182,6 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Export a string from event
-     */
-    static JSValueRef convertToString(JSContextRef context,
-            JSObjectRef object,
-            JSObjectRef thisObject,
-            size_t argumentCount,
-            const JSValueRef arguments[],
-            JSValueRef* exception);
-
-    /**
      * Watch changes
      */
     static JSValueRef addChangeListener(JSContextRef context,
@@ -212,9 +202,9 @@ class JSCalendar
             JSValueRef* exception);
 
     /**
-     * Expand event instances from a recurring event
+     * Get an item from id
      */
-    static JSValueRef expandEventRecurrence(JSContextRef context,
+    static JSValueRef get(JSContextRef context,
             JSObjectRef object,
             JSObjectRef thisObject,
             size_t argumentCount,
diff --git a/src/standards/Tizen/Calendar/JSCalendarAlarm.cpp b/src/standards/Tizen/Calendar/JSCalendarAlarm.cpp
new file mode 100755 (executable)
index 0000000..1108d10
--- /dev/null
@@ -0,0 +1,332 @@
+/*
+ * 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 "JSCalendarAlarm.h"
+#include "CalendarConverter.h"
+#include <dpl/log/log.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <CommonsJavaScript/Converter.h>
+#include <Tizen/TimeUtil/TimeUtilConverter.h>
+#include <Tizen/TimeUtil/JSTZDate.h>
+#include <Tizen/TimeUtil/JSTimeDuration.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 {
+
+JSClassDefinition JSCalendarAlarm::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_INTERFACE_CALENDAR_ALARM,
+    0,
+    m_property,
+    NULL, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    constructor,
+    NULL, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSCalendarAlarm::m_property[] = {
+    { TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_BEFORE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_METHOD, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_ALARM_DESCRIPTION, getProperty, setProperty, kJSPropertyAttributeNone },
+
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSCalendarAlarm::m_jsClassRef = JSClassCreate(
+        JSCalendarAlarm::getClassInfo());
+
+const JSClassDefinition* JSCalendarAlarm::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSCalendarAlarm::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+JSObjectRef JSCalendarAlarm::createJSCalendarAlarm(JSContextRef context, EventAlarmPtr alarm)
+{
+    EventAlarmPrivateObject *priv = new EventAlarmPrivateObject(context, alarm);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+EventAlarmPtr JSCalendarAlarm::getPrivateObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    EventAlarmPrivateObject *priv =
+        static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    }
+    EventAlarmPtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+void JSCalendarAlarm::setPrivateObject(const EventAlarmPtr &alarm,
+        JSContextRef ctx,
+        const JSObjectRef object)
+{
+    LogDebug("entered");
+    Try
+    {
+        EventAlarmPrivateObject *priv =
+            static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+        delete priv;
+        priv = new EventAlarmPrivateObject(ctx, alarm);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("Error during replacing alarm object.");
+    }
+}
+
+JSObjectRef JSCalendarAlarm::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        if (argumentCount<2 || argumentCount>3) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        EventAlarmPrivateObject* privateObject = static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(constructor));
+        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        EventAlarmPtr alarm( new EventAlarm());
+
+        TimeUtilConverter timeConverter(context);
+        if (JSValueIsObjectOfClass(context, arguments[0], JSTZDate::getClassRef())){ // 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])) {
+                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.");
+                }
+            }
+        } else { // if (JSValueIsObjectOfClass(context, arguments[0], JSTimeDuration::getClassRef())){ // before case
+            alarm->setDuration(timeConverter.getDurationPropertis(arguments[0]));
+            if (JSValueIsString(context, arguments[1])) {
+                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.");
+                }
+            }
+        }/* else { // Workaround until plugin link issue is resolved.
+            ThrowMsg(ConversionException, "First parameter conversion failed.");
+        }*/
+
+        return createJSCalendarAlarm(globalContext, alarm);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+void JSCalendarAlarm::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+    LogDebug("enter");
+}
+
+void JSCalendarAlarm::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    EventAlarmPrivateObject* priv =
+        static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+JSValueRef JSCalendarAlarm::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("enter");
+    WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+    Try
+    {
+        EventAlarmPrivateObject* priv =
+            static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(WrtDeviceApis::Commons::NullPointerException);
+        }
+        EventAlarmPtr alarm = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE)) {
+            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());
+            } else {
+                return JSValueMakeUndefined(context);
+            }
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) {
+            return JSTimeDuration::createJSObject(priv->getContext(), 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);
+        }
+    }
+    Catch(WrtDeviceApis::Commons::Exception)
+    {
+        LogError("invalid property");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarAlarm::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    CalendarConverter converter(context);
+    Try
+    {
+        EventAlarmPrivateObject* priv =
+            static_cast<EventAlarmPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(WrtDeviceApis::Commons::NullPointerException);
+        }
+        EventAlarmPtr alarm = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
+            TimeUtilConverter timeConverter(context);
+            std::time_t absoluteDate = timeConverter.toTZDateTimeT(value);
+            alarm->setAbsoluteDate(absoluteDate);
+
+            if( alarm->getTimeZone().empty() ) {
+                std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
+                alarm->setTimeZone(timeZone);
+            }
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_BEFORE)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTimeDuration::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
+            TimeUtilConverter timeConverter(context);
+            alarm->setDuration(timeConverter.getDurationPropertis(value));
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_DESCRIPTION)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            alarm->setDescription(converter.toString(value));
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_ALARM_METHOD)) {
+            std::string method = converter.toString(value);
+            std::vector<CalendarEvent::EventAlarmType> convertedMethods;
+            convertedMethods.push_back(converter.toEventAlarmType(method));
+            alarm->setMethods(convertedMethods);
+            return true;
+        }
+    }
+    Catch(WrtDeviceApis::Commons::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/JSCalendarAlarm.h b/src/standards/Tizen/Calendar/JSCalendarAlarm.h
new file mode 100755 (executable)
index 0000000..47442b3
--- /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.
+ */
+
+
+#ifndef _JS_CALENDAR_ALARM_H_
+#define _JS_CALENDAR_ALARM_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/EventAlarm.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_INTERFACE_CALENDAR_ALARM "CalendarAlarm"
+
+#define TIZEN_CALENDAR_ALARM_ABSOLUTE_DATE "absoluteDate"
+#define TIZEN_CALENDAR_ALARM_BEFORE "before"
+#define TIZEN_CALENDAR_ALARM_METHOD "method"
+#define TIZEN_CALENDAR_ALARM_DESCRIPTION "description"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventAlarmPtr,
+            WrtDeviceApis::CommonsJavaScript::NoOwnership> EventAlarmPrivateObject;
+
+class JSCalendarAlarm
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createJSCalendarAlarm(JSContextRef context, TizenApis::Api::Calendar::EventAlarmPtr alarm);
+
+    static TizenApis::Api::Calendar::EventAlarmPtr getPrivateObject(JSObjectRef object);
+
+    static void setPrivateObject(const TizenApis::Api::Calendar::EventAlarmPtr &alarm,
+            JSContextRef ctx,
+            const 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);
+
+       /**
+        * Constructor for the CalendarAlarm interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+                   JSObjectRef constructor,
+                   size_t argumentCount,
+                   const JSValueRef arguments[],
+                   JSValueRef* exception);
+
+    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_ALARM_H_ */
diff --git a/src/standards/Tizen/Calendar/JSCalendarAttendee.cpp b/src/standards/Tizen/Calendar/JSCalendarAttendee.cpp
new file mode 100755 (executable)
index 0000000..464be60
--- /dev/null
@@ -0,0 +1,355 @@
+/*
+ * 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 "JSCalendarAttendee.h"
+#include <dpl/log/log.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <CommonsJavaScript/Converter.h>
+#include "CalendarConverter.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 {
+
+JSClassDefinition JSCalendarAttendee::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_INTERFACE_CALENDAR_ATTENDEE,
+    0,
+    m_property,
+    NULL, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    constructor,
+    NULL, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSCalendarAttendee::m_property[] = {
+    { TIZEN_ATTENDEE_NAME, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_URI, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_ROLE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_STATUS, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_RSVP, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_TYPE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_GROUP, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_DELEGATORURI, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_DELEGATEURI, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_ATTENDEE_CONTACT_REF, getProperty, setProperty, kJSPropertyAttributeNone },
+
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSCalendarAttendee::m_jsClassRef = JSClassCreate(
+        JSCalendarAttendee::getClassInfo());
+
+const JSClassDefinition* JSCalendarAttendee::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSCalendarAttendee::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+JSObjectRef JSCalendarAttendee::createJSCalendarAttendee(JSContextRef context, EventAttendeePtr attendee)
+{
+    AttendeePrivateObject *priv = new AttendeePrivateObject(context, attendee);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSCalendarAttendee::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+    LogDebug("enter");
+}
+
+void JSCalendarAttendee::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    AttendeePrivateObject* priv =
+        static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+EventAttendeePtr JSCalendarAttendee::getPrivateObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    AttendeePrivateObject *priv =
+        static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Private object is null.");
+    }
+    EventAttendeePtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null.");
+    }
+    return result;
+}
+
+void JSCalendarAttendee::setPrivateObject(const EventAttendeePtr &attendee,
+        JSContextRef ctx,
+        const JSObjectRef object)
+{
+    LogDebug("entered");
+    Try
+    {
+        AttendeePrivateObject *priv =
+            static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+        delete priv;
+        priv = new AttendeePrivateObject(ctx, attendee);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("Error during replacing attendee object");
+    }
+}
+
+JSObjectRef JSCalendarAttendee::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        AttendeePrivateObject* privateObject = static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(constructor));
+        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        EventAttendeePtr attendee;
+
+        if (argumentCount==1) {
+            if (!JSValueIsString(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+
+            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.");
+            }
+
+            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);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+JSValueRef JSCalendarAttendee::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("enter");
+    CalendarConverterFactory::ConverterType converter =
+        CalendarConverterFactory::getConverter(context);
+    Try
+    {
+        AttendeePrivateObject* priv =
+            static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventAttendeePtr attendee = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_NAME)) {
+            return converter->toJSValueRef(attendee->getName());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_URI)) {
+            return converter->toJSValueRef(attendee->getURI());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_ROLE)) {
+            return converter->toJSValueRef(converter->toTizenValue(attendee->getRole()));
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_STATUS)) {
+            return converter->toJSValueRef(converter->toTizenValue(attendee->getStatus()));
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) {
+            return converter->toJSValueRef(attendee->getRSVP());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_TYPE)) {
+           return converter->toJSValueRef(converter->toTizenValue(attendee->getType()));
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) {
+            return converter->toJSValueRef(attendee->getGroup());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATORURI)) {
+            return converter->toJSValueRef(attendee->getDelegatorURI());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) {
+            return converter->toJSValueRef(attendee->getDelegateURI());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_CONTACT_REF)) {
+            return converter->toJSValueRef(attendee->getPersonId());
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("invalid property");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarAttendee::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    CalendarConverterFactory::ConverterType converter =
+        CalendarConverterFactory::getConverter(context);
+    Try
+    {
+        AttendeePrivateObject* priv =
+            static_cast<AttendeePrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventAttendeePtr attendee = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_NAME)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            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);
+            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));
+            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));
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_RSVP)) {
+            if (!JSValueIsBoolean(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            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));
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_GROUP)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            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);
+            attendee->setDelegatorURI(delegatorURI);
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_ATTENDEE_DELEGATEURI)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            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->setPersonId(uid);
+            return true;
+        }
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+    }
+    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
+    return false;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Calendar/JSCalendarAttendee.h b/src/standards/Tizen/Calendar/JSCalendarAttendee.h
new file mode 100755 (executable)
index 0000000..38a2e02
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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_ATTENDEE_H_
+#define _JS_CALENDAR_ATTENDEE_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/CalendarEvent.h>
+#include <API/Calendar/EventAttendee.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_INTERFACE_CALENDAR_ATTENDEE "CalendarAttendee"
+
+#define TIZEN_ATTENDEE_NAME "name"
+#define TIZEN_ATTENDEE_URI "uri"
+#define TIZEN_ATTENDEE_ROLE "role"
+#define TIZEN_ATTENDEE_STATUS "status"
+#define TIZEN_ATTENDEE_RSVP "RSVP"
+#define TIZEN_ATTENDEE_TYPE "type"
+#define TIZEN_ATTENDEE_GROUP "group"
+#define TIZEN_ATTENDEE_DELEGATORURI "delegatorURI"
+#define TIZEN_ATTENDEE_DELEGATEURI "delegateURI"
+#define TIZEN_ATTENDEE_CONTACT_REF "contactRef"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventAttendeePtr,
+       WrtDeviceApis::CommonsJavaScript::NoOwnership> AttendeePrivateObject;
+
+class JSCalendarAttendee
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createJSCalendarAttendee(JSContextRef context, TizenApis::Api::Calendar::EventAttendeePtr event);
+
+    static TizenApis::Api::Calendar::EventAttendeePtr getPrivateObject(JSObjectRef object);
+
+    static void setPrivateObject(const TizenApis::Api::Calendar::EventAttendeePtr &attendee,
+            JSContextRef ctx,
+            const 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);
+
+       /**
+        * Constructor for the CalendarAttendee interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+                   JSObjectRef constructor,
+                   size_t argumentCount,
+                   const JSValueRef arguments[],
+                   JSValueRef* exception);
+
+    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_ATTENDEE_H_ */
index c922426..0cfb60c 100755 (executable)
 #include <CommonsJavaScript/PrivateObject.h>
 #include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSUtils.h>
-#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
 #include <API/Calendar/EventId.h>
+#include <API/Calendar/ICalendar.h>
+#include <API/Calendar/CalendarFactory.h>
 #include "JSCalendarEvent.h"
 #include "JSCalendarItemProperties.h"
 #include "CalendarConverter.h"
-#include "JSEventId.h"
+#include "JSCalendarEventId.h"
+#include "plugin_config.h"
+#include "CalendarResponseDispatcher.h"
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <Tizen/TimeUtil/JSTZDate.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/SecurityExceptions.h>
 
 using namespace TizenApis::Api::Calendar;
 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 {
 
-#define TIZEN_CALENDAR_EVENT_ATTRIBUTENAME "CalendarEvent"
-
 JSClassDefinition JSCalendarEvent::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    TIZEN_CALENDAR_EVENT_ATTRIBUTENAME,
+    TIZEN_INTERFACE_CALENDAR_EVENT,
     JSCalendarItemProperties::getClassRef(),
     m_property,
-    NULL, //    m_function,
+    m_function,
     initialize,
     finalize,
     NULL, //hasProperty,
@@ -54,7 +77,7 @@ JSClassDefinition JSCalendarEvent::m_classInfo = {
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
+    constructor,
     NULL, //HasInstance,
     NULL  //ConvertToType
 };
@@ -70,6 +93,12 @@ JSStaticValue JSCalendarEvent::m_property[] = {
     { 0, 0, 0, 0 }
 };
 
+JSStaticFunction JSCalendarEvent::m_function[] = {
+    { CALENDAR_FUNCTION_API_EXPAND_RECURRENCE, expandRecurrence, kJSPropertyAttributeNone },
+
+    { 0, 0, 0 }
+};
+
 JSClassRef JSCalendarEvent::m_jsClassRef = JSClassCreate(JSCalendarEvent::getClassInfo());
 
 void JSCalendarEvent::initialize(JSContextRef context,
@@ -93,6 +122,92 @@ void JSCalendarEvent::finalize(JSObjectRef object)
     LogDebug("entered");
 }
 
+JSObjectRef JSCalendarEvent::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+       LogDebug("entered");
+
+    Try
+    {
+               CalendarEventPrivObject* privateObject = static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(constructor));
+               JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        CalendarEventPtr event;
+
+        if (argumentCount==0) {
+            CalendarEventPtr result(new CalendarEvent());
+            event = result;
+        } else if (argumentCount==1) { // eventInitDict case
+            event = converter.toEvent(arguments[0]);
+            if (!event) {
+                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.");
+            }
+
+            std::string eventStr;
+            CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
+            eventStr = converter.toString(arguments[0]);
+            format = converter.toVObjectFormat(converter.toString(arguments[1]));
+
+            ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject();
+            calendar->setType(CalendarEvent::EVENT_TYPE);
+
+            IEventCreateEventFromStringPtr dplEvent(new IEventCreateEventFromString());
+            dplEvent->setEventString(eventStr);
+            dplEvent->setFormat(format);
+            dplEvent->setForSynchronousCall();
+            calendar->createEventFromString(dplEvent);
+
+            // Process the returned object.
+            if (dplEvent->getResult()) {
+                LogInfo("Successfully created an item.");
+                event = dplEvent->getEvent();
+            } else {
+                ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
+            }
+        } else {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        return createJSCalendarEvent(globalContext, event);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+JSObjectRef JSCalendarEvent::createJSCalendarEvent(JSContextRef context, CalendarEventPtr event)
+{
+    CalendarEventPrivObject *priv = new CalendarEventPrivObject(context, event);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
 const JSClassRef JSCalendarEvent::getClassRef()
 {
     if (!m_jsClassRef) {
@@ -142,6 +257,101 @@ void JSCalendarEvent::setPrivateObject(const CalendarEventPtr &event,
     }
 }
 
+JSValueRef JSCalendarEvent::expandRecurrence(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        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);
+
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+    JSCallbackManagerPtr cbm(NULL);
+
+    Try
+    {
+        if (argumentCount<3 || argumentCount>4) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        CalendarEventPtr event = privateObject->getObject();
+        if (!event) {
+            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.");
+        }
+
+        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 (argumentCount>0 ) {
+            startDate = timeConverter.toTZDateTimeT(arguments[0]);
+        }
+        if (argumentCount>1 ) {
+            endDate = timeConverter.toDateTimeT(arguments[1]);
+        }
+
+        ICalendarPtr calendar = CalendarFactory::getInstance().createCalendarObject();
+        calendar->setType(event->getCalendarType());
+
+        IEventExpandEventRecurrencePtr dplEvent(new IEventExpandEventRecurrence());
+        dplEvent->setPrivateData(DPL::StaticPointerCast<IEventPrivateData>(cbm));
+        dplEvent->setForAsynchronousCall(&CalendarResponseDispatcher::getInstance());
+        dplEvent->setEvent(event);
+        dplEvent->setStartDate(startDate);
+        dplEvent->setEndDate(endDate);
+        calendar->expandEventRecurrence(dplEvent);
+
+        return JSValueMakeNull(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 JSValueMakeNull(context);
+}
+
 JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
@@ -150,15 +360,15 @@ JSValueRef JSCalendarEvent::getPropertyId(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        CalendarEventPtr event = getPrivateObject(object);
+        CalendarEventPrivObject *privateObject =
+            static_cast<CalendarEventPrivObject*>(JSObjectGetPrivate(object));
+        CalendarEventPtr event = privateObject->getObject();
 
         EventIdPtr eventId( new EventId() );
         eventId->setUId(event->getUId());
         eventId->setRecurrenceId(event->getRecurrenceId());
         eventId->setTimeZone(event->getTimeZone());
-        return converter->toJSValueRef(eventId);
+        return JSCalendarEventId::createJSCalendarEventId(privateObject->getContext(), eventId);
     }
     Catch(Exception)
     {
index 6229943..7072519 100755 (executable)
@@ -26,6 +26,8 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_INTERFACE_CALENDAR_EVENT "CalendarEvent"
+
 #define TIZEN_CALENDAR_EVENT_ID "id"
 #define TIZEN_CALENDAR_EVENT_LAST_MODIFICATION_DATE "lastModificationDate"
 #define TIZEN_CALENDAR_EVENT_IS_DETACHED "isDetached"
@@ -51,6 +53,8 @@ class JSCalendarEvent
             const JSObjectRef object,
             JSValueRef* exception);
 
+       static JSObjectRef createJSCalendarEvent(JSContextRef context, TizenApis::Api::Calendar::CalendarEventPtr event);
+
   private:
     /**
      * This member variable contains the values which has to be passed when
@@ -83,6 +87,25 @@ class JSCalendarEvent
      */
     static void finalize(JSObjectRef object);
 
+       /**
+        * Constructor for the CalendarEvent interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception);
+
+    /**
+     * Expand event instances from a recurring event
+     */
+    static JSValueRef expandRecurrence(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
+
     /**
      * Getters and setters for properties
      */
diff --git a/src/standards/Tizen/Calendar/JSCalendarEventId.cpp b/src/standards/Tizen/Calendar/JSCalendarEventId.cpp
new file mode 100755 (executable)
index 0000000..73d0965
--- /dev/null
@@ -0,0 +1,289 @@
+/*
+ * 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 "JSCalendarEventId.h"
+#include "CalendarConverter.h"
+#include <dpl/log/log.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <CommonsJavaScript/Converter.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 {
+
+JSClassDefinition JSCalendarEventId::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_INTERFACE_CALENDAR_EVENT_ID,
+    0,
+    m_property,
+    NULL, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    constructor,
+    NULL, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSCalendarEventId::m_property[] = {
+    { TIZEN_CALENDAR_EVENT_ID_UID, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_CALENDAR_EVENT_ID_RECURRENCEID, getProperty, setProperty, kJSPropertyAttributeNone },
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSCalendarEventId::m_jsClassRef = JSClassCreate(
+        JSCalendarEventId::getClassInfo());
+
+const JSClassDefinition* JSCalendarEventId::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSCalendarEventId::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+EventIdPtr JSCalendarEventId::getPrivateObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    EventIdPrivateObject *priv =
+        static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    EventIdPtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+void JSCalendarEventId::setPrivateObject(const EventIdPtr &eventId,
+        JSContextRef ctx,
+        const JSObjectRef object)
+{
+    LogDebug("entered");
+    Try
+    {
+        EventIdPrivateObject *priv =
+            static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+        delete priv;
+        priv = new EventIdPrivateObject(ctx, eventId);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("Error during replacing event id object.");
+    }
+}
+
+JSObjectRef JSCalendarEventId::createJSCalendarEventId(JSContextRef context, EventIdPtr eventId)
+{
+    EventIdPrivateObject *priv = new EventIdPrivateObject(context, eventId);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSCalendarEventId::initialize(JSContextRef context,
+        JSObjectRef object)
+{
+    LogDebug("enter");
+}
+
+void JSCalendarEventId::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    EventIdPrivateObject* priv =
+        static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+JSObjectRef JSCalendarEventId::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        EventIdPrivateObject* privateObject = static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(constructor));
+        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        EventIdPtr eventId;
+
+        if (argumentCount==1) {
+            if (!JSValueIsString(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+
+            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.");
+            }
+
+            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.");
+        }
+
+        return createJSCalendarEventId(globalContext, eventId);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+JSValueRef JSCalendarEventId::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("enter");
+    Converter converter(context);
+    Try
+    {
+        EventIdPrivateObject* priv =
+            static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventIdPtr eventId = priv->getObject();
+
+        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());
+            } else {
+                return JSValueMakeUndefined(context);
+            }
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("invalid property");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarEventId::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Converter converter(context);
+    Try
+    {
+        EventIdPrivateObject* priv =
+            static_cast<EventIdPrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventIdPtr eventId = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_UID)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            std::string uid = converter.toString(value);
+            eventId->setUId(uid);
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_CALENDAR_EVENT_ID_RECURRENCEID)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
+            TimeUtilConverter timeConverter(context);
+            std::time_t recurrenceId = timeConverter.toTZDateTimeT(value);
+            eventId->setRecurrenceId(recurrenceId);
+
+            if( eventId->getTimeZone().empty() ) {
+                std::string timeZone = timeConverter.getPropertiesInTZDate(value).timezone;
+                eventId->setTimeZone(timeZone);
+            }
+            return true;
+        }
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+    }
+    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
+    return false;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Calendar/JSCalendarEventId.h b/src/standards/Tizen/Calendar/JSCalendarEventId.h
new file mode 100755 (executable)
index 0000000..347367f
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * 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_CALEMDAR_EVENT_ID_H_
+#define _JS_CALEMDAR_EVENT_ID_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/EventId.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_INTERFACE_CALENDAR_EVENT_ID "CalendarEventId"
+
+#define TIZEN_CALENDAR_EVENT_ID_UID "uid"
+#define TIZEN_CALENDAR_EVENT_ID_RECURRENCEID "recurrenceId"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventIdPtr,
+                               WrtDeviceApis::CommonsJavaScript::NoOwnership> EventIdPrivateObject;
+
+class JSCalendarEventId
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createJSCalendarEventId(JSContextRef context, TizenApis::Api::Calendar::EventIdPtr eventId);
+
+    static TizenApis::Api::Calendar::EventIdPtr getPrivateObject(JSObjectRef object);
+
+    static void setPrivateObject(const TizenApis::Api::Calendar::EventIdPtr &eventId,
+            JSContextRef ctx,
+            const 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);
+
+       /**
+        * Constructor for the CalendarEventId interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+                   JSObjectRef constructor,
+                   size_t argumentCount,
+                   const JSValueRef arguments[],
+                   JSValueRef* exception);
+
+    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_CALEMDAR_EVENT_ID_H_ */
index 29f5974..4f30327 100755 (executable)
 #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 "JSEventId.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 {
@@ -45,7 +47,7 @@ JSClassDefinition JSCalendarItem::m_classInfo = {
     TIZEN_CALENDAR_ITEM_ATTRIBUTENAME,
     JSCalendarItemProperties::getClassRef(),
     m_property,
-    NULL, //    m_function,
+    NULL,
     initialize,
     finalize,
     NULL, //hasProperty,
@@ -65,6 +67,8 @@ JSStaticValue JSCalendarItem::m_property[] = {
       NULL, kJSPropertyAttributeReadOnly },
     { TIZEN_CALENDAR_ITEM_LAST_MODIFICATION_DATE, getPropertyLastModificationDate,
       NULL, kJSPropertyAttributeReadOnly },
+    { TIZEN_CALENDAR_ITEM_IS_DETACHED, getPropertyIsDetached,
+      NULL, kJSPropertyAttributeReadOnly },
 
     { 0, 0, 0, 0 }
 };
@@ -141,6 +145,12 @@ void JSCalendarItem::setPrivateObject(const CalendarEventPtr &event,
     }
 }
 
+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,
@@ -149,16 +159,21 @@ JSValueRef JSCalendarItem::getPropertyId(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        CalendarEventPtr event = getPrivateObject(object);
-
-        EventIdPtr eventId( new EventId() );
-        eventId->setUId(event->getUId());
-        LogDebug("event->getRecurrenceId() : " << event->getRecurrenceId());
-        eventId->setRecurrenceId(event->getRecurrenceId());
-        eventId->setTimeZone(event->getTimeZone());
-        return converter->toJSValueRef(eventId);
+        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)
     {
@@ -196,6 +211,29 @@ JSValueRef JSCalendarItem::getPropertyLastModificationDate(JSContextRef context,
     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)
index 902de1b..d98f2de 100755 (executable)
@@ -28,6 +28,7 @@ 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;
@@ -46,6 +47,8 @@ class JSCalendarItem
             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);
index facaba6..49f4f37 100755 (executable)
@@ -103,6 +103,12 @@ void JSCalendarItemGeo::finalize(JSObjectRef object)
     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,
index 6b13f24..7bdf35b 100755 (executable)
@@ -42,6 +42,8 @@ class JSCalendarItemGeo
 
     static TizenApis::Api::Calendar::CalendarItemGeoPtr getPrivateObject(JSObjectRef object);
 
+       static JSObjectRef createJSCalendarItemGeo(JSContextRef context, TizenApis::Api::Calendar::CalendarItemGeoPtr geo);
+
   private:
 
     /**
index 79636d4..bc3553a 100755 (executable)
 #include <CommonsJavaScript/JSUtils.h>
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/SecurityExceptions.h>
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <Tizen/TimeUtil/JSTZDate.h>
 #include <API/Calendar/EventAlarm.h>
 #include <API/Calendar/EventId.h>
+#include <API/Calendar/ICalendar.h>
+#include <API/Calendar/CalendarFactory.h>
 #include "API/TimeUtil/DurationProperties.h"
 #include "JSCalendarItemProperties.h"
 #include "CalendarConverter.h"
-#include "JSEventId.h"
-#include "JSEventAlarm.h"
-#include "JSRecurrenceRule.h"
-#include "JSAttendee.h"
+#include "JSCalendarEventId.h"
+#include "JSCalendarAlarm.h"
+#include "JSCalendarRecurrenceRule.h"
+#include "JSCalendarAttendee.h"
+#include "JSCalendarItemGeo.h"
+#include "JSCalendarItem.h"
+#include "plugin_config.h"
 
 using namespace TizenApis::Api::Calendar;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Commons;
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -50,7 +57,7 @@ JSClassDefinition JSCalendarItemProperties::m_classInfo = {
     TIZEN_CALENDAR_ITEM_PROPERTIES_ATTRIBUTENAME,
     0,
     m_property,
-    NULL, //m_function,
+    m_function,
     initialize,
     finalize,
     NULL, //hasProperty,
@@ -110,6 +117,13 @@ JSStaticValue JSCalendarItemProperties::m_property[] = {
     { 0, 0, 0, 0 }
 };
 
+JSStaticFunction JSCalendarItemProperties::m_function[] = {
+    { CALENDAR_FUNCTION_API_CONVERT_TO_STRING, convertToString, kJSPropertyAttributeNone },
+    { CALENDAR_FUNCTION_API_CLONE, clone, kJSPropertyAttributeNone },
+
+    { 0, 0, 0 }
+};
+
 JSClassRef JSCalendarItemProperties::m_jsClassRef = JSClassCreate(JSCalendarItemProperties::getClassInfo());
 
 void JSCalendarItemProperties::initialize(JSContextRef context,
@@ -185,6 +199,162 @@ void JSCalendarItemProperties::setPrivateObject(const CalendarEventPtr &event,
     }
 }
 
+JSObjectRef JSCalendarItemProperties::createJSCalendarItemProperties(JSContextRef context, CalendarEventPtr item)
+{
+    CalendarItemPropertiesPrivObject *priv = new CalendarItemPropertiesPrivObject(context, item);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSValueRef JSCalendarItemProperties::convertToString(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    CalendarItemPropertiesPrivObject *privateObject =
+        static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(thisObject));
+    assert(privateObject);
+
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(),
+            CALENDAR_FUNCTION_API_CONVERT_TO_STRING);
+
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+    Try
+    {
+        CalendarEventPtr item = privateObject->getObject();
+        if (!item) {
+            ThrowMsg(ConversionException, "Parameter conversion failed.");
+        }
+
+        if (argumentCount!=1) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        if (!JSValueIsString(context, arguments[0])) {
+            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());
+
+        IEventExportEventToStringPtr dplEvent(new IEventExportEventToString());
+        dplEvent->setEvent(item);
+        dplEvent->setFormat(format);
+        dplEvent->setForSynchronousCall();
+        calendar->exportEventToString(dplEvent);
+
+        if (dplEvent->getResult()) {
+            return converter.toJSValueRef(dplEvent->getEventString());
+        } else {
+            ThrowMsg(UnknownException, "Converting to string failed by unkown 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 JSValueMakeNull(context);
+}
+
+JSValueRef JSCalendarItemProperties::clone(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    CalendarItemPropertiesPrivObject *privateObject =
+        static_cast<CalendarItemPropertiesPrivObject*>(JSObjectGetPrivate(thisObject));
+    assert(privateObject);
+
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(),
+            CALENDAR_FUNCTION_API_CLONE);
+
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+    Try
+    {
+        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));
+
+        // Reset the id.
+        clonedItem->resetId();
+        clonedItem->setRecurrenceId(0);
+
+        return JSCalendarItem::createJSCalendarItem(globalContext, clonedItem);
+    }
+    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 JSValueMakeNull(context);
+}
+
 JSValueRef JSCalendarItemProperties::getPropertyDescription(JSContextRef context,
         JSObjectRef object,
         JSStringRef propertyName,
@@ -511,8 +681,9 @@ JSValueRef JSCalendarItemProperties::getPropertyAlarms(JSContextRef context,
             methodVector.push_back(event->getAlarmsType().at(i)); // Only one alarm type is saved.
             alarm->setMethods(methodVector);
             alarm->setTimeZone(event->getTimeZone());
+            alarm->setDescription(event->getAlarmsDescription().at(i));
 
-            if (!JSSetArrayElement(context, jsResult, i, JSEventAlarm::createJSObject(context, alarm))) {
+            if (!JSSetArrayElement(context, jsResult, i, JSCalendarAlarm::createJSCalendarAlarm(context, alarm))) {
                ThrowMsg(UnknownException, "Could not insert value into js array");
             }
         }
@@ -539,13 +710,16 @@ bool JSCalendarItemProperties::setPropertyAlarms(JSContextRef context,
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
 
-        EventAlarmListPtr alarms = converter->toVectorOfEventAlarms(value);
+        EventAlarmListPtr alarms = converter->toVectorOfEventAlarmsFromReference(value);
         std::vector<CalendarEvent::EventAlarmType> alarmsType;
         std::vector<long> alarmsTick;
+        std::vector<std::string> alarmsDescription;
+
         // Set the multiple alarms.
         for( unsigned int i=0; i<alarms->size(); i++) {
             EventAlarmPtr theAlarm = alarms->at(i);
             alarmsType.push_back(theAlarm->getMethods().at(0));
+            alarmsDescription.push_back(theAlarm->getDescription());
             if( 0 < theAlarm->getAbsoluteDate() ) {
                 alarmsTick.push_back(theAlarm->getAbsoluteDate()/60);
             } else {
@@ -699,7 +873,7 @@ JSValueRef JSCalendarItemProperties::getPropertyGeolocation(JSContextRef context
         CalendarEventPtr event = getPrivateObject(object);
         CalendarItemGeoPtr geoInfo = event->getGeolocation();
 
-        return converter.toJSValueRef(geoInfo);
+        return JSCalendarItemGeo::createJSCalendarItemGeo(context, geoInfo);
     }
     Catch(Exception)
     {
@@ -815,7 +989,7 @@ JSValueRef JSCalendarItemProperties::getPropertyRecurrenceRule(JSContextRef cont
         EventRecurrenceRulePtr rrule = event->getRecurrenceRule();
 
         if (rrule) {
-            return JSRecurrenceRule::createJSRecurrenceRule(context, rrule);
+            return JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(context, rrule);
         }
     }
     Catch(Exception)
@@ -836,9 +1010,7 @@ bool JSCalendarItemProperties::setPropertyRecurrenceRule(JSContextRef context,
     Try
     {
         event = getPrivateObject(object);
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        event->setRecurrenceRule(converter->toEventRecurrenceRule(value));
+        event->setRecurrenceRule(JSCalendarRecurrenceRule::getPrivateObject(JSValueToObject(context, value, NULL)));
         return true;
     }
     Catch(Exception)
@@ -965,7 +1137,7 @@ JSValueRef JSCalendarItemProperties::getPropertyAttendees(JSContextRef context,
                 ThrowMsg(NullPointerException, "Could not create js array object");
             }
             for(unsigned int i=0; i<attendees->size(); i++) {
-                if (!JSSetArrayElement(context, jsResult, i, JSAttendee::createJSAttendee(context, attendees->at(i)))) {
+                if (!JSSetArrayElement(context, jsResult, i, JSCalendarAttendee::createJSCalendarAttendee(context, attendees->at(i)))) {
                    ThrowMsg(UnknownException, "Could not insert value into js array");
                 }
             }
@@ -991,7 +1163,7 @@ bool JSCalendarItemProperties::setPropertyAttendees(JSContextRef context,
         CalendarEventPtr event = getPrivateObject(object);
         CalendarConverterFactory::ConverterType converter =
             CalendarConverterFactory::getConverter(context);
-        event->setAttendees(converter->toVectorOfAttendees(value));
+        event->setAttendees(converter->toVectorOfAttendeesFromReference(value));
         return true;
     }
     Catch(Exception)
index 5eff397..dafb02f 100755 (executable)
@@ -69,6 +69,8 @@ class JSCalendarItemProperties
             JSContextRef ctx,
             const JSObjectRef object);
 
+       static JSObjectRef createJSCalendarItemProperties(JSContextRef context, TizenApis::Api::Calendar::CalendarEventPtr geo);
+
     static bool validate(JSContextRef ctx,
             const JSObjectRef object,
             JSValueRef* exception);
@@ -106,6 +108,26 @@ class JSCalendarItemProperties
     static void finalize(JSObjectRef object);
 
     /**
+     * Export a string from item
+     */
+    static JSValueRef convertToString(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
+
+    /**
+     * Copy item object contents except id
+     */
+    static JSValueRef clone(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
+
+    /**
      * Getters and setters for properties
      */
     static JSValueRef getPropertyDescription(JSContextRef context,
index d57df1c..20d19cc 100755 (executable)
@@ -40,8 +40,6 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Commons;
 
 #define TIZEN_CALENDAR_MANAGER_ATTRIBUTENAME "calendar"
-#define TIZEN_CALENDAR_MANAGER_FUNCTION_GET_CALENDARS "getCalendars"
-#define TIZEN_CALENDAR_MANAGER_FUNCTION_GET_DEFAULT_CALENDAR "getDefaultCalendar"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -68,12 +66,15 @@ JSClassDefinition JSCalendarManager::m_classInfo = {
 };
 
 JSStaticFunction JSCalendarManager::m_function[] = {
-    { TIZEN_CALENDAR_MANAGER_FUNCTION_GET_CALENDARS,
+    { CALENDAR_FUNCTION_API_GET_CALENDARS,
       getCalendars, kJSPropertyAttributeNone },
 
-    { TIZEN_CALENDAR_MANAGER_FUNCTION_GET_DEFAULT_CALENDAR,
+    { CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR,
       getDefaultCalendar, kJSPropertyAttributeNone },
 
+    { CALENDAR_FUNCTION_API_GET_CALENDAR,
+      getCalendar, kJSPropertyAttributeNone },
+
     { 0, 0, 0 }
 };
 
@@ -201,7 +202,7 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
             ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
         }
 
-        CalendarConverter converter(context);
+        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.");
@@ -215,11 +216,92 @@ JSValueRef JSCalendarManager::getDefaultCalendar(JSContextRef context,
         privateObject->getObject()->getDefaultCalendar(dplEvent);
 
         if (dplEvent->getResult()) {
-            CalendarConverterFactory::ConverterType converter =
-                CalendarConverterFactory::getConverter(globalContext); // should be global!
-            return converter->toJSValueRefCalendar(dplEvent->getCalendar());
+            return converter.toJSValueRefCalendar(dplEvent->getCalendar());
+        } else {
+            ThrowMsg(UnknownException, "Getting default calendar failed by unkown 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 JSValueMakeNull(context);
+}
+
+JSValueRef JSCalendarManager::getCalendar(JSContextRef context,
+        JSObjectRef object,
+        JSObjectRef thisObject,
+        size_t argumentCount,
+        const JSValueRef arguments[],
+        JSValueRef* exception)
+{
+    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);
+
+    TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+    Try {
+        if (argumentCount!=2) {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        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 {
+            calendarType = converter.toCalendarType(converter.toString(arguments[0]));
+        }
+
+        std::string calendarId;
+        if (!JSValueIsString(context, arguments[1])) {
+            ThrowMsg(ConversionException, "Wrong parameter type.");
+        } else {
+            calendarId = converter.toString(arguments[1]);
+        }
+
+        IEventGetCalendarPtr dplEvent(new IEventGetCalendar());
+        dplEvent->setForSynchronousCall();
+        dplEvent->setId(calendarId);
+        dplEvent->setType(calendarType);
+        privateObject->getObject()->getCalendar(dplEvent);
+
+        // Process the result.
+        if (dplEvent->getResult()) {
+            return converter.toJSValueRefCalendar(dplEvent->getCalendar());
         } else {
-            ThrowMsg(UnknownException, "Updating failed by unkown reason.");
+            ThrowMsg(UnknownException, "Getting calendar failed by unkown reason.");
         }
     }
     Catch(UnsupportedException)
index aafe67f..abb1c87 100755 (executable)
@@ -79,7 +79,7 @@ typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar
 #define TIZEN_CALENDAR_PROPERTY_YEARLY_RECURRENCE   "YEARLY"
 
 //#define TIZEN_CALENDAR_PROPERTY_NO_ALARM            "NO_ALARM"
-#define TIZEN_CALENDAR_PROPERTY_SILENT_ALARM        "SILENT"
+#define TIZEN_CALENDAR_PROPERTY_DISPLAY_ALARM        "DISPLAY"
 #define TIZEN_CALENDAR_PROPERTY_SOUND_ALARM         "SOUND"
 
 #define TIZEN_CALENDAR_PROPERTY_TYPE_EVENT         "EVENT"
@@ -150,6 +150,16 @@ class JSCalendarManager
             size_t argumentCount,
             const JSValueRef arguments[],
             JSValueRef* exception);
+
+    /**
+     * Get a calendar.
+     */
+    static JSValueRef getCalendar(JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
 };
 
 }
diff --git a/src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp b/src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.cpp
new file mode 100755 (executable)
index 0000000..d8f0ab7
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+ * 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 "JSCalendarRecurrenceRule.h"
+#include <dpl/log/log.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <CommonsJavaScript/Converter.h>
+#include "CalendarConverter.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 {
+
+JSClassDefinition JSCalendarRecurrenceRule::m_classInfo = {
+    0,
+    kJSClassAttributeNone,
+    TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE,
+    0,
+    m_property,
+    NULL, //m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //deleteProperty,
+    NULL, //getPropertyNames,
+    NULL, //callAsFunction,
+    constructor,
+    NULL, //hasInstance,
+    NULL, //convertToType,
+};
+
+JSStaticValue JSCalendarRecurrenceRule::m_property[] = {
+    { TIZEN_RECURRENCE_RULE_FREQUENCY, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_INTERVAL, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_UNTIL_DATE, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT, getProperty, setProperty, kJSPropertyAttributeNone },
+//    { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK, getProperty, setProperty, kJSPropertyAttributeNone },
+//    { TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR, getProperty, setProperty, kJSPropertyAttributeNone },
+//    { TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_SET_POSITION, getProperty, setProperty, kJSPropertyAttributeNone },
+    { TIZEN_RECURRENCE_RULE_EXCEPTIONS, getProperty, setProperty, kJSPropertyAttributeNone },
+
+    { 0, 0, 0, 0 }
+};
+
+JSClassRef JSCalendarRecurrenceRule::m_jsClassRef = JSClassCreate(
+        JSCalendarRecurrenceRule::getClassInfo());
+
+const JSClassDefinition* JSCalendarRecurrenceRule::getClassInfo()
+{
+    return &(m_classInfo);
+}
+
+JSClassRef JSCalendarRecurrenceRule::getClassRef()
+{
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+JSObjectRef JSCalendarRecurrenceRule::createJSCalendarRecurrenceRule(JSContextRef context, EventRecurrenceRulePtr rule)
+{
+    RecurrenceRulePrivateObject *priv = new RecurrenceRulePrivateObject(context, rule);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSCalendarRecurrenceRule::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug("enter");
+}
+
+void JSCalendarRecurrenceRule::finalize(JSObjectRef object)
+{
+    LogDebug("enter");
+    RecurrenceRulePrivateObject* priv =
+        static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+    delete priv;
+    JSObjectSetPrivate(object, NULL);
+}
+
+EventRecurrenceRulePtr JSCalendarRecurrenceRule::getPrivateObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    RecurrenceRulePrivateObject *priv =
+        static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+    if (!priv) {
+        ThrowMsg(NullPointerException, "Private object is null.");
+    }
+    EventRecurrenceRulePtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null.");
+    }
+    return result;
+}
+
+void JSCalendarRecurrenceRule::setPrivateObject(const EventRecurrenceRulePtr &rrule,
+        JSContextRef ctx,
+        const JSObjectRef object)
+{
+    LogDebug("entered");
+    Try
+    {
+        RecurrenceRulePrivateObject *priv =
+            static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+        delete priv;
+        priv = new RecurrenceRulePrivateObject(ctx, rrule);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) {
+            delete priv;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("Error during replacing rrule object.");
+    }
+}
+
+JSObjectRef JSCalendarRecurrenceRule::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+    LogDebug("entered");
+
+    Try
+    {
+        RecurrenceRulePrivateObject* privateObject = static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(constructor));
+        JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        EventRecurrenceRulePtr rrule;
+
+        if (argumentCount==1) {
+            if (!JSValueIsString(context, arguments[0])) {
+                ThrowMsg(ConversionException, "Wrong parameter type.");
+            }
+
+            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.");
+            }
+
+            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);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+JSValueRef JSCalendarRecurrenceRule::getProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("enter");
+    CalendarConverterFactory::ConverterType converter =
+        CalendarConverterFactory::getConverter(context);
+    Try
+    {
+        RecurrenceRulePrivateObject* priv =
+            static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventRecurrenceRulePtr rrule = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) {
+            return converter->toJSValueRef(converter->toTizenValue(rrule->getFrequency()));
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_INTERVAL)) {
+            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());
+            } else {
+                return JSValueMakeUndefined(context);
+            }
+        } 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());
+        } 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());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_SET_POSITION)) {
+            return converter->toJSValueRef(rrule->getSetPosition());
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
+            JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+            if (NULL == jsResult) {
+                LogError("Could not create js array object.");
+                ThrowMsg(NullPointerException, "Could not create js array object");
+            }
+
+            for (std::size_t i = 0; i < rrule->getExceptions().size(); ++i) {
+                JSValueRef tmpVal = JSTZDate::createJSObject(priv->getContext(), 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");
+                }
+            }
+
+            return jsResult;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("invalid property");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+bool JSCalendarRecurrenceRule::setProperty(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    CalendarConverterFactory::ConverterType converter =
+        CalendarConverterFactory::getConverter(context);
+    Try
+    {
+        RecurrenceRulePrivateObject* priv =
+            static_cast<RecurrenceRulePrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv) {
+            Throw(NullPointerException);
+        }
+        EventRecurrenceRulePtr rrule = priv->getObject();
+
+        if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_FREQUENCY)) {
+            if (!JSValueIsString(context, value)) {
+                Throw(InvalidArgumentException);
+            }
+            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);
+            rrule->setInterval(interval);
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_UNTIL_DATE)) {
+            if (!JSValueIsObjectOfClass(context, value, JSTZDate::getClassRef())) {
+                Throw(InvalidArgumentException);
+            }
+            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);
+            rrule->setOccurrenceCount(occurrenceCount);
+            return true;
+        /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH)) {
+            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);
+            rrule->setDaysOfTheWeek(daysOfTheWeek);
+            return true;
+        /*} else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR)) {
+            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);
+            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);
+            rrule->setSetPosition(setPosition);*/
+            return true;
+        } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN_RECURRENCE_RULE_EXCEPTIONS)) {
+            // Only save the converted time info.
+            rrule->setExceptions(converter->toVectorOfTimeTFromTZDate(value));
+            return true;
+        }
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+    }
+    JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR);
+    return false;
+}
+
+}
+}
+}
diff --git a/src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.h b/src/standards/Tizen/Calendar/JSCalendarRecurrenceRule.h
new file mode 100755 (executable)
index 0000000..eb32588
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * 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_RECURRENCE_RULE_H_
+#define _JS_CALENDAR_RECURRENCE_RULE_H_
+
+#include <string>
+#include <vector>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Calendar/CalendarEvent.h>
+#include <API/Calendar/EventRecurrenceRule.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Calendar {
+
+#define TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE "CalendarRecurrenceRule"
+
+#define TIZEN_RECURRENCE_RULE_FREQUENCY "frequency"
+#define TIZEN_RECURRENCE_RULE_INTERVAL "interval"
+#define TIZEN_RECURRENCE_RULE_UNTIL_DATE "untilDate"
+#define TIZEN_RECURRENCE_RULE_OCCURRENCE_COUNT "occurrenceCount"
+//#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_MONTH "daysOfTheMonth"
+#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_WEEK "daysOfTheWeek"
+//#define TIZEN_RECURRENCE_RULE_DAYS_OF_THE_YEAR "daysOfTheYear"
+//#define TIZEN_RECURRENCE_RULE_WEEKS_OF_THE_YEAR "weeksOfTheYear"
+#define TIZEN_RECURRENCE_RULE_SET_POSITION "setPositions"
+#define TIZEN_RECURRENCE_RULE_EXCEPTIONS "exceptions"
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Calendar::EventRecurrenceRulePtr,
+       WrtDeviceApis::CommonsJavaScript::NoOwnership> RecurrenceRulePrivateObject;
+
+class JSCalendarRecurrenceRule
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createJSCalendarRecurrenceRule(JSContextRef context, TizenApis::Api::Calendar::EventRecurrenceRulePtr rule);
+
+    static TizenApis::Api::Calendar::EventRecurrenceRulePtr getPrivateObject(JSObjectRef object);
+
+    static void setPrivateObject(const TizenApis::Api::Calendar::EventRecurrenceRulePtr &rrule,
+            JSContextRef ctx,
+            const 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);
+
+       /**
+        * Constructor for the CalendarRecurrenceRule interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+                   JSObjectRef constructor,
+                   size_t argumentCount,
+                   const JSValueRef arguments[],
+                   JSValueRef* exception);
+
+    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_RECURRENCE_RULE_H_ */
index 76158ba..659ab25 100755 (executable)
 #include <CommonsJavaScript/JSUtils.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <API/Calendar/EventId.h>
+#include <API/Calendar/ICalendar.h>
+#include <API/Calendar/CalendarFactory.h>
 #include "JSCalendarTask.h"
 #include "JSCalendarItemProperties.h"
 #include "CalendarConverter.h"
-#include "JSEventId.h"
+#include "JSCalendarEventId.h"
 #include <Tizen/TimeUtil/TimeUtilConverter.h>
 #include <Tizen/TimeUtil/JSTZDate.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.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_TASK_ATTRIBUTENAME "CalendarTask"
-
 JSClassDefinition JSCalendarTask::m_classInfo = {
     0,
     kJSClassAttributeNone,
-    TIZEN_CALENDAR_TASK_ATTRIBUTENAME,
+    TIZEN_INTERFACE_CALENDAR_TASK,
     JSCalendarItemProperties::getClassRef(),
     m_property,
     NULL, //    m_function,
@@ -92,6 +95,92 @@ void JSCalendarTask::finalize(JSObjectRef object)
     LogDebug("entered");
 }
 
+JSObjectRef JSCalendarTask::constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception)
+{
+       LogDebug("entered");
+
+    Try
+    {
+               CalendarTaskPrivObject* privateObject = static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(constructor));
+               JSContextRef globalContext = privateObject ? privateObject->getContext() : context;
+
+        CalendarConverter converter(globalContext);
+        CalendarEventPtr task;
+
+        if (argumentCount==0) {
+            CalendarEventPtr result(new CalendarEvent());
+            task = result;
+        } else if (argumentCount==1) { // eventInitDict case
+            task = converter.toEvent(arguments[0]);
+            if (!task) {
+                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.");
+            }
+
+            std::string eventStr;
+            CalendarEvent::VObjectFormat format = CalendarEvent::ICALENDAR_20;
+            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);
+
+            // Process the returned object.
+            if (dplEvent->getResult()) {
+                LogInfo("Successfully created an item.");
+                task = dplEvent->getEvent();
+            } else {
+                ThrowMsg(UnknownException, "Converting from string failed by unkown reason.");
+            }
+        } else {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        return createJSCalendarTask(globalContext, task);
+    }
+    Catch(UnsupportedException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::NOT_SUPPORTED_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(InvalidArgumentException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(ConversionException)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, _rethrown_exception.GetMessage());
+    }
+    Catch(Exception)
+    {
+        LogWarning("Exception: "<<_rethrown_exception.GetMessage());
+        *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, _rethrown_exception.GetMessage());
+    }
+
+    return NULL;
+}
+
+JSObjectRef JSCalendarTask::createJSCalendarTask(JSContextRef context, CalendarEventPtr task)
+{
+    CalendarTaskPrivObject *priv = new CalendarTaskPrivObject(context, task);
+    return JSObjectMake(context, getClassRef(), priv);
+}
+
 const JSClassRef JSCalendarTask::getClassRef()
 {
     if (!m_jsClassRef) {
@@ -149,15 +238,11 @@ JSValueRef JSCalendarTask::getPropertyId(JSContextRef context,
     LogDebug("entered");
     Try
     {
-        CalendarConverterFactory::ConverterType converter =
-            CalendarConverterFactory::getConverter(context);
-        CalendarEventPtr event = getPrivateObject(object);
-
-        EventIdPtr eventId( new EventId() );
-        eventId->setUId(event->getUId());
-        eventId->setRecurrenceId(event->getRecurrenceId());
-        eventId->setTimeZone(event->getTimeZone());
-        return converter->toJSValueRef(eventId);
+        CalendarTaskPrivObject *privateObject =
+            static_cast<CalendarTaskPrivObject*>(JSObjectGetPrivate(object));
+        CalendarEventPtr task = privateObject->getObject();
+
+        return Converter(context).toJSValueRef(task->getUId());
     }
     Catch(Exception)
     {
index 7bfcf35..385274f 100755 (executable)
@@ -26,6 +26,8 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+#define TIZEN_INTERFACE_CALENDAR_TASK "CalendarTask"
+
 #define TIZEN_CALENDAR_TASK_ID "id"
 #define TIZEN_CALENDAR_TASK_LAST_MODIFICATION_DATE "lastModificationDate"
 
@@ -50,6 +52,8 @@ class JSCalendarTask
             const JSObjectRef object,
             JSValueRef* exception);
 
+       static JSObjectRef createJSCalendarTask(JSContextRef context, TizenApis::Api::Calendar::CalendarEventPtr task);
+
   private:
     /**
      * This member variable contains the values which has to be passed when
@@ -82,6 +86,15 @@ class JSCalendarTask
      */
     static void finalize(JSObjectRef object);
 
+       /**
+        * Constructor for the CalendarTask interface.
+        */
+       static JSObjectRef constructor(JSContextRef context,
+    JSObjectRef constructor,
+    size_t argumentCount,
+    const JSValueRef arguments[],
+    JSValueRef* exception);
+
     /**
      * Getters and setters for properties
      */
index c796d11..1c33631 100755 (executable)
@@ -85,7 +85,6 @@ static FunctionMapping createCalendarFunctions()
     /**
      * Functions
      */
-
     FunctionMapping calendarMapping;
 
     //getCalendars
@@ -110,6 +109,16 @@ static FunctionMapping createCalendarFunctions()
                                CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR,
                                getDefaultCalendarFunc));
 
+    //getCalendar
+    AceFunction getCalendarFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET_CALENDAR,
+            CALENDAR_FUNCTION_API_GET_CALENDAR,
+            CALENDAR_FEATURES_CALENDAR_READ_WRITE,
+            DEVICE_LIST_CALENDAR_READ);
+
+    calendarMapping.insert(std::make_pair(
+                               CALENDAR_FUNCTION_API_GET_CALENDAR,
+                               getCalendarFunc));
 
     //find
     AceFunction findFunc = ACE_CREATE_FUNCTION(
@@ -189,7 +198,7 @@ static FunctionMapping createCalendarFunctions()
                                removeBatchFunc));
 
     //convertFromString
-    AceFunction convertFromStringFunc = ACE_CREATE_FUNCTION(
+    /*AceFunction convertFromStringFunc = ACE_CREATE_FUNCTION(
             FUNCTION_CONVERT_FROM_STRING,
             CALENDAR_FUNCTION_API_CONVERT_FROM_STRING,
             CALENDAR_FEATURES_CALENDAR_READ_WRITE,
@@ -197,7 +206,7 @@ static FunctionMapping createCalendarFunctions()
 
     calendarMapping.insert(std::make_pair(
                                CALENDAR_FUNCTION_API_CONVERT_FROM_STRING,
-                               convertFromStringFunc));
+                               convertFromStringFunc));*/
 
     //convertToString
     AceFunction convertToStringFunc = ACE_CREATE_FUNCTION(
@@ -232,20 +241,42 @@ static FunctionMapping createCalendarFunctions()
                                CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER,
                                removeChangeListenerFunc));
 
-    //expandEventRecurrence
-    AceFunction expandEventRecurrenceFunc = ACE_CREATE_FUNCTION(
-            FUNCTION_EXPAND_EVENT_RECURRENCE,
-            CALENDAR_FUNCTION_API_EXPAND_EVENT_RECURRENCE,
+    //expandRecurrence
+    AceFunction expandRecurrenceFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_EXPAND_RECURRENCE,
+            CALENDAR_FUNCTION_API_EXPAND_RECURRENCE,
+            CALENDAR_FEATURES_CALENDAR_READ,
+            DEVICE_LIST_CALENDAR_READ);
+
+    calendarMapping.insert(std::make_pair(
+                               CALENDAR_FUNCTION_API_EXPAND_RECURRENCE,
+                               expandRecurrenceFunc));
+
+    //get
+    AceFunction getFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_GET,
+            CALENDAR_FUNCTION_API_GET,
+            CALENDAR_FEATURES_CALENDAR_READ,
+            DEVICE_LIST_CALENDAR_READ);
+
+    calendarMapping.insert(std::make_pair(
+                               CALENDAR_FUNCTION_API_GET,
+                               getFunc));
+
+    //clone
+    AceFunction cloneFunc = ACE_CREATE_FUNCTION(
+            FUNCTION_CLONE,
+            CALENDAR_FUNCTION_API_CLONE,
             CALENDAR_FEATURES_CALENDAR_READ,
             DEVICE_LIST_CALENDAR_READ);
 
     calendarMapping.insert(std::make_pair(
-                               CALENDAR_FUNCTION_API_EXPAND_EVENT_RECURRENCE,
-                               expandEventRecurrenceFunc));
+                               CALENDAR_FUNCTION_API_CLONE,
+                               getFunc));
 
     return calendarMapping;
 }
 
 }
 } 
-} 
\ No newline at end of file
+}
index 7cccfc0..af6194b 100755 (executable)
@@ -25,8 +25,12 @@ namespace TizenApis {
 namespace Tizen1_0 {
 namespace Calendar {
 
+// Functions from calendar manager
 #define CALENDAR_FUNCTION_API_GET_CALENDARS "getCalendars"
 #define CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR "getDefaultCalendar"
+#define CALENDAR_FUNCTION_API_GET_CALENDAR "getCalendar"
+
+// Functions from calendar
 #define CALENDAR_FUNCTION_API_ADD "add"
 #define CALENDAR_FUNCTION_API_ADD_BATCH "addBatch"
 #define CALENDAR_FUNCTION_API_UPDATE "update"
@@ -38,7 +42,9 @@ namespace Calendar {
 #define CALENDAR_FUNCTION_API_CONVERT_TO_STRING "convertToString"
 #define CALENDAR_FUNCTION_API_ADD_CHANGE_LISTENER "addChangeListener"
 #define CALENDAR_FUNCTION_API_REMOVE_CHANGE_LISTENER "removeChangeListener"
-#define CALENDAR_FUNCTION_API_EXPAND_EVENT_RECURRENCE "expandEventRecurrence"
+#define CALENDAR_FUNCTION_API_EXPAND_RECURRENCE "expandRecurrence"
+#define CALENDAR_FUNCTION_API_GET "get"
+#define CALENDAR_FUNCTION_API_CLONE "clone"
 
 DECLARE_FUNCTION_GETTER(Calendar);
 
index 11e9c23..87360e2 100755 (executable)
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>
 #include "JSCalendarManager.h"
+#include "JSCalendarEvent.h"
+#include "JSCalendarTask.h"
+#include "JSCalendarAttendee.h"
+#include "JSCalendarRecurrenceRule.h"
+#include "JSCalendarEventId.h"
+#include "JSCalendarAlarm.h"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -46,6 +52,30 @@ PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
         "calendar",
         JSCalendarManager::getClassRef(),
         NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+               TIZEN_INTERFACE_CALENDAR_EVENT,
+               JSCalendarEvent::getClassRef(),
+               NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        TIZEN_INTERFACE_CALENDAR_TASK,
+        JSCalendarEvent::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        TIZEN_INTERFACE_CALENDAR_ATTENDEE,
+        JSCalendarAttendee::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        TIZEN_INTERFACE_CALENDAR_RECURRENCE_RULE,
+        JSCalendarRecurrenceRule::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        TIZEN_INTERFACE_CALENDAR_EVENT_ID,
+        JSCalendarEventId::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+        TIZEN_INTERFACE_CALENDAR_ALARM,
+        JSCalendarAlarm::getClassRef(),
+        NULL)
 PLUGIN_CLASS_MAP_END
 
 }
index bfa3352..89d1000 100755 (executable)
@@ -6,17 +6,39 @@ set(SRCS
   ${SRCS_PLATFORM_API_CALL}
   ${SRCS_PLATFORM_IMPLEMENTATION_CALL}
   ${SRCS_PLATFORM_API_FILTER}
-  JSCallApi.cpp
+  CallMultiCallback.cpp
+  CallStaticController.cpp
+  Converter.cpp
   JSCallHistory.cpp
   JSCallHistoryEntry.cpp
-  Converter.cpp
-  ResponseDispatcher.cpp
-  plugin_initializer.cpp
+  JSCallManager.cpp
+  JSCallService.cpp
+  JSCellularCallService.cpp
+  JSRemoteParty.cpp
   plugin_config.cpp
+  plugin_initializer.cpp
+  ResponseDispatcher.cpp
+  ${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
   ../Tizen/FilterConverter.cpp
+  ../Tizen/JSAttributeFilter.cpp
+  ../Tizen/JSAttributeRangeFilter.cpp
+  ../Tizen/JSCompositeFilter.cpp
+  ../Tizen/JSAbstractFilterArray.cpp
+  ../Tizen/JSSortMode.cpp
   ../Common/JSTizenException.cpp
   ../Common/TizenExceptionData.cpp
   ../Common/JSTizenExceptionFactory.cpp
+  ../Common/JSGlobalContextFactory.cpp
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
diff --git a/src/standards/Tizen/Call/CallMultiCallback.cpp b/src/standards/Tizen/Call/CallMultiCallback.cpp
new file mode 100755 (executable)
index 0000000..6ef4b2e
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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 "CallMultiCallback.h"
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+EventCallHistoryListenerPrivateData::EventCallHistoryListenerPrivateData(
+                       const JSCallbackManagerPtr& onAdded, const JSCallbackManagerPtr& onChanged) :
+                       m_onAdded(onAdded), m_onChanged(onChanged)
+{
+}
+
+JSCallbackManagerPtr EventCallHistoryListenerPrivateData::getOnAdded() const
+{
+       return m_onAdded;
+}
+
+JSCallbackManagerPtr EventCallHistoryListenerPrivateData::getOnChanged() const
+{
+       return m_onChanged;
+}
+
+}
+}
+
diff --git a/src/standards/Tizen/Call/CallMultiCallback.h b/src/standards/Tizen/Call/CallMultiCallback.h
new file mode 100755 (executable)
index 0000000..4e49356
--- /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. 
+ */
+
+#ifndef TIZENAPIS_TIZEN_CALL_MULTI_CALLBACK_H_
+#define TIZENAPIS_TIZEN_CALL_MULTI_CALLBACK_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 Tizen1_0 {
+
+struct CallHistoryChangeCB
+{
+       JSValueRef onAdded;
+       JSValueRef onChanged;
+
+       CallHistoryChangeCB() :
+               onAdded(NULL),
+               onChanged(NULL)
+       { }
+};
+
+class EventCallHistoryListenerPrivateData : public WrtDeviceApis::Commons::IEventPrivateData
+{
+public:
+       EventCallHistoryListenerPrivateData(const JSCallbackManagerPtr& onAdded,
+                       const JSCallbackManagerPtr& onChanged);
+
+       JSCallbackManagerPtr getOnAdded() const;
+       JSCallbackManagerPtr getOnChanged() const;
+
+private:
+       JSCallbackManagerPtr m_onAdded;
+       JSCallbackManagerPtr m_onChanged;
+};
+
+typedef DPL::SharedPtr<EventCallHistoryListenerPrivateData> EventCallHistoryListenerPrivateDataPtr;
+
+}
+}
+
+#endif
diff --git a/src/standards/Tizen/Call/CallStaticController.cpp b/src/standards/Tizen/Call/CallStaticController.cpp
new file mode 100755 (executable)
index 0000000..f43cfde
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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 <JavaScriptCore/JavaScript.h>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <Commons/IEvent.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "CallStaticController.h"
+#include "Converter.h"
+
+using namespace TizenApis::Api::Call;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+CallStaticController& CallStaticController::getInstance()
+{
+    static CallStaticController controller;
+    return controller;
+}
+
+CallStaticController::CallStaticController() :
+       WrtDeviceApis::Commons::EventListener<EventCallHistoryListener>(ThreadEnum::NULL_THREAD)
+{
+}
+
+void CallStaticController::onAnswerReceived(const EventCallHistoryListenerPtr& event)
+{
+       EventCallHistoryListenerPrivateDataPtr multiCallbacks = 
+               DPL::DynamicPointerCast<EventCallHistoryListenerPrivateData>(event->getPrivateData());
+
+       assert(multiCallbacks != NULL);
+       assert(multiCallbacks->getOnAdded() != NULL);
+       assert(multiCallbacks->getOnChanged() != NULL);
+
+       JSCallbackManagerPtr defaultCbm = multiCallbacks->getOnAdded(); 
+       JSContextRef context = defaultCbm->getContext();
+       Converter converter(context);
+
+       try {
+               JSValueRef result = converter.toJSValueRef(event->getResult(), context);
+               
+               switch (event->getResultState()) {
+               case EventCallHistoryListener::ADDED :
+                       multiCallbacks->getOnAdded()->callOnSuccess(result);
+                       break;
+               case EventCallHistoryListener::CHANGED :
+                       multiCallbacks->getOnChanged()->callOnSuccess(result);
+                       break;                  
+               }
+       } catch(ConversionException) {
+               LogError(       "Conversion exception while processing EventCallHistoryListener");
+       }
+}
+
+}
+}
diff --git a/src/standards/Tizen/Call/CallStaticController.h b/src/standards/Tizen/Call/CallStaticController.h
new file mode 100755 (executable)
index 0000000..cbc4826
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * 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_CALL_STATIC_CONTROLLER_H_
+#define TIZENAPIS_TIZEN_CALL_STATIC_CONTROLLER_H_
+
+#include <Commons/EventReceiver.h>
+#include <Commons/EventListener.h>
+#include <API/Call/EventCallHistoryListener.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+class CallStaticController : 
+       public WrtDeviceApis::Commons::EventListener<Api::Call::EventCallHistoryListener>
+{
+public:
+       static CallStaticController& getInstance();
+
+       void onAnswerReceived(const Api::Call::EventCallHistoryListenerPtr& event);
+
+protected:
+       CallStaticController();
+};
+}
+}
+
+#endif
+
index 9ee597c..331a053 100755 (executable)
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/JSUtils.h>
-#include <API/Call/CallHistoryEntryProperties.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
 #include "JSCallHistoryEntry.h"
+#include "JSRemoteParty.h"
+#include "JSCallService.h"
+#include "JSCellularCallService.h"
 
 #define CH_ENTRY_ID                            "entryId"
-#define CH_ACCOUNT_ID                  "accountId"
+#define CH_SERVICE_ID                  "serviceId"
 #define CH_CALL_TYPE                   "callType"
-#define CH_REMOTE_PARTY                "remoteParty"
-#define CH_CONTACT_ID                  "contactId"
-#define CH_CONTACT_DETAILS             "contactDetails"
+#define CH_TAGS                                        "tags"
+#define CH_REMOTE_PARTIES              "remoteParties"
 #define CH_FORWARDEDFROM               "forwardedFrom"
 #define CH_START_TIME                  "startTime"
 #define CH_DURATION                    "duration"
 #define CH_END_REASON                  "endReason"
-#define CH_USED_CAPABILITIES   "usedCapabilities"
-#define CH_KIND                                        "kind"
-#define CH_TAGS                                        "tags"
 #define CH_DIRECTION                   "direction"
 #define CH_RECORDING                   "recording"
 #define CH_COST                                        "cost"
 #define CH_CURRENCY                            "currency"
 
+#define CH_REMOTE_PARTY                "remoteParty"
+#define CH_DISPLAY_NAME                "displayName"
+#define CH_CONTACT_ID                  "contactId"
+
+#define CH_SERVICETYPE_ID              "serviceTypeId"
+#define CH_SERVICENAME                 "serviceName"
+#define CH_PROVIDER_ID                 "providerId"
+
 using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
@@ -51,6 +58,8 @@ 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)
 {
@@ -91,9 +100,9 @@ CallHistoryEntryList Converter::toVectorOfCallHistoryEntryProperties(const JSVal
 
 }
 
-stringArrayPtr Converter::toCallHistoryEntryStringArray(const JSValueRef &jsValue)
+StringArrayPtr Converter::toStringArray(const JSValueRef &jsValue)
 {
-       stringArrayPtr result(new stringArray());
+       StringArrayPtr result(new StringArray());
        try {
                if (!JSValueIsNull(m_context, jsValue)) {
                        JSObjectRef jsObject = toJSObjectRef(jsValue);
@@ -109,6 +118,122 @@ stringArrayPtr Converter::toCallHistoryEntryStringArray(const JSValueRef &jsValu
        return result;
 }
 
+RemotePartyListPtr Converter::toRemotePartyList(const JSValueRef &jsValue)
+{
+       RemotePartyListPtr result(new RemotePartyList());
+       try {
+               if (!JSValueIsNull(m_context, jsValue)) {
+                       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(toRemoteParty(element));
+                       }
+               }
+       } catch (Commons::Exception& ex) {
+               LogError("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(CH_REMOTE_PARTY));
+       const ScopedJSStringRef displayNameStr(JSStringCreateWithUTF8CString(CH_DISPLAY_NAME));
+       const ScopedJSStringRef contactIdStr(JSStringCreateWithUTF8CString(CH_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);
+       }
+
+       return result;
+}
+
+CallServiceFilterPtr Converter::toCallServiceFilter(const JSValueRef &jsValue)
+{
+       Validator validator(m_context);
+       if (!validator.checkArrayKeys(m_allowedCallServiceFilter, jsValue)) {
+               ThrowMsg(Commons::InvalidArgumentException, "Wrong attribute of RemoteParty");
+       }
+
+       const ScopedJSStringRef serviceTypeIdStr(JSStringCreateWithUTF8CString(CH_SERVICETYPE_ID));
+       const ScopedJSStringRef tagsStr(JSStringCreateWithUTF8CString(CH_TAGS));
+       const ScopedJSStringRef serviceNameStr(JSStringCreateWithUTF8CString(CH_SERVICENAME));
+       const ScopedJSStringRef providerIdStr(JSStringCreateWithUTF8CString(CH_PROVIDER_ID));
+
+       JSObjectRef jsObject = toJSObjectRef(jsValue);
+
+       JSValueRef jServiceTypeId = JSObjectGetProperty(m_context, jsObject, serviceTypeIdStr.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 serviceTypeId;
+       StringArrayPtr tags;
+       std::string serviceName;
+       std::string providerId;
+
+       CallServiceFilterPtr result(new CallServiceFilter());
+
+       if (!result) {
+               Throw(Commons::ConversionException);
+       }
+
+       if (!JSValueIsUndefined(m_context, jServiceTypeId)) {
+               serviceTypeId = toString(jServiceTypeId);
+               result->setServiceTypeId(serviceTypeId);
+       }
+
+       if (!JSValueIsUndefined(m_context, jTags)) {
+               tags = toStringArray(jProviderId);
+               result->setTags(tags);
+       }
+
+       if (!JSValueIsUndefined(m_context, jServiceName)) {
+               serviceName = toString(jServiceName);
+               result->setServiceName(serviceName);
+       }
+
+       if (!JSValueIsUndefined(m_context, jProviderId)) {
+               providerId = toString(jProviderId);
+               result->setProviderId(providerId);
+       }
+
+       return result;
+}
+
 CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSValueRef &jsValue)
 {
        Validator validator(m_context);
@@ -117,17 +242,14 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
        }
 
        const ScopedJSStringRef entryIdStr(JSStringCreateWithUTF8CString(CH_ENTRY_ID));
-       const ScopedJSStringRef accountIdStr(JSStringCreateWithUTF8CString(CH_ACCOUNT_ID));
+       const ScopedJSStringRef serviceIdStr(JSStringCreateWithUTF8CString(CH_SERVICE_ID));
        const ScopedJSStringRef callTypeStr(JSStringCreateWithUTF8CString(CH_CALL_TYPE));
-       const ScopedJSStringRef remotePartyStr(JSStringCreateWithUTF8CString(CH_REMOTE_PARTY));
-       const ScopedJSStringRef contactIdStr(JSStringCreateWithUTF8CString(CH_CONTACT_ID));
-       const ScopedJSStringRef contactDetailsStr(JSStringCreateWithUTF8CString(CH_CONTACT_DETAILS));
+       const ScopedJSStringRef tagsStr(JSStringCreateWithUTF8CString(CH_TAGS));
+       const ScopedJSStringRef remotePartiesStr(JSStringCreateWithUTF8CString(CH_REMOTE_PARTIES));
        const ScopedJSStringRef forwardedFromStr(JSStringCreateWithUTF8CString(CH_FORWARDEDFROM));
        const ScopedJSStringRef startTimeStr(JSStringCreateWithUTF8CString(CH_START_TIME));
        const ScopedJSStringRef durationStr(JSStringCreateWithUTF8CString(CH_DURATION));
        const ScopedJSStringRef endReasonStr(JSStringCreateWithUTF8CString(CH_END_REASON));
-       const ScopedJSStringRef usedCapabilitiesStr(JSStringCreateWithUTF8CString(CH_USED_CAPABILITIES));
-       const ScopedJSStringRef kindStr(JSStringCreateWithUTF8CString(CH_KIND));
        const ScopedJSStringRef directionStr(JSStringCreateWithUTF8CString(CH_DIRECTION));
        const ScopedJSStringRef recordingStr(JSStringCreateWithUTF8CString(CH_RECORDING));
        const ScopedJSStringRef costStr(JSStringCreateWithUTF8CString(CH_COST));
@@ -136,36 +258,30 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
        JSObjectRef jsObject = toJSObjectRef(jsValue);
 
        JSValueRef jEntryId = JSObjectGetProperty(m_context, jsObject, entryIdStr.get(), NULL);
-       JSValueRef jAccountId = JSObjectGetProperty(m_context, jsObject, accountIdStr.get(), NULL);
+       JSValueRef jServiceId = JSObjectGetProperty(m_context, jsObject, serviceIdStr.get(), NULL);
        JSValueRef jCallType = JSObjectGetProperty(m_context, jsObject, callTypeStr.get(), NULL);
-       JSValueRef jRemoteParty = JSObjectGetProperty(m_context, jsObject, remotePartyStr.get(), NULL);
-       JSValueRef jContactId = JSObjectGetProperty(m_context, jsObject, contactIdStr.get(), NULL);
-       JSValueRef jContactDetails = JSObjectGetProperty(m_context, jsObject, contactDetailsStr.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 jUsedCapabilities = JSObjectGetProperty(m_context, jsObject, usedCapabilitiesStr.get(), NULL);
-       JSValueRef jKind = JSObjectGetProperty(m_context, jsObject, kindStr.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 accountId;
+       std::string serviceId;
        std::string callType;
-       std::string remoteParty;
-       std::string contactId;
-       std::string contactDetails;
-       std::string forwardedFrom;
+       StringArrayPtr tags;
+       RemotePartyListPtr remoteParties;
+       RemotePartyPtr forwardedFrom;
        time_t startTime;
        unsigned long duration;
        std::string endReason;
-       stringArrayPtr usedCapabilities;
-       std::string kind;
        std::string direction;
-       stringArrayPtr recording;
+       StringArrayPtr recording;
        unsigned long cost;
        std::string currency;
 
@@ -182,9 +298,9 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
                ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
        }
 
-       if (!JSValueIsUndefined(m_context, jAccountId)) {
-               accountId = toString(jAccountId);
-               result->setAccountId(accountId);
+       if (!JSValueIsUndefined(m_context, jServiceId)) {
+               serviceId = toString(jServiceId);
+               result->setServiceId(serviceId);
        }
 
        if (!JSValueIsUndefined(m_context, jCallType)) {
@@ -192,25 +308,20 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
                result->setCallType(callType);
        }
 
-       if (!JSValueIsUndefined(m_context, jRemoteParty)) {
-               remoteParty = toString(jRemoteParty);
-               result->setRemoteParty(remoteParty);
-       } else {
-               ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
+       if (!JSValueIsUndefined(m_context, jTags)) {
+               tags = toStringArray(jTags);
+               result->setTags(tags);
        }
 
-       if (!JSValueIsUndefined(m_context, jContactId)) {
-               contactId = toString(jContactId);
-               result->setContactId(contactId);
-       }
-
-       if (!JSValueIsUndefined(m_context, jContactDetails)) {
-               contactDetails = toString(jContactDetails);
-               result->setContactDetails(contactDetails);
+       if (!JSValueIsUndefined(m_context, jRemoteParties)) {
+               remoteParties = toRemotePartyList(jRemoteParties);
+               result->setRemoteParties(remoteParties);
+       } else {
+               ThrowMsg(Commons::InvalidArgumentException, "Undefined history entry");
        }
 
        if (!JSValueIsUndefined(m_context, jForwardedFrom)) {
-               forwardedFrom = toString(jForwardedFrom);
+               forwardedFrom = toRemoteParty(jForwardedFrom);
                result->setForwardedFrom(forwardedFrom);
        }
 
@@ -229,23 +340,13 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
                result->setEndReason(endReason);
        }
 
-       if (!JSValueIsUndefined(m_context, jUsedCapabilities)) {
-               usedCapabilities = toCallHistoryEntryStringArray(jUsedCapabilities);
-               result->setUsedCapabilities(usedCapabilities);
-       }
-
-       if (!JSValueIsUndefined(m_context, jKind)) {
-               kind = toString(jKind);
-               result->setKind(kind);
-       }
-
        if (!JSValueIsUndefined(m_context, jDirection)) {
                direction = toString(jDirection);
                result->setDirection(direction);
        }
 
        if (!JSValueIsUndefined(m_context, jRecording)) {
-               recording = toCallHistoryEntryStringArray(jRecording);
+               recording = toStringArray(jRecording);
                result->setRecording(recording);
        }
 
@@ -262,6 +363,34 @@ CallHistoryEntryPropertiesPtr Converter::toCallHistoryEntryProperties(const JSVa
        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");
+       }
+
+       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");
+       }
+
+       JSCallbackManagerPtr onAddedCbm = JSCallbackManager::createObject(context, result.onAdded, NULL);
+       JSCallbackManagerPtr onChangedCbm = JSCallbackManager::createObject(context, result.onChanged, NULL);
+
+       return EventCallHistoryListenerPrivateDataPtr(new EventCallHistoryListenerPrivateData(onAddedCbm, onChangedCbm));
+}
+
 JSValueRef Converter::toJSValueRef(const Api::Call::CallHistoryEntryListPtr& arg, JSContextRef context)
 {
        JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
@@ -284,7 +413,7 @@ JSValueRef Converter::toJSValueRef(const Api::Call::CallHistoryEntryListPtr& arg
        return jsResult;
 }
 
-JSValueRef Converter::toJSValueRef(const Api::Call::stringArrayPtr &arg, JSContextRef context)
+JSValueRef Converter::toJSValueRef(const Api::Call::StringArrayPtr &arg, JSContextRef context)
 {
        JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
        if (!jsResult) {
@@ -300,29 +429,74 @@ JSValueRef Converter::toJSValueRef(const Api::Call::stringArrayPtr &arg, JSConte
        return jsResult;
 }
 
+JSValueRef Converter::toJSValueRef(const Api::Call::RemotePartyListPtr& arg, JSContextRef context)
+{
+       JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
+       if (!jsResult) {
+               ThrowMsg(Commons::ConversionException, "Could not create js array object");
+       }
+
+       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.");
+               }
+
+               if (!JSSetArrayElement(m_context, jsResult, i, jsObject)) {
+                       ThrowMsg(Commons::ConversionException, "Could not insert value into js array");
+               }
+       }
+       return jsResult;
+}
+
+JSValueRef Converter::toJSValueRef(const Api::Account::AccountServicesArrayPtr& arg, JSContextRef context)
+{
+       std::vector<JSValueRef> callServiceList;
+
+       Api::Account::AccountServices tmpAccountServices;
+
+       for (size_t i = 0; i < (*arg).size(); i++) {
+               tmpAccountServices = *((*arg)[i]);
+
+               if (tmpAccountServices.getServiceTypeId().compare("tizen.tel") == 0) {
+                       callServiceList.push_back(JSCellularCallService::createJSObject(context, tmpAccountServices));
+               } else {
+                       callServiceList.push_back(JSCallService::createJSObject(context, tmpAccountServices));
+               }
+       }
+
+       return toJSValueRef(callServiceList);
+}
+
 bool Converter::initializeAllowedProperties()
 {
        m_allowedCallHistoryEntryProperties.push_back(CH_ENTRY_ID);
-       m_allowedCallHistoryEntryProperties.push_back(CH_ACCOUNT_ID);
+       m_allowedCallHistoryEntryProperties.push_back(CH_SERVICE_ID);
        m_allowedCallHistoryEntryProperties.push_back(CH_CALL_TYPE);
-       m_allowedCallHistoryEntryProperties.push_back(CH_REMOTE_PARTY);
-       m_allowedCallHistoryEntryProperties.push_back(CH_CONTACT_ID);
-       m_allowedCallHistoryEntryProperties.push_back(CH_CONTACT_DETAILS);
+       m_allowedCallHistoryEntryProperties.push_back(CH_TAGS);
+       m_allowedCallHistoryEntryProperties.push_back(CH_REMOTE_PARTIES);
        m_allowedCallHistoryEntryProperties.push_back(CH_FORWARDEDFROM);
        m_allowedCallHistoryEntryProperties.push_back(CH_START_TIME);
        m_allowedCallHistoryEntryProperties.push_back(CH_DURATION);
        m_allowedCallHistoryEntryProperties.push_back(CH_END_REASON);
-       m_allowedCallHistoryEntryProperties.push_back(CH_USED_CAPABILITIES);
-       m_allowedCallHistoryEntryProperties.push_back(CH_KIND);
        m_allowedCallHistoryEntryProperties.push_back(CH_DIRECTION);
        m_allowedCallHistoryEntryProperties.push_back(CH_RECORDING);
        m_allowedCallHistoryEntryProperties.push_back(CH_COST);
        m_allowedCallHistoryEntryProperties.push_back(CH_CURRENCY);
+       m_allowedRemoteParty.push_back(CH_REMOTE_PARTY);
+       m_allowedRemoteParty.push_back(CH_DISPLAY_NAME);
+       m_allowedRemoteParty.push_back(CH_CONTACT_ID);
+       m_allowedCallServiceFilter.push_back(CH_SERVICETYPE_ID);
+       m_allowedCallServiceFilter.push_back(CH_TAGS);
+       m_allowedCallServiceFilter.push_back(CH_SERVICENAME);
+       m_allowedCallServiceFilter.push_back(CH_PROVIDER_ID);
 
        return true;
-
 }
 
-} // Tizen1_0
-} // TizenApis
+}
+}
 
index 6a87a9d..d33c461 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 "CallMultiCallback.h"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -39,17 +43,31 @@ public:
 
        Api::Call::CallHistoryEntryList toVectorOfCallHistoryEntryProperties(const JSValueRef& arg);
 
-       Api::Call::stringArrayPtr toCallHistoryEntryStringArray(const JSValueRef &jsValue);
+       Api::Call::StringArrayPtr toStringArray(const JSValueRef &jsValue);
+
+       Api::Call::RemotePartyListPtr toRemotePartyList(const JSValueRef &jsValue);
+
+       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);
+
        JSValueRef toJSValueRef(const Api::Call::CallHistoryEntryListPtr &arg, JSContextRef context);
 
-       JSValueRef toJSValueRef(const Api::Call::stringArrayPtr &arg, JSContextRef context);
+       JSValueRef toJSValueRef(const Api::Call::StringArrayPtr &arg, JSContextRef context);
+
+       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 5aec320..ff07e37 100755 (executable)
 #include <Tizen/Tizen/FilterConverter.h>
 #include <API/Call/EventFindCallHistory.h>
 #include <API/Call/EventRemoveBatch.h>
+#include <API/Call/EventRemoveAll.h>
+#include <API/Call/EventCallHistoryListener.h>
 #include <API/Call/CallHistoryFactory.h>
+#include <API/Call/ICallHistory.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h> 
 #include <Tizen/Common/SecurityExceptions.h>
 
 #include "JSCallHistoryEntry.h"
 #include "JSCallHistory.h"
+#include "CallStaticController.h"
+#include "CallMultiCallback.h"
 #include "ResponseDispatcher.h"
 #include "Converter.h"
 #include "plugin_config.h"
@@ -42,18 +47,6 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Tizen1_0::Tizen;
 using namespace TizenApis::Commons;
 
-#define STR_CALL_TYPE_UNKNOWN                          "CALL_TYPE_UNKNOWN"
-#define STR_CALL_TYPE_AUDIO                                    "CALL_TYPE_AUDIO"
-#define STR_CALL_TYPE_VIDEO                                    "CALL_TYPE_VIDEO"
-
-#define STR_CALL_STATE_UNKNOWN                         "CALL_STATE_UNKNOWN"
-#define STR_CALL_STATE_INCOMING                                "CALL_STATE_INCOMING"
-#define STR_CALL_STATE_OUTGOING                                "CALL_STATE_OUTGOING"
-#define STR_CALL_STATE_MISSED_CHECKED          "CALL_STATE_MISSED_CHECKED"
-#define STR_CALL_STATE_MISSED_UNCHECKED                "CALL_STATE_MISSED_UNCHECKED"
-#define STR_CALL_STATE_REJECTED                                "CALL_STATE_REJECTED"
-#define STR_CALL_STATE_BLOCKED                         "CALL_STATE_BLOCKED"
-
 namespace TizenApis {
 namespace Tizen1_0 {
 
@@ -89,6 +82,10 @@ JSStaticFunction JSCallHistory::m_function[] =
        { "find", JSCallHistory::find, kJSPropertyAttributeNone },
        { "remove",      JSCallHistory::remove,      kJSPropertyAttributeNone },
        { "removeBatch",      JSCallHistory::removeBatch,      kJSPropertyAttributeNone },
+       { "removeAll",      JSCallHistory::removeAll,      kJSPropertyAttributeNone },
+       { "deleteRecording",      JSCallHistory::deleteRecording,      kJSPropertyAttributeNone },
+       { "addListener",      JSCallHistory::addListener,      kJSPropertyAttributeNone },
+       { "removeListener",      JSCallHistory::removeListener,      kJSPropertyAttributeNone },
        { 0, 0, 0 }
 };
 
@@ -139,7 +136,7 @@ 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) {
+       if (argumentCount < 1 || argumentCount > 6) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
        }
 
@@ -154,8 +151,6 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
                FilterConverterFactory::ConverterType filterConverter = FilterConverterFactory::getConverter(context);
 
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
-               if (cbm != NULL) {
-               }
 
                if (argumentCount >= 2) {
                        if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1])) {
@@ -183,7 +178,7 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
                        }
                }
 
-               AceSecurityStatus status = CALL_HISTORY_CHECK_ACCESS(
+               AceSecurityStatus status = CALL_CHECK_ACCESS(
                                gContext,
                                CALL_HISTORY_FUNCTION_API_FIND);
 
@@ -203,7 +198,7 @@ JSValueRef JSCallHistory::find(JSContextRef context, JSObjectRef object, JSObjec
 
                if (argumentCount >= 4) {
                        if (!check.isNullOrUndefined(arguments[3])) {
-                               event->setSortMode(filterConverter->toSortModeArray(arguments[3]));
+                               event->setSortMode(filterConverter->toSortMode(arguments[3]));
                        }
                }
 
@@ -236,7 +231,7 @@ 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) {
+       if (argumentCount < 1 || argumentCount > 1) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
        }
 
@@ -254,7 +249,7 @@ JSValueRef JSCallHistory::remove(JSContextRef context, JSObjectRef object, JSObj
        }
 
        try {
-               AceSecurityStatus status = CALL_HISTORY_CHECK_ACCESS(
+               AceSecurityStatus status = CALL_CHECK_ACCESS(
                                gContext,
                                CALL_HISTORY_FUNCTION_API_REMOVE);
 
@@ -279,7 +274,7 @@ 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) {
+       if (argumentCount < 1 || argumentCount > 3) {
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
        }
 
@@ -296,8 +291,6 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
 
        try {
                JSCallbackManagerPtr cbm(JSCallbackManager::createObject(gContext));
-               if (cbm != NULL) {
-               }
 
                if (argumentCount >= 3) {
                        if (!JSValueIsNull(context, arguments[2]) && !JSValueIsUndefined(context, arguments[2])) {
@@ -317,7 +310,7 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
                        }
                }
 
-               AceSecurityStatus status = CALL_HISTORY_CHECK_ACCESS(
+               AceSecurityStatus status = CALL_CHECK_ACCESS(
                                gContext,
                                CALL_HISTORY_FUNCTION_API_REMOVE_BATCH);
 
@@ -355,6 +348,158 @@ JSValueRef JSCallHistory::removeBatch(JSContextRef context, JSObjectRef object,
        return JSValueMakeUndefined(context);
 }
 
+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");
+       }
+
+       JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
+       JSContextRef gContext = priv->getContext();
+
+       assert(priv && "Invalid private pointer.");
+       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]);
+                       }
+               }
+
+               if (argumentCount >= 1) {
+                       if (!JSValueIsNull(context, arguments[0]) && !JSValueIsUndefined(context, arguments[0])) {
+                               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]);
+                       }
+               }
+
+               AceSecurityStatus status = CALL_CHECK_ACCESS(
+                               gContext,
+                               CALL_HISTORY_FUNCTION_API_REMOVE_ALL);
+
+               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+               EventRemoveAllPtr event(new EventRemoveAll());
+               ICallHistoryPtr callHistory(priv->getObject());
+               event->setPrivateData(StaticPointerCast<IEventPrivateData> (cbm));
+               event->setForAsynchronousCall(&ResponseDispatcher::getInstance());
+
+               callHistory->removeAll(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);
+}
+
+JSValueRef JSCallHistory::deleteRecording(JSContextRef context, JSObjectRef object, JSObjectRef thisObject, size_t argumentCount,
+       const JSValueRef arguments[], JSValueRef* exception) {
+
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error : deleteRecording");
+}
+
+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");
+       }
+
+       JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
+       JSContextRef gContext = priv->getContext();
+
+       assert(priv && "Invalid private pointer.");
+       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);
+
+               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);
+
+               return converter.toJSValueRefLong(id);
+       } 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);
+}
+
+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");
+       }
+
+       JSCallHistoryPriv *priv = static_cast<JSCallHistoryPriv*> (JSObjectGetPrivate(thisObject));
+       JSContextRef gContext = priv->getContext();
+
+       assert(priv && "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 = static_cast<long>(converter.toLong(arguments[0]));
+
+               if (id >= 0) {
+                       ICallHistoryPtr callHistory(priv->getObject());
+                       callHistory->removeListener(id);
+               }
+       } 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);
+}
+
 }
 }
 
index 4394dcb..eec38aa 100755 (executable)
@@ -59,6 +59,22 @@ private:
                        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
                        JSValueRef* exception);
 
+       static JSValueRef removeAll(JSContextRef context, JSObjectRef object,
+                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef deleteRecording(JSContextRef context, JSObjectRef object,
+                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef addListener(JSContextRef context, JSObjectRef object,
+                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef removeListener(JSContextRef context, JSObjectRef object,
+                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+                       JSValueRef* exception);
+
        static JSClassDefinition m_classInfo;
 
        static JSStaticValue m_property[];
index 9ee9874..9c0751d 100755 (executable)
 #include <CommonsJavaScript/JSUtils.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <API/Call/CallHistoryEntryProperties.h>
+#include <API/Call/CallHistoryFactory.h>
+#include <API/Call/ICallHistoryEntry.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/SecurityExceptions.h>
 #include "JSCallHistoryEntry.h"
+#include "JSRemoteParty.h"
 #include "Converter.h"
 
 namespace TizenApis {
@@ -32,19 +38,17 @@ using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::Call;
+using namespace TizenApis::Commons;
 
 #define STR_ENTRY_ID                   "entryId"
-#define STR_ACCOUNT_ID                 "accountId"
+#define STR_SERVICE_ID                 "serviceId"
 #define STR_CALL_TYPE                  "callType"
-#define STR_REMOTE_PARTY               "remoteParty"
-#define STR_CONTACT_ID                 "contactId"
-#define STR_CONTACT_DETAILS    "contactDetails"
+#define STR_TAGS                               "tags"
+#define STR_REMOTE_PARTIES             "remoteParties"
 #define STR_FORWARDEDFROM              "forwardedFrom"
 #define STR_START_TIME                 "startTime"
 #define STR_DURATION                   "duration"
 #define STR_END_REASON                 "endReason"
-#define STR_USED_CAPABILITIES  "usedCapabilities"
-#define STR_KIND                               "kind"
 #define STR_DIRECTION                  "direction"
 #define STR_RECORDING                  "recording"
 #define STR_COST                               "cost"
@@ -72,21 +76,18 @@ JSClassDefinition JSCallHistoryEntry::m_classInfo = {
 
 JSStaticValue JSCallHistoryEntry::m_property[] = {
        { STR_ENTRY_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_ACCOUNT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_SERVICE_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_CALL_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_REMOTE_PARTY, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_CONTACT_ID, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_CONTACT_DETAILS, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_FORWARDEDFROM, getProperty, NULL, kJSPropertyAttributeNone },
+       { STR_TAGS, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_REMOTE_PARTIES, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_FORWARDEDFROM, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_START_TIME, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_DURATION, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_END_REASON, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_USED_CAPABILITIES, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_KIND, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_DIRECTION, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_RECORDING, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_COST, getProperty, NULL, kJSPropertyAttributeNone },
-       { STR_CURRENCY, getProperty, NULL, kJSPropertyAttributeNone },
+       { STR_END_REASON, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_DIRECTION, getProperty, setProperty, kJSPropertyAttributeNone },
+       { STR_RECORDING, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_COST, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_CURRENCY, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { 0, 0, 0, 0 }
 };
 
@@ -106,13 +107,13 @@ const JSClassDefinition* JSCallHistoryEntry::getClassInfo()
 JSClassRef JSCallHistoryEntry::m_jsClassRef = JSClassCreate(JSCallHistoryEntry::getClassInfo());
 
 JSObjectRef JSCallHistoryEntry::createJSObject(JSContextRef context,
-        const CallHistoryEntryProperties &callInfo)
+        const CallHistoryEntryProperties &entryInfo)
 {
-       std::auto_ptr<CallHistoryEntryProperties> callHistoryEntryProps(new CallHistoryEntryProperties(callInfo));
+       std::auto_ptr<CallHistoryEntryProperties> callHistoryEntryProps(new CallHistoryEntryProperties(entryInfo));
        JSCallHistoryEntryPriv *priv = new JSCallHistoryEntryPriv(context, callHistoryEntryProps.get());
        callHistoryEntryProps.release();
        if (!priv) {
-               ThrowMsg(Commons::NullPointerException, "Can not new an object");
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Can not new an object");
        }
        return JSObjectMake(context, getClassRef(), priv);
 }
@@ -137,50 +138,88 @@ JSValueRef JSCallHistoryEntry::getProperty(JSContextRef context,
        assert(priv && "Private object not set.");
 
        try {
-               CallHistoryEntryProperties *callInfo = priv->getObject();
+               JSContextRef globalContext = priv->getContext();
+               CallHistoryEntryProperties *entryInfo = priv->getObject();
                Converter convert(context);
 
                if (JSStringIsEqualToUTF8CString(propertyName, STR_ENTRY_ID)) {
-                       return convert.toJSValueRef(callInfo->getEntryId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_ACCOUNT_ID)) {
-                       return convert.toJSValueRef(callInfo->getAccountId());
+                       return convert.toJSValueRef(entryInfo->getEntryId());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_SERVICE_ID)) {
+                       return convert.toJSValueRef(entryInfo->getServiceId());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CALL_TYPE)) {
-                       return convert.toJSValueRef(callInfo->getCallType());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_REMOTE_PARTY)) {
-                       return convert.toJSValueRef(callInfo->getRemoteParty());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CONTACT_ID)) {
-                       return convert.toJSValueRef(callInfo->getContactId());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CONTACT_DETAILS)) {
-                       return convert.toJSValueRef(callInfo->getContactDetails());
+                       return convert.toJSValueRef(entryInfo->getCallType());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_TAGS)) {
+                       return convert.toJSValueRef(entryInfo->getTags(), context);
+               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_REMOTE_PARTIES)) {
+                       return convert.toJSValueRef(entryInfo->getRemoteParties(), context);
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_FORWARDEDFROM)) {
-                       return convert.toJSValueRef(callInfo->getForwardedFrom());
+                       return TizenApis::Tizen1_0::JSRemoteParty::createJSObject(globalContext, (*(entryInfo->getForwardedFrom())));
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_START_TIME)) {
-                       return convert.toJSValueRef(callInfo->getStartTime());
+                       return convert.toJSValueRef(entryInfo->getStartTime());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DURATION)) {
-                       return convert.toJSValueRef(callInfo->getDuration());
+                       return convert.toJSValueRef(entryInfo->getDuration());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_END_REASON)) {
-                       return convert.toJSValueRef(callInfo->getEndReason());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_USED_CAPABILITIES)) {
-                       return convert.toJSValueRef(callInfo->getUsedCapabilities(), context);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_KIND)) {
-                       return convert.toJSValueRef(callInfo->getKind());
+                       return convert.toJSValueRef(entryInfo->getEndReason());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DIRECTION)) {
-                       return convert.toJSValueRef(callInfo->getDirection());
+                       return convert.toJSValueRef(entryInfo->getDirection());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_DURATION)) {
-                       return convert.toJSValueRef(callInfo->getDuration());
+                       return convert.toJSValueRef(entryInfo->getDuration());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_RECORDING)) {
-                       return convert.toJSValueRef(callInfo->getRecording(), context);
+                       return convert.toJSValueRef(entryInfo->getRecording(), context);
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_COST)) {
-                       return convert.toJSValueRef(callInfo->getCost());
+                       return convert.toJSValueRef(entryInfo->getCost());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_CURRENCY)) {
-                       return convert.toJSValueRef(callInfo->getCurrency());
+                       return convert.toJSValueRef(entryInfo->getCurrency());
                }
-       } catch(Commons::Exception) {
+       } catch(WrtDeviceApis::Commons::Exception) {
                LogWarning("trying to get incorrect value");
        }
        return JSValueMakeUndefined(context);
 }
 
+bool JSCallHistoryEntry::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       JSCallHistoryEntryPriv *priv = static_cast<JSCallHistoryEntryPriv*>(JSObjectGetPrivate(object));
+       assert(priv && "Private object not set.");
+
+       Converter converter(context);
+       try {
+               if (JSStringIsEqualToUTF8CString(propertyName, STR_DIRECTION)) {
+                       CallHistoryEntryProperties *entryInfo = priv->getObject();
+                       if (entryInfo != NULL) {
+                               ICallHistoryEntryPtr callHistoryEntry(CallHistoryFactory::getInstance().getCallHistoryEntryObject());
+                               std::string direction(converter.toString(value));
+
+                               if (callHistoryEntry != NULL) {
+                                       if((entryInfo->getDirection().compare("missed-new") == 0) && (direction.compare("missed") == 0)) {
+                                               callHistoryEntry->setMarkSeen(entryInfo->getEntryId());
+                                               entryInfo->setDirection("missed");
+                                       } else {
+                                               Throw(WrtDeviceApis::Commons::UnsupportedException);
+                                       }
+
+                                       return true;
+                               } else {
+                                       Throw(WrtDeviceApis::Commons::Exception);
+                               }
+                       } else {
+                               Throw(WrtDeviceApis::Commons::Exception);
+                       }
+               } else {
+                       Throw(WrtDeviceApis::Commons::UnsupportedException);
+               }
+       } catch(const WrtDeviceApis::Commons::UnsupportedException& ex) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported error");
+       } catch (const WrtDeviceApis::Commons::Exception& ex) {
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown error");
+       }
+
+       return false;
+}
 bool JSCallHistoryEntry::hasInstance(JSContextRef context,
        JSObjectRef constructor,
        JSValueRef possibleInstance,
index 651a29a..bd239f3 100755 (executable)
@@ -34,7 +34,7 @@ public:
        static const JSClassRef getClassRef();
 
        static JSObjectRef createJSObject(JSContextRef context,
-               const Api::Call::CallHistoryEntryProperties &callEntry);
+               const Api::Call::CallHistoryEntryProperties &entryInfo);
 
 private:
        static void initialize(JSContextRef context,
@@ -47,6 +47,12 @@ private:
                JSStringRef propertyName,
                JSValueRef* exception);
 
+       static bool setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception);
+
        static bool hasInstance(JSContextRef context,
                JSObjectRef constructor,
                JSValueRef possibleInstance,
diff --git a/src/standards/Tizen/Call/JSCallManager.cpp b/src/standards/Tizen/Call/JSCallManager.cpp
new file mode 100755 (executable)
index 0000000..e782a8b
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * 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/ICallManager.h>
+#include <API/Call/CallFactory.h>
+#include <API/Call/EventGetCallService.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h> 
+#include <Tizen/Common/SecurityExceptions.h>
+#include "JSCallManager.h"
+#include "JSCallHistory.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 JSCallManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSCallManager::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "call",
+       NULL,
+       m_property,
+       m_function,
+       initialize,
+       finalize,
+       NULL, //hasProperty,
+       NULL, //getProperty,
+       NULL, //setProperty,
+       NULL, //deleteProperty,
+       NULL, //getPropertyNames,
+       NULL,
+       NULL,
+       hasInstance,
+       NULL
+};
+
+JSStaticValue JSCallManager::m_property[] = {
+       { "history", getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSCallManager::m_function[] =
+{
+       { "isCallInProgress", JSCallManager::isCallInProgress, kJSPropertyAttributeNone },
+       { "getCallServices", JSCallManager::getCallServices, kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+const JSClassRef JSCallManager::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSCallManager::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+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;
+       }
+
+       LogDebug("JSCallManager::initialize ");
+}
+
+void JSCallManager::finalize(JSObjectRef object)
+{
+       JSCallManagerPriv* priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       delete priv;
+}
+
+JSValueRef JSCallManager::getProperty(JSContextRef context,
+       JSObjectRef object,
+       JSStringRef propertyName,
+       JSValueRef* exception)
+{
+       JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               return JSValueMakeUndefined(context);
+       }
+
+       JSContextRef globalContext = priv->getContext();
+       try {
+               Converter convert(context);
+               if(JSStringIsEqualToUTF8CString(propertyName, "history")) {
+                       return JSCallHistory::createJSObject(globalContext, object);
+               }
+       } catch(const WrtDeviceApis::Commons::Exception& ex) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, ex.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSCallManager::hasInstance(JSContextRef context, JSObjectRef constructor,
+       JSValueRef possibleInstance, JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+JSValueRef JSCallManager::isCallInProgress(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       JSCallManagerPriv *priv = static_cast<JSCallManagerPriv*>(JSObjectGetPrivate(thisObject));
+
+       JSContextRef gContext = priv->getContext();
+       Converter converter(context);
+
+       if (priv == NULL) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "private object is null");
+       }
+
+       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("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::UnsupportedException) {
+                               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::NOT_SUPPORTED_ERROR, "Not supported value");
+                       } 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());
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+}
+}
+
diff --git a/src/standards/Tizen/Call/JSCallManager.h b/src/standards/Tizen/Call/JSCallManager.h
new file mode 100755 (executable)
index 0000000..1f89ff4
--- /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. 
+ */
+
+
+#ifndef TIZENAPIS_TIZEN_JS_CALLMANAGER_H_
+#define TIZENAPIS_TIZEN_JS_CALLMANAGER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Call/ICallManager.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::ICallManagerPtr>::Type JSCallManagerPriv;
+
+class JSCallManager
+{
+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 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 isCallInProgress(JSContextRef context, JSObjectRef object,
+                       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[],
+                       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;
+
+       /**
+        * 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/JSCallService.cpp b/src/standards/Tizen/Call/JSCallService.cpp
new file mode 100755 (executable)
index 0000000..039bb79
--- /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/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.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[] = {
+       { "voicemailNumbers", 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, "voicemailNumbers")) {
+                       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->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
new file mode 100755 (executable)
index 0000000..fcc8224
--- /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. 
+ */
+
+
+#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
new file mode 100755 (executable)
index 0000000..311a232
--- /dev/null
@@ -0,0 +1,228 @@
+/*
+ * 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/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[] = {
+       { "subscriberNumbers", getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { "emergencyNumbers", 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, "subscriberNumbers")) {
+                       return convert.toJSValueRef(callService->getSubscriberNumbers(), globalContext);
+               } else if(JSStringIsEqualToUTF8CString(propertyName, "emergencyNumbers")) {
+                       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
new file mode 100755 (executable)
index 0000000..c3c0684
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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
+
diff --git a/src/standards/Tizen/Call/JSRemoteParty.cpp b/src/standards/Tizen/Call/JSRemoteParty.cpp
new file mode 100755 (executable)
index 0000000..2af67c5
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * 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 <memory>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <API/Call/RemoteParty.h>
+#include "JSRemoteParty.h"
+#include "Converter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace Api::Call;
+
+#define STR_REMOTE_PARTY               "remoteParty"
+#define STR_DISPLAY_NAME               "displayName"
+#define STR_CONTACT_ID                 "contactId"
+
+JSClassDefinition JSRemoteParty::m_classInfo = {
+       0,
+       kJSClassAttributeNone,
+       "remoteparty",
+       0,
+       m_property,
+       0,
+       initialize,
+       finalize,
+       NULL,     //HasProperty,
+       getProperty,
+       NULL,     //SetProperty,
+       NULL,     //DeleteProperty,
+       NULL,     //GetPropertyNames,
+       NULL,     //CallAsFunction,
+       NULL,     //CallAsConstructor,
+       hasInstance,
+       NULL,     //ConvertToType
+};
+
+JSStaticValue JSRemoteParty::m_property[] = {
+       { STR_REMOTE_PARTY, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_DISPLAY_NAME, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_CONTACT_ID, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSRemoteParty::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSRemoteParty::getClassInfo()
+{
+       return &m_classInfo;
+}
+
+JSClassRef JSRemoteParty::m_jsClassRef = JSClassCreate(JSRemoteParty::getClassInfo());
+
+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();
+       if (!priv) {
+               ThrowMsg(Commons::NullPointerException, "Can not new an object");
+       }
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSRemoteParty::initialize(JSContextRef context, JSObjectRef object)
+{
+}
+
+void JSRemoteParty::finalize(JSObjectRef object)
+{
+       JSRemotePartyPriv* priv = static_cast<JSRemotePartyPriv*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       delete priv;
+}
+
+JSValueRef JSRemoteParty::getProperty(JSContextRef context,
+       JSObjectRef object,
+       JSStringRef propertyName,
+       JSValueRef* exception)
+{
+       JSRemotePartyPriv *priv = static_cast<JSRemotePartyPriv*>(JSObjectGetPrivate(object));
+       assert(priv && "Private object not set.");
+
+       try {
+               RemoteParty* remoteParty = priv->getObject();
+               Converter convert(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());
+               }
+       } catch(Commons::Exception) {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSRemoteParty::hasInstance(JSContextRef context,
+       JSObjectRef constructor,
+       JSValueRef possibleInstance,
+       JSValueRef* exception)
+{
+       return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+}
+}
+
diff --git a/src/standards/Tizen/Call/JSRemoteParty.h b/src/standards/Tizen/Call/JSRemoteParty.h
new file mode 100755 (executable)
index 0000000..6478f1b
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * 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_REMOTEPARTY_H_
+#define TIZENAPIS_TIZEN_JS_REMOTEPARTY_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Call/RemoteParty.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<Api::Call::RemoteParty*>::Type JSRemotePartyPriv;
+
+class JSRemoteParty
+{
+public:
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context,
+               const Api::Call::RemoteParty &remoteParty);
+
+private:
+       static void initialize(JSContextRef context,
+               JSObjectRef object);
+
+       static void finalize(JSObjectRef object);
+
+       static JSValueRef getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception);
+
+       static bool hasInstance(JSContextRef context,
+               JSObjectRef constructor,
+               JSValueRef possibleInstance,
+               JSValueRef* exception);
+
+       static JSClassDefinition m_classInfo;
+
+       static JSStaticValue m_property[];
+
+       static JSClassRef m_jsClassRef;
+};
+} 
+}
+
+#endif
+
index 1f74f57..bab1be5 100755 (executable)
@@ -43,13 +43,16 @@ ResponseDispatcher& ResponseDispatcher::getInstance()
 
 ResponseDispatcher::ResponseDispatcher() :
        EventAnswerReceiver<Api::Call::EventFindCallHistory>(ThreadEnum::NULL_THREAD),
-       EventAnswerReceiver<Api::Call::EventRemoveBatch>(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)
 {
 }
 
 void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventFindCallHistoryPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
        Assert(NULL != data);
 
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
@@ -64,7 +67,7 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventFindCallHistoryP
                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");
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
                }
                data->callOnError(jsException);
        }
@@ -72,7 +75,7 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventFindCallHistoryP
 
 void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveBatchPtr& event)
 {
-       DPL::SharedPtr<JSCallbackManager> data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
        Assert(NULL != data);
 
        if (event->getExceptionCode() == WrtDeviceApis::Commons::ExceptionCodes::None) {
@@ -86,12 +89,81 @@ void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveBatchPtr&
                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");
+                       jsException = JSTizenExceptionFactory::makeErrorObject(data->getContext(), JSTizenException::UNKNOWN_ERROR, "Unknown error");
                }
                data->callOnError(jsException);
        }
 }
 
+void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventRemoveAllPtr& event)
+{
+       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       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);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventLaunchDialerPtr& event)
+{
+       LogDebug("Enter");
+       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       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);
+       }
+}
+
+void ResponseDispatcher::OnAnswerReceived(const Api::Call::EventSendUSSDPtr& event)
+{
+       LogDebug("Enter");
+
+       JSCallbackManagerPtr data = DPL::DynamicPointerCast<JSCallbackManager>(event->getPrivateData());
+       Assert(NULL != data);
+
+       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"));
+               }
+       } 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);
+       }
+}
 }
 } 
 
index 24a39c5..d5b0e85 100755 (executable)
 #include <Commons/EventReceiver.h>
 #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::EventRemoveBatch>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventRemoveAll>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventLaunchDialer>,
+       public WrtDeviceApis::Commons::EventAnswerReceiver<Api::Call::EventSendUSSD>
 {
 public:
        static ResponseDispatcher& getInstance();
 
        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 6f0a7b7..90fe78b 100755 (executable)
        </api-feature>
 
        <api-feature>
+               <name>http://tizen.org/api/call.simple</name>
+               <device-capability>call.simple</device-capability>
+       </api-feature>
+
+       <api-feature>
                <name>http://tizen.org/api/call.history</name>
                <device-capability>call.history.read</device-capability>
                <device-capability>call.history.write</device-capability>
index e51423e..98f49fb 100755 (executable)
@@ -24,6 +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_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"
 namespace TizenApis {
 namespace Tizen1_0 {
 
+const char* CALL_DEVICE_CAP_SIMPLE = "call.simple";
 const char* CALL_HISTORY_DEVICE_CAP_READ = "call.history.read";
 const char* CALL_HISTORY_DEVICE_CAP_WRITE = "call.history.write";
 
 const char* CALL_HISTORY_FUNCTION_API_FIND = "find";
 const char* CALL_HISTORY_FUNCTION_API_REMOVE = "remove";
 const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH = "removeBatch";
+const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL = "removeAll";
+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();
 
@@ -48,11 +59,15 @@ 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_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_HISTORY_READ);
        ACE_ADD_DEVICE_CAP(DEVICE_LIST_CALL_HISTORY_READ, DEVICE_CAP_CALL_HISTORY_READ);
 
@@ -60,10 +75,15 @@ 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_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_HISTORY_READ_WRITE);
        ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_HISTORY_READ_WRITE, FEATURE_CALL);
        ACE_ADD_API_FEATURE(CALL_FEATURES_CALL_HISTORY_READ_WRITE, FEATURE_CALL_HISTORY);
@@ -106,6 +126,62 @@ static WrtDeviceApis::Commons::FunctionMapping createCallFunctions()
 
        CallMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVE_BATCH, removeBatchFunc));
 
+       AceFunction removeAllFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_REMOVE_ALL,
+                       CALL_HISTORY_FUNCTION_API_REMOVE_ALL,
+                       CALL_FEATURES_CALL_HISTORY_WRITE,
+                       EMPTY_DEVICE_LIST);
+
+       CallMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVE_ALL, removeAllFunc));
+
+       AceFunction addListenerFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_ADD_LISTENER,
+                       CALL_HISTORY_FUNCTION_API_ADDLISTENER,
+                       CALL_FEATURES_CALL_HISTORY_READ_WRITE,
+                       EMPTY_DEVICE_LIST);
+
+       CallMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_ADDLISTENER, addListenerFunc));
+
+       AceFunction removeListenerFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_REMOVE_LISTENER,
+                       CALL_HISTORY_FUNCTION_API_REMOVELISTENER,
+                       CALL_FEATURES_CALL_HISTORY_READ_WRITE,
+                       EMPTY_DEVICE_LIST);
+
+       CallMapping.insert(std::make_pair(CALL_HISTORY_FUNCTION_API_REMOVELISTENER, removeListenerFunc));
+
+       AceFunction isCallInProgressFunc = ACE_CREATE_FUNCTION(
+                       FUNCTION_IS_CALL_IN_PROGRESS,
+                       CALL_FUNCTION_API_ISCALLINPROGRESS,
+                       CALL_FEATURES_CALL_SIMPLE,
+                       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 03de843..6a3b5c6 100755 (executable)
@@ -26,6 +26,14 @@ namespace Tizen1_0 {
 extern const char* CALL_HISTORY_FUNCTION_API_FIND;
 extern const char* CALL_HISTORY_FUNCTION_API_REMOVE;
 extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_BATCH;
+extern const char* CALL_HISTORY_FUNCTION_API_REMOVE_ALL;
+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);
 
@@ -35,7 +43,7 @@ DECLARE_FUNCTION_GETTER(Call);
 namespace WrtDeviceApis {
 namespace Commons {
 
-#define CALL_HISTORY_CHECK_ACCESS(globalContext, functionName) \
+#define CALL_CHECK_ACCESS(globalContext, functionName) \
     WrtDeviceApis::Commons::aceCheckAccess<AceFunctionGetter, \
     WrtDeviceApis::Commons::DefaultArgsVerifier<> >(                \
         globalContext,                     \
index aa17fe0..385c30f 100755 (executable)
 
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
-#include <Commons/WrtWrapper/WrtWrappersMgr.h>
-#include <Commons/Exception.h>
-#include "JSCallApi.h"
+#include "JSCallManager.h"
 
 #define CALL "call"
 
-using namespace WrtDeviceApis::Commons;
-
 void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface) {
-       Try {
-               WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().registerWrapper(widgetId,context,interface);
-       } Catch(Exception) {
-               LogError("Wrt wrapper registration failed");
-       }
 }
 
 void on_widget_stop_callback(int widgetId) {
-       WrtDeviceApis::Commons::WrtWrappersMgr::getInstance().removeWrapper(widgetId);
 }
 
 PLUGIN_ON_WIDGET_START(on_widget_start_callback)
@@ -44,7 +34,7 @@ PLUGIN_CLASS_MAP_BEGIN
     PLUGIN_CLASS_MAP_ADD_CLASS(
         WRT_JS_EXTENSION_OBJECT_TIZEN,
         CALL,
-        TizenApis::Tizen1_0::JSCallApi::getClassRef(),
+        TizenApis::Tizen1_0::JSCallManager::getClassRef(),
         NULL)
 PLUGIN_CLASS_MAP_END
 
diff --git a/src/standards/Tizen/Common/JSGlobalContextFactory.cpp b/src/standards/Tizen/Common/JSGlobalContextFactory.cpp
new file mode 100644 (file)
index 0000000..b896083
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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
new file mode 100644 (file)
index 0000000..631cf40
--- /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.
+ */
+
+/**
+ * @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 b809943..51ae014 100755 (executable)
@@ -35,10 +35,16 @@ set(SRCS
   JSContactWebSiteArray.cpp
   plugin_initializer.cpp
   plugin_config.cpp
+  ../Tizen/JSAttributeFilter.cpp
+  ../Tizen/JSAttributeRangeFilter.cpp
+  ../Tizen/JSCompositeFilter.cpp
+  ../Tizen/JSAbstractFilterArray.cpp
+  ../Tizen/JSSortMode.cpp
   ../Tizen/FilterConverter.cpp
   ../Common/JSTizenException.cpp
   ../Common/TizenExceptionData.cpp
   ../Common/JSTizenExceptionFactory.cpp
+  ../Common/JSGlobalContextFactory.cpp
 )
 
 include_directories(
index a46088c..c42370b 100755 (executable)
@@ -37,6 +37,12 @@ const char* ACCESS_MODE_READ = "r";
 const char* ACCESS_MODE_APPEND = "a";
 const char* ACCESS_MODE_WRITE = "w";
 const char* ACCESS_MODE_READ_WRITE = "rw";
+const char* STORAGE_TYPE_STATE_MOUNTED = "MOUNTED";
+const char* STORAGE_TYPE_STATE_REMOVED = "REMOVED";
+const char* STORAGE_TYPE_STATE_UNMOUNTABLE = "REMOVED";
+const char* STORAGE_TYPE_INTERNAL = "INTERNAL";
+const char* STORAGE_TYPE_EXTERNAL = "EXTERNAL";
+
 
 const char* ENCODINGS[] = {
     TizenApis::Tizen1_0::Encodings::UTF8,
@@ -239,5 +245,32 @@ std::string Converter::toEncoding(const JSValueRef& arg)
        }
        ThrowMsg(Commons::InvalidArgumentException, "Invalid encoding");
 }
+JSValueRef Converter::toStorageType(const short type)
+{
+       switch (type) 
+       {
+               case Api::Filesystem::StorageProperties::STATE_MOUNTED:
+                       return toJSValueRef(STORAGE_TYPE_STATE_MOUNTED);
+               case Api::Filesystem::StorageProperties::STATE_REMOVED:
+                       return toJSValueRef(STORAGE_TYPE_STATE_REMOVED);
+               case Api::Filesystem::StorageProperties::STATE_UNMOUNTABLE:
+                       return toJSValueRef(STORAGE_TYPE_STATE_UNMOUNTABLE);
+       }
+       ThrowMsg(Commons::InvalidArgumentException, "Invalid storage type");
+}
+
+JSValueRef Converter::toStorageState(const short state)
+{
+       switch (state) 
+       {
+               case Api::Filesystem::StorageProperties::TYPE_INTERNAL:
+                       return toJSValueRef(STORAGE_TYPE_INTERNAL);
+               case Api::Filesystem::StorageProperties::TYPE_EXTERNAL:
+                       return toJSValueRef(STORAGE_TYPE_EXTERNAL);
+       }
+       ThrowMsg(Commons::InvalidArgumentException, "Invalid storage state");
+}
+
+
 }
 }
index e54f924..6c2bd9e 100755 (executable)
@@ -60,6 +60,9 @@ public:
        Api::Filesystem::AccessMode toAccessMode(const JSValueRef& arg);
 
        std::string toEncoding(const JSValueRef& arg);
+       
+       JSValueRef toStorageType(const short type);
+       JSValueRef toStorageState(const short state);
 };
 
 typedef WrtDeviceApis::CommonsJavaScript::ConverterFactory<Converter> ConverterFactory;
index bd4acdd..63b0e30 100755 (executable)
@@ -393,7 +393,7 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                Api::Filesystem::IPathPtr path = Utils::fromVirtualPath(globalContext, converter->toString(argv[0]));
                std::string virtualPath = converter->toString(argv[0]);
 
-               int permissions = Api::Filesystem::PERM_READ;
+               int permissions = Api::Filesystem::PERM_READ | Api::Filesystem::PERM_WRITE;
 
                if (argc > 3) {
                        if (!JSValueIsNull(context, argv[3]) && !JSValueIsUndefined(context, argv[3])) {
@@ -402,10 +402,7 @@ JSValueRef JSFilesystemManager::resolve(JSContextRef context,
                                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid values error");
                                } else if ("r" == perms) {
                                        permissions = Api::Filesystem::PERM_READ;
-                               } else {
-                                       permissions = Api::Filesystem::PERM_READ | Api::Filesystem::PERM_WRITE;
-                               }
-                               
+                               } 
                        }
                }
 
index 5fa776d..c43aa84 100755 (executable)
 #include <memory>
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/JSUtils.h>
-#include <CommonsJavaScript/Converter.h>
+//#include <CommonsJavaScript/Converter.h>
 #include <CommonsJavaScript/JSDOMExceptionFactory.h>
 #include <API/Filesystem/StorageProperties.h>
 #include "JSStorage.h"
+#include "Converter.h"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -36,11 +37,11 @@ namespace {
 const char* STR_STORAGE_LABEL = "label";
 const char* STR_STORAGE_TYPE = "type";
 const char* STR_STORAGE_STATE = "state";
-const char* STR_TYPE_INTERNAL = "TYPE_INTERNAL";
-const char* STR_TYPE_EXTERNAL = "TYPE_EXTERNAL";
-const char* STR_STATE_MOUNTED = "STATE_MOUNTED";
-const char* STR_STATE_REMOVED = "STATE_REMOVED";
-const char* STR_STATE_UNMOUNTABLE = "STATE_UNMOUNTABLE";
+const char* STR_TYPE_INTERNAL = "INTERNAL";
+const char* STR_TYPE_EXTERNAL = "EXTERNAL";
+const char* STR_STATE_MOUNTED = "MOUNTED";
+const char* STR_STATE_REMOVED = "REMOVED";
+const char* STR_STATE_UNMOUNTABLE = "UNMOUNTABLE";
 } //private namespace
 
 JSClassDefinition JSStorage::m_classInfo = {
@@ -67,11 +68,11 @@ JSStaticValue JSStorage::m_property[] = {
        { STR_STORAGE_LABEL, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_STORAGE_TYPE, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_STORAGE_STATE, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_TYPE_INTERNAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
+/*     { STR_TYPE_INTERNAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_TYPE_EXTERNAL, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_STATE_MOUNTED, getProperty, NULL, kJSPropertyAttributeReadOnly },
        { STR_STATE_REMOVED, getProperty, NULL, kJSPropertyAttributeReadOnly },
-       { STR_STATE_UNMOUNTABLE, getProperty, NULL, kJSPropertyAttributeReadOnly },
+       { STR_STATE_UNMOUNTABLE, getProperty, NULL, kJSPropertyAttributeReadOnly },*/
        { 0, 0, 0, 0 }
 };
 
@@ -135,10 +136,11 @@ JSValueRef JSStorage::getProperty(JSContextRef context,
                if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_LABEL)) {
                        return convert.toJSValueRef(storages->getLabel());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_TYPE)) {
-                       return convert.toJSValueRef(storages->getType());
+                       return convert.toStorageType(storages->getType());
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STORAGE_STATE)) {
-                       return convert.toJSValueRef(storages->getState());
-               } else if (JSStringIsEqualToUTF8CString(propertyName, STR_TYPE_INTERNAL)) {
+                       return convert.toStorageState(storages->getState());
+               } 
+               /*else if (JSStringIsEqualToUTF8CString(propertyName, STR_TYPE_INTERNAL)) {
                        return convert.toJSValueRef(TYPE_INTERNAL);
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_TYPE_EXTERNAL)) {
                        return convert.toJSValueRef(TYPE_EXTERNAL);
@@ -148,7 +150,7 @@ JSValueRef JSStorage::getProperty(JSContextRef context,
                        return convert.toJSValueRef(STATE_REMOVED);
                } else if (JSStringIsEqualToUTF8CString(propertyName, STR_STATE_UNMOUNTABLE)) {
                        return convert.toJSValueRef(STATE_UNMOUNTABLE);
-               }
+               }*/
        } Catch(Commons::Exception) {
                LogWarning("trying to get incorrect value");
        }
diff --git a/src/standards/Tizen/Log/CMakeLists.txt b/src/standards/Tizen/Log/CMakeLists.txt
new file mode 100644 (file)
index 0000000..0d361f0
--- /dev/null
@@ -0,0 +1,26 @@
+set(TARGET_NAME       "wrt-plugins-tizen-1.0-tizenlog")
+set(DESTINATION_NAME  "tizen-1.0-tizenlog")
+
+set(SRCS_DEVICEINTERACTION
+    JSTizenLog.cpp    
+    plugin_initializer.cpp
+
+)
+
+set(SRCS
+    ${SRCS_DEVICEINTERACTION}
+)
+
+include_directories(
+    ${INCLUDES_PLATFORM_IMPLEMENTATION_HAPTICS}
+       ${INCLUDES_PLATFORM_IMPLEMENTATION_POWER}
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+
+target_link_libraries(${TARGET_NAME}
+    ${LIBS_COMMON}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
diff --git a/src/standards/Tizen/Log/JSTizenLog.cpp b/src/standards/Tizen/Log/JSTizenLog.cpp
new file mode 100755 (executable)
index 0000000..56bc60b
--- /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. 
+ */
+
+
+/**
+ * @file        JSTizenLog
+ * @author      Sang-tai Kim(sangtai.kim@samsung.com)
+ * @version     0.1
+ */
+
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include <CommonsJavaScript/Utils.h>
+
+#include "JSTizenLog.h"
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN"
+
+#define EXCEPTION_COLOR    "\033[1;31;40m"  //bold and red
+#define ASSERT_COLOR       "\033[1;31;40m"  //bold and red
+
+#define GREEN_COLOR        "\033[0;32;40m"  //normal and green
+#define NORMAL_COLOR       "\033[0m"        //system default
+#define RED_COLOR          "\033[0;31;40m"  //normal and red
+#define YELLOW_COLOR       "\033[0;33m"     //normal and yellow
+#define BLUE_COLOR         "\033[0;34m"     //normal and blue
+#define MAGENTA_COLOR      "\033[0;35;40m"  //normal and magenta
+#define CYAN_COLOR         "\033[0;36;40m"  //normal and cyan
+
+#define TIZEN_DEBUG(FM,ARG...)   {LOGD("%s[%s]%s" FM, GREEN_COLOR,  __FUNCTION__, NORMAL_COLOR, ##ARG);}
+#define TIZEN_INFO(FM,ARG...)    {LOGI("%s[%s]%s" FM, CYAN_COLOR,   __FUNCTION__, NORMAL_COLOR, ##ARG);}
+#define TIZEN_WANING(FM,ARG...)  {LOGW("%s[%s]%s" FM, YELLOW_COLOR, __FUNCTION__, NORMAL_COLOR, ##ARG);}
+#define TIZEN_ERROR(FM,ARG...)   {LOGE("%s[%s]%s" FM, RED_COLOR,    __FUNCTION__, NORMAL_COLOR, ##ARG);}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis;
+
+JSClassDefinition JSTizenLog::m_classInfo =
+{
+    0,
+    kJSClassAttributeNone,
+    "log",
+    0,
+    NULL,
+    m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //DeleteProperty,
+    NULL, //GetPropertyNames,
+    NULL, //CallAsFunction,
+    NULL, //CallAsConstructor,
+    NULL, //HasInstance,
+    NULL, //ConvertToType
+};
+
+const JSClassRef JSTizenLog::getClassRef() {
+    if (!m_jsClassRef) {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSTizenLog::getClassInfo() {
+    return &m_classInfo;
+}
+
+JSStaticFunction JSTizenLog::m_function[] = {
+    { "debug",    JSTizenLog::logDebug,   kJSPropertyAttributeNone},
+    { "info",     JSTizenLog::logInfo,    kJSPropertyAttributeNone},
+    { "warning",  JSTizenLog::logWarning, kJSPropertyAttributeNone},
+    { "error",    JSTizenLog::logError,   kJSPropertyAttributeNone},
+    { 0, 0, 0 }
+};
+
+JSClassRef JSTizenLog::m_jsClassRef =
+  JSClassCreate(JSTizenLog::getClassInfo());
+
+
+void JSTizenLog::initialize(JSContextRef context, JSObjectRef object) {
+//    TIZEN_DEBUG("<<<");
+}
+
+void JSTizenLog::finalize(JSObjectRef object) {
+//    TIZEN_DEBUG("<<<");
+}
+
+JSValueRef JSTizenLog::logDebug(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argc, const JSValueRef argv[],
+               JSValueRef* exception) {
+
+       CommonsJavaScript::Converter converter(context);
+       std::string pattern = converter.toString(argv[0]);
+
+       TIZEN_DEBUG("[%s]", pattern.c_str());
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSTizenLog::logInfo(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argc, const JSValueRef argv[],
+               JSValueRef* exception) {
+
+       CommonsJavaScript::Converter converter(context);
+       std::string pattern = converter.toString(argv[0]);
+
+       TIZEN_INFO("[%s]", pattern.c_str());
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSTizenLog::logWarning(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argc, const JSValueRef argv[],
+               JSValueRef* exception) {
+
+       CommonsJavaScript::Converter converter(context);
+       std::string pattern = converter.toString(argv[0]);
+
+       TIZEN_WANING("[%s]", pattern.c_str());
+
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSTizenLog::logError(JSContextRef context, JSObjectRef object,
+               JSObjectRef thisObject, size_t argc, const JSValueRef argv[],
+               JSValueRef* exception) {
+
+       CommonsJavaScript::Converter converter(context);
+       std::string pattern = converter.toString(argv[0]);
+
+       TIZEN_ERROR("[%s]", pattern.c_str());
+
+       return JSValueMakeUndefined(context);
+}
+
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Log/JSTizenLog.h b/src/standards/Tizen/Log/JSTizenLog.h
new file mode 100644 (file)
index 0000000..aa18dd4
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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        JSTizenLog.h
+ * @author      Sang-tai Kim(sangtai.kim@samsung.com)
+ * @version     0.1
+ */
+
+
+#ifndef _JS_TIZEN_LOG_H_
+#define _JS_TIZEN_LOG_H_
+
+#include <JavaScriptCore/JavaScript.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class DeviceController;
+
+/**
+ * @class JSTizenLog
+ * @brief This class is javascript extenstion
+ *
+ */
+class JSTizenLog
+{
+public:
+    static const JSClassDefinition* getClassInfo();
+
+    /**
+     * Gets class definition reference.
+     * @remarks New instance of JSClassRef is created (only once) if none was
+     * @remarks set before.
+     * @return Class reference.
+     */
+    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);
+
+    /**
+     * This structure describes a statically declared function.
+     */
+    static JSStaticFunction m_function[];
+
+    /**
+     * This structure contains properties and callbacks that define a type of object.
+     */
+    static JSClassDefinition m_classInfo;
+
+    /**
+     * Class definition reference.
+     */
+
+    static JSClassRef m_jsClassRef;
+
+    static JSValueRef logDebug(JSContextRef context,
+                             JSObjectRef object,
+                             JSObjectRef thisObject,
+                             size_t argc,
+                             const JSValueRef argv[],
+                             JSValueRef* exception);
+
+    static JSValueRef logInfo(JSContextRef context,
+                                 JSObjectRef object,
+                                 JSObjectRef thisObject,
+                                 size_t argc,
+                                 const JSValueRef argv[],
+                                 JSValueRef* exception);
+
+    static JSValueRef logWarning(JSContextRef context,
+                                 JSObjectRef object,
+                                 JSObjectRef thisObject,
+                                 size_t argc,
+                                 const JSValueRef argv[],
+                                 JSValueRef* exception);
+
+    static JSValueRef logError(JSContextRef context,
+                                 JSObjectRef object,
+                                 JSObjectRef thisObject,
+                                 size_t argc,
+                                 const JSValueRef argv[],
+                                 JSValueRef* exception);
+
+};
+
+}
+
+}
+
+#endif //  _JS_TIZEN_LOG_H_
diff --git a/src/standards/Tizen/Log/config.xml b/src/standards/Tizen/Log/config.xml
new file mode 100644 (file)
index 0000000..fe6fa61
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+    <library-name>libwrt-plugins-tizen-1.0-tizenlog.so</library-name>
+    <feature-install-uri>device.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>
+
+    <feature-set name="http://tizen.org/api/log">
+        <api-feature-ref name="http://tizen.org/api/log"/>
+    </feature-set>
+
+    <api-feature>
+        <name>http://tizen.org/api/log</name>
+        <Object name="log">
+            <Function name="debug"/>
+            <Function name="info"/>
+            <Function name="warning"/>
+            <Function name="error"/>
+        </Object>
+    </api-feature>
+</plugin-properties>
diff --git a/src/standards/Tizen/Log/plugin_initializer.cpp b/src/standards/Tizen/Log/plugin_initializer.cpp
new file mode 100644 (file)
index 0000000..0eafde3
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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 "JSTizenLog.h"
+
+#define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
+
+void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
+{
+    LogDebug("[TizenLog] on_widget_start_callback ("<<widgetId<<")");
+}
+
+void on_widget_stop_callback(int widgetId)
+{
+    LogDebug("[TizenLog] on_widget_stop_callback ("<<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, "log",
+      TizenApis::Tizen1_0::JSTizenLog::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_END
diff --git a/src/standards/Tizen/Mediacontent/CMakeLists.txt b/src/standards/Tizen/Mediacontent/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..216e70d
--- /dev/null
@@ -0,0 +1,40 @@
+set(TARGET_NAME "wrt-plugins-tizen-1.0-mediacontent") 
+set(DESTINATION_NAME  "tizen-1.0-mediacontent")
+include_directories(${INCLUDES_PLATFORM_IMPLEMENTATION_MEDIACONTENT})
+
+set(SRCS  
+  ${SRCS_PLATFORM_API_MEDIACONTENT}
+  ${SRCS_PLATFORM_IMPLEMENTATION_MEDIACONTENT}
+  ${SRCS_PLATFORM_API_WRT_WRAPPER}
+  ${SRCS_PLATFORM_API_FILTER}
+  ../Tizen/FilterConverter.cpp
+  ../Tizen/JSAttributeFilter.cpp
+  ../Tizen/JSAttributeRangeFilter.cpp
+  ../Tizen/JSCompositeFilter.cpp
+  ../Tizen/JSAbstractFilterArray.cpp
+  ../Tizen/JSSortMode.cpp
+  ../Common/JSGlobalContextFactory.cpp
+  ../Common/JSTizenException.cpp
+  ../Common/TizenExceptionData.cpp
+  ../Common/JSTizenExceptionFactory.cpp
+  JSMediacontent.cpp
+  JSFolder.cpp
+  JSMedia.cpp
+  JSImage.cpp
+  JSVideo.cpp
+  JSAudio.cpp
+  JSMediaLyrics.cpp
+  JSMediacontentManager.cpp
+  MediacontentController.cpp
+  plugin_initializer.cpp
+  MediaConverter.cpp
+)
+
+add_library(${TARGET_NAME} SHARED ${SRCS})
+target_link_libraries(${TARGET_NAME}
+  ${LIBS_PLATFORM_IMPLEMENTATION_MEDIACONTENT}
+  ${LIBS_COMMON}
+)
+
+INSTALL(TARGETS ${TARGET_NAME} LIBRARY DESTINATION ${DESTINATION_NAME})
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/config.xml DESTINATION ${DESTINATION_NAME})
diff --git a/src/standards/Tizen/Mediacontent/JSAudio.cpp b/src/standards/Tizen/Mediacontent/JSAudio.cpp
new file mode 100644 (file)
index 0000000..af87666
--- /dev/null
@@ -0,0 +1,457 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+
+#include "JSMediacontent.h"
+#include "JSAudio.h"
+#include "MediaConverter.h"
+
+
+#define TIZEN_MEDIACONTENT_AUDIO_ATTRIBUTENAME         "Audio"
+#define TIZEN_MEDIACONTENT_AUDIO_ALBUM                         "album"
+#define TIZEN_MEDIACONTENT_AUDIO_GENRE                         "genres"
+#define TIZEN_MEDIACONTENT_AUDIO_ARTIST                                "artists"
+#define TIZEN_MEDIACONTENT_AUDIO_COMPOSER                      "composers"
+#define TIZEN_MEDIACONTENT_AUDIO_LYIRICS                       "lyrics"
+#define TIZEN_MEDIACONTENT_AUDIO_COPYRIGHT                     "copyright"
+#define TIZEN_MEDIACONTENT_AUDIO_BITRATE                       "bitrate"
+#define TIZEN_MEDIACONTENT_AUDIO_TRACKNUM                      "trackNumber"
+#define TIZEN_MEDIACONTENT_AUDIO_DURATION                      "duration"
+#define TIZEN_MEDIACONTENT_AUDIO_PLAYEDCOUNT           "playedCount"   
+#define TIZEN_MEDIACONTENT_AUDIO_PLAYEDTIME                    "playedTime"    
+#define TIZEN_MEDIACONTENT_AUDIO_SIZE                          "size"  
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Mediacontent;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+JSClassDefinition JSAudio::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       TIZEN_MEDIACONTENT_AUDIO_ATTRIBUTENAME,
+       JSMedia::getClassRef(),
+       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 JSAudio::m_property[] =
+{
+       { TIZEN_MEDIACONTENT_AUDIO_ALBUM, getPropertyAlbum, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_ARTIST, getPropertyArtist, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_GENRE, getPropertyGenre, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_COMPOSER , getPropertyComposer, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_COPYRIGHT, getPropertyCopyright, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_LYIRICS, getPropertyLyrics, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_AUDIO_BITRATE, getPropertyBitrate, NULL, kJSPropertyAttributeReadOnly},    
+       { TIZEN_MEDIACONTENT_AUDIO_TRACKNUM, getPropertyTrackNum, NULL, kJSPropertyAttributeReadOnly},  
+       { TIZEN_MEDIACONTENT_AUDIO_DURATION, getPropertyDuration, NULL, kJSPropertyAttributeReadOnly},  
+       { TIZEN_MEDIACONTENT_AUDIO_PLAYEDCOUNT, getPropertyPlayedCount, setPropertyPlayCount, kJSPropertyAttributeNone},  
+       { TIZEN_MEDIACONTENT_AUDIO_PLAYEDTIME, getPropertyPlayedTime, setPropertyPlayedTime, kJSPropertyAttributeNone},  
+       { TIZEN_MEDIACONTENT_AUDIO_SIZE, getPropertySize, NULL, kJSPropertyAttributeReadOnly},          
+       { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSAudio::m_jsClassRef = JSClassCreate(JSAudio::getClassInfo());
+
+void JSAudio::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    AudioPrivObject *priv = static_cast<AudioPrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) 
+    {
+        MediacontentAudioPtr privateData(new MediacontentAudio());
+        priv = new AudioPrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("new event is created" );
+    }
+    else {
+        LogDebug("private object already exists");
+    }
+}
+
+void JSAudio::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+       AudioPrivObject *priv =  static_cast<AudioPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSAudio::getClassRef()
+{
+       LogDebug("JSAudio::getClassRef()");
+
+    if (!m_jsClassRef) 
+    {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSAudio::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+
+MediacontentAudioPtr JSAudio::getAudioObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    AudioPrivObject *priv = static_cast<AudioPrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) 
+    {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentAudioPtr result = priv->getObject();
+    if (!result) 
+    {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+                                       
+JSValueRef JSAudio::getPropertyAlbum(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioAlbum());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSAudio::getPropertyArtist(
+                               JSContextRef context,
+                               JSObjectRef object,
+                               JSStringRef propertyName,
+                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+       Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioArtist());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSAudio::getPropertyGenre(
+                               JSContextRef context,
+                       JSObjectRef object, 
+                       JSStringRef propertyName, 
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioGenre());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSAudio::getPropertyComposer(
+                               JSContextRef context,
+                       JSObjectRef object, 
+                       JSStringRef propertyName, 
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioComposer());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertyCopyright(
+                               JSContextRef context,
+                       JSObjectRef object, 
+                       JSStringRef propertyName, 
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioCopyright());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertyLyrics(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+               MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
+               //MediaConverter converter(globalContext);
+
+        MediacontentAudioPtr event = getAudioObject(object);
+        //Todo. Lyrics
+        return converter->toJSValueRef(event->getAudioLyrics());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertyBitrate(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioBitrate());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertyTrackNum(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioTrackNum());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertyDuration(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioDuration());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSAudio::getPropertyPlayedCount(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioPlayCount());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSAudio::getPropertyPlayedTime(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioPlayedTime());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAudio::getPropertySize(
+                               JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        return converter.toJSValueRef(event->getAudioSize());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+bool JSAudio::setPropertyPlayedTime(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        int rating = converter.toLong(value);
+        event->setAudioPlayedTime(rating);
+        return true;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
+    return false;
+
+
+}
+bool JSAudio::setPropertyPlayCount(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentAudioPtr event = getAudioObject(object);
+        int rating = converter.toInt(value);
+        event->setAudioPlayCount(rating);
+        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/Mediacontent/JSAudio.h b/src/standards/Tizen/Mediacontent/JSAudio.h
new file mode 100644 (file)
index 0000000..693dd9c
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+* 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_AUDIO_H_
+#define _JS_TIZEN_AUDIO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+#include <API/Mediacontent/MediacontentAudio.h>
+#include "JSMedia.h"
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<MediacontentAudioPtr, NoOwnership> AudioPrivObject;
+
+class JSAudio
+{
+public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static const JSClassRef getClassRef();
+
+       static Api::Mediacontent::MediacontentAudioPtr getAudioObject(JSObjectRef object);
+
+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  getPropertyAlbum(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyArtist(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyGenre(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyComposer(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+       static JSValueRef       getPropertyLyrics(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+    static JSValueRef  getPropertyCopyright(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyBitrate(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyTrackNum(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+    
+    static JSValueRef  getPropertyDuration(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);    
+
+       static bool                     setPropertyPlayCount(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                   JSValueRef value,
+                                               JSValueRef* exception);  
+
+    static JSValueRef  getPropertyPlayedCount(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);    
+
+       static bool                     setPropertyPlayedTime(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                   JSValueRef value,
+                                               JSValueRef* exception);  
+
+    static JSValueRef  getPropertyPlayedTime(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);    
+
+    static JSValueRef  getPropertySize(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);                 
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_AUDIO_H_ */
diff --git a/src/standards/Tizen/Mediacontent/JSFolder.cpp b/src/standards/Tizen/Mediacontent/JSFolder.cpp
new file mode 100644 (file)
index 0000000..7d43980
--- /dev/null
@@ -0,0 +1,367 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+
+#include <API/Mediacontent/IMediacontent.h>
+#include <API/Mediacontent/MediacontentFactory.h>
+//#include <API/Mediacontent/IEventFolderFindMedia.h>
+
+
+#include "MediacontentController.h"
+#include "JSMediacontent.h"
+#include "JSFolder.h"
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+#define TIZEN_MEDIACONTENT_FOLDER_ATTRIBUTENAME        "Folder"
+#define TIZEN_MEDIACONTENT_FOLDER_UID                          "id"
+#define TIZEN_MEDIACONTENT_FOLDER_NAME                         "title"
+#define TIZEN_MEDIACONTENT_FOLDER_PATH                         "folderUrl"
+#define TIZEN_MEDIACONTENT_FOLDER_STORAGE_TYPE         "storageType"
+#define TIZEN_MEDIACONTENT_FOLDER_MODIFIEDDATE         "modifiedDate"
+#define TIZEN_MEDIACONTENT_FOLDER_MEDIAID                      "mediaItems"
+
+
+JSClassDefinition JSFolder::m_classInfo =
+{
+    0,
+    kJSClassAttributeNone,
+    TIZEN_MEDIACONTENT_FOLDER_ATTRIBUTENAME,
+    0,
+    m_property,
+    m_function, //    m_function,
+    initialize,
+    finalize,
+    NULL, //hasProperty,
+    NULL, //getProperty,
+    NULL, //setProperty,
+    NULL, //DeleteProperty,
+    NULL, //GetPropertyNames,
+    NULL, //CallAsFunction,
+    NULL, //CallAsConstructor,
+    NULL, //HasInstance,
+    NULL  //ConvertToType
+};
+
+JSStaticValue JSFolder::m_property[] =
+{
+    //FolderProperties
+    { TIZEN_MEDIACONTENT_FOLDER_UID, getPropertyId, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_FOLDER_NAME, getPropertyName, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_FOLDER_PATH, getPropertyPath, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_FOLDER_STORAGE_TYPE, getPropertyStorageType, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_FOLDER_MODIFIEDDATE, getPropertyModifiedDate, NULL, kJSPropertyAttributeReadOnly}, 
+    { TIZEN_MEDIACONTENT_FOLDER_MEDIAID, getPropertyMediaId, NULL, kJSPropertyAttributeReadOnly}, 
+     { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSFolder::m_function[] =
+{
+    { 0, 0, 0 }
+};
+
+
+JSClassRef JSFolder::m_jsClassRef = JSClassCreate(JSFolder::getClassInfo());
+
+void JSFolder::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    FolderPrivObject *priv = static_cast<FolderPrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) 
+       {
+        MediacontentFolderPtr privateData(new MediacontentFolder());
+        priv = new FolderPrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("new event is created" );
+    }
+    else 
+       {
+        LogDebug("private object already exists");
+    }
+}
+
+
+void JSFolder::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+    FolderPrivObject *priv = static_cast<FolderPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+
+
+const JSClassRef JSFolder::getClassRef()
+{
+    if (!m_jsClassRef) 
+       {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSFolder::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+
+MediacontentFolderPtr JSFolder::getFolderObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    FolderPrivObject *priv = static_cast<FolderPrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentFolderPtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+
+
+JSValueRef JSFolder::getPropertyId(
+               JSContextRef context, 
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+
+        return converter.toJSValueRef(folder->getFolderUUID());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+                                       
+JSValueRef JSFolder::getPropertyName(
+               JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+        return converter.toJSValueRef(folder->getFolderName());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSFolder::getPropertyPath(
+               JSContextRef context,
+           JSObjectRef object, 
+           JSStringRef propertyName, 
+           JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+        return converter.toJSValueRef(folder->getFolderPath());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSFolder::getPropertyStorageType(
+               JSContextRef context,
+           JSObjectRef object,
+           JSStringRef propertyName,
+           JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+        return converter.toJSValueRef(folder->getFolderStorageType());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSFolder::getPropertyModifiedDate(
+               JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+        return converter.toJSValueRef(folder->getFolderModifiedDate());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef     JSFolder::getPropertyMediaId(
+               JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentFolderPtr folder = getFolderObject(object);
+        //folder->getMediaIdList()
+        //MediaIdListPtr       getMediaIdList() const; 
+               //typedef vector<std::string> MediaIdList;
+               //typedef DPL::SharedPtr<MediaIdList> MediaIdListPtr;
+               MediaIdListPtr mediaIdLstPtr = folder->getMediaIdList();
+               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+
+               if(mediaIdLstPtr)
+               {
+                       if (NULL == jsResult) 
+                       {
+                ThrowMsg(NullPointerException, "Could not create js array object");
+            }
+            for(unsigned int i=0; i<mediaIdLstPtr->size(); i++) 
+            {
+               JSValueRef val = converter.toJSValueRef(mediaIdLstPtr->at(i));
+                if(!JSSetArrayElement(context, jsResult, i, val)) 
+                {
+                   ThrowMsg(UnknownException, "Could not insert value into js array");
+                }
+            }
+               }
+        return jsResult;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+
+
+/*
+JSValueRef     JSFolder::findMedia(
+               JSContextRef context, 
+               JSObjectRef object,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception )
+{
+       FolderPrivObject *privFolder = static_cast<FolderPrivObject*>(JSObjectGetPrivate(thisObject));
+
+    LogDebug("JSFolder::FolderfindMedia entered" << getClassInfo());
+
+    assert(privFolder);
+
+    JSCallbackManagerPtr cbm(NULL);
+    Try
+    {
+               IMediacontentPtr mediacontent = Api::MediacontentFactory::getInstance().createMediacontentObject();
+
+        if (argumentCount < 1) 
+               {
+            LogError("No callback parameters");
+            return JSExceptionFactory::TypeMismatchException.make(context, exception);
+        }
+        JSValueRef onError = (argumentCount > 1 ? getFunctionOrNull(context, arguments[1]) : NULL);
+        JSContextRef globalContext = privFolder->getContext();
+        JSCallbackManagerPtr cbm = JSCallbackManager::createObject(globalContext, NULL, onError);
+        Commons::Validator validator(context);
+        if (validator.isCallback(arguments[0])) 
+               {
+            cbm->setOnSuccess(arguments[0]);
+        }
+        else if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
+               {
+            cbm->callOnError(JSExceptionFactory::InvalidValuesException.make(context));
+            return JSValueMakeUndefined(context);
+        }
+        else 
+               {
+            return JSExceptionFactory::TypeMismatchException.make(context, exception);
+        }
+        IEventFolderFindMediaPtr dplEvent(new IEventFolderFindMedia());
+               MediacontentFolderPtr folder = getFolderObject(thisObject);
+               dplEvent->setFolder(folder);
+        dplEvent->setPrivateData( DPL::StaticPointerCast<Platform::IEventPrivateData> (cbm));
+        dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
+        mediacontent->folderFindMedia(dplEvent);
+
+        return Utils::makePendingOperation(cbm->getContext(), dplEvent);
+    }
+    Catch(Commons::InvalidArgumentException)
+    {
+        LogError("Invalid argument");
+        return JSExceptionFactory::TypeMismatchException.make(context, exception);
+    }
+    Catch(Commons::Exception)
+    {
+        LogError("unknow error occured");
+    }
+    if (NULL != cbm) {
+        cbm->callOnError(JSExceptionFactory::UnknownException.make(privFolder->getContext()));
+    }
+    return JSValueMakeUndefined(context);
+
+}
+*/
+
+}
+}
+}
diff --git a/src/standards/Tizen/Mediacontent/JSFolder.h b/src/standards/Tizen/Mediacontent/JSFolder.h
new file mode 100644 (file)
index 0000000..8b72168
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+* 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_FOLDER_H_
+#define _JS_TIZEN_FOLDER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentFolder.h>
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+
+typedef PrivateObject<MediacontentFolderPtr, NoOwnership> FolderPrivObject;
+
+class JSFolder
+{
+       public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static MediacontentFolderPtr getFolderObject(JSObjectRef object);
+
+       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       getPropertyPath(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static JSValueRef       getPropertyName(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static JSValueRef       getPropertyStorageType(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static JSValueRef       getPropertyModifiedDate(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static JSValueRef       getPropertyMediaId(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+       
+       static JSValueRef       getPropertyEditableAttr(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+/*     static JSValueRef       findMedia(
+                       JSContextRef context, 
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception );
+*/
+
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_FOLDER_H_ */
diff --git a/src/standards/Tizen/Mediacontent/JSImage.cpp b/src/standards/Tizen/Mediacontent/JSImage.cpp
new file mode 100644 (file)
index 0000000..30c59ed
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+#include "JSMediacontent.h"
+#include "JSImage.h"
+
+
+
+#define TIZEN_MEDIACONTENT_IMAGE_ATTRIBUTENAME                 "Image"
+#define TIZEN_MEDIACONTENT_IMAGE_GEOLOCATION           "geolocation"
+#define TIZEN_MEDIACONTENT_IMAGE_WIDTH                         "width"
+#define TIZEN_MEDIACONTENT_IMAGE_HEIGHT                                "height"
+#define TIZEN_MEDIACONTENT_IMAGE_ORIENTATION           "orientation"
+
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+
+JSClassDefinition JSImage::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       TIZEN_MEDIACONTENT_IMAGE_ATTRIBUTENAME,
+       JSMedia::getClassRef(),
+       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 JSImage::m_property[] =
+{
+//    { TIZEN_MEDIACONTENT_IMAGE_UID, getPropertyUid, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_IMAGE_GEOLOCATION, getPropertyGeoLocation, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_IMAGE_WIDTH, getPropertyWidth, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_IMAGE_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},    
+    { TIZEN_MEDIACONTENT_IMAGE_ORIENTATION, getPropertyOrientation, NULL, kJSPropertyAttributeReadOnly},  
+    { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSImage::m_jsClassRef = JSClassCreate(JSImage::getClassInfo());
+
+void JSImage::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    ImagePrivObject *priv =
+            static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) {
+        MediacontentImagePtr privateData(new MediacontentImage());
+        priv = new ImagePrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("new event is created" );
+    }
+    else {
+        LogDebug("private object already exists");
+    }
+}
+
+void JSImage::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+       ImagePrivObject *priv =
+        static_cast<ImagePrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSImage::getClassRef()
+{
+       LogDebug("JSImage::getClassRef()");
+
+    if (!m_jsClassRef) {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSImage::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+MediacontentImagePtr JSImage::getImageObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    ImagePrivObject *priv = static_cast<ImagePrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentImagePtr result = priv->getObject();
+    if (!result) {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+                                       
+JSValueRef JSImage::getPropertyGeoLocation(
+               JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentImagePtr event = getImageObject(object);
+
+        //Todo. change to getPropertyGeoLocation
+        return converter.toJSValueRef(event->getImageLongitude());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSImage::getPropertyWidth(
+               JSContextRef context,
+        JSObjectRef object, 
+        JSStringRef propertyName, 
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentImagePtr event = getImageObject(object);
+        return converter.toJSValueRef(event->getImageWidth());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSImage::getPropertyHeight(
+               JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentImagePtr event = getImageObject(object);
+        return converter.toJSValueRef(event->getImageHeight());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSImage::getPropertyOrientation(
+               JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentImagePtr event = getImageObject(object);
+        return converter.toJSValueRef(event->getImageOrientation());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Mediacontent/JSImage.h b/src/standards/Tizen/Mediacontent/JSImage.h
new file mode 100644 (file)
index 0000000..f407244
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+* 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_IMAGE_H_
+#define _JS_TIZEN_IMAGE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+#include <API/Mediacontent/MediacontentImage.h>
+#include "JSMedia.h"
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<MediacontentImagePtr, NoOwnership> ImagePrivObject;
+
+class JSImage
+{
+public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static const JSClassRef getClassRef();
+
+    static MediacontentImagePtr getImageObject(JSObjectRef object);
+
+
+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  getPropertyGeoLocation(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyWidth(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyHeight(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+    
+
+    static JSValueRef  getPropertyOrientation(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);    
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_IMAGE_H_ */
diff --git a/src/standards/Tizen/Mediacontent/JSMedia.cpp b/src/standards/Tizen/Mediacontent/JSMedia.cpp
new file mode 100644 (file)
index 0000000..449e5c4
--- /dev/null
@@ -0,0 +1,409 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+
+
+#include "JSMediacontent.h"
+#include "JSMedia.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+#define TIZEN_MEDIACONTENT_MEDIA_ATTRIBUTENAME         "MediaItem"
+#define TIZEN_MEDIACONTENT_MEDIA_UID                           "id"
+#define TIZEN_MEDIACONTENT_MEDIA_TYPE                          "type"
+#define TIZEN_MEDIACONTENT_MEDIA_MIME_TYPE                     "mimeType"
+#define TIZEN_MEDIACONTENT_MEDIA_TITLE                         "title"
+#define TIZEN_MEDIACONTENT_MEDIA_FILE_URL                      "fileURL"
+#define TIZEN_MEDIACONTENT_MEDIA_THUMBNAILPATH         "thumbnailPath"
+#define TIZEN_MEDIACONTENT_MEDIA_CREATEDDATE           "createdDate"   
+#define TIZEN_MEDIACONTENT_MEDIA_RELEASEDDATE          "releasedDate"  
+#define TIZEN_MEDIACONTENT_MEDIA_MODIFIEDDATE          "modifiedDate"  
+#define TIZEN_MEDIACONTENT_MEDIA_DESCRIPTION           "description"   
+#define TIZEN_MEDIACONTENT_MEDIA_RATING                                "rating"        
+
+
+JSClassDefinition JSMedia::m_classInfo =
+{
+    0,
+    kJSClassAttributeNone,
+    TIZEN_MEDIACONTENT_MEDIA_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 JSMedia::m_property[] =
+{
+    //EventProperties
+    { TIZEN_MEDIACONTENT_MEDIA_UID, getPropertyId, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_TYPE, getPropertyType , NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_MIME_TYPE, getPropertyMimeType , NULL, kJSPropertyAttributeReadOnly},    
+    { TIZEN_MEDIACONTENT_MEDIA_TITLE, getPropertyDisplayName, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_FILE_URL, getPropertyFilePath, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_THUMBNAILPATH, getPropertyThumbnailPath, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_CREATEDDATE, getPropertyCreatedDate, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_RELEASEDDATE, getPropertyReleasedDate, NULL, kJSPropertyAttributeReadOnly},    
+    { TIZEN_MEDIACONTENT_MEDIA_MODIFIEDDATE, getPropertyModifiedDate, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_MEDIA_DESCRIPTION, getPropertyDescription, NULL, kJSPropertyAttributeReadOnly},    
+    { TIZEN_MEDIACONTENT_MEDIA_RATING, getPropertyFavorite, setPropertyFavorite, kJSPropertyAttributeNone},        
+    { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSMedia::m_jsClassRef = JSClassCreate(JSMedia::getClassInfo());
+
+void JSMedia::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    MediaPrivObject *priv = static_cast<MediaPrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) 
+       {
+        MediacontentMediaPtr privateData(new MediacontentMedia());
+        priv = new MediaPrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("new event is created" );
+    }
+    else 
+       {
+        LogDebug("private object already exists");
+    }
+}
+
+void JSMedia::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+    MediaPrivObject *priv = static_cast<MediaPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSMedia::getClassRef()
+{
+       LogDebug("JSMedia::getClassRef()");
+    if (!m_jsClassRef) 
+       {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSMedia::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+MediacontentMediaPtr JSMedia::getMediaObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    MediaPrivObject *priv = static_cast<MediaPrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) 
+       {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentMediaPtr result = priv->getObject();
+    if (!result) 
+       {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+JSValueRef JSMedia::getPropertyId(
+                                       JSContextRef context, 
+                                       JSObjectRef object,
+                                       JSStringRef propertyName, 
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+
+        return converter.toJSValueRef(event->getMediaUUID());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef     JSMedia::getPropertyMimeType(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getMimeType());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+
+                                       
+JSValueRef JSMedia::getPropertyDisplayName(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("getPropertyDisplayName::entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+       LogDebug("getDisplayName:"<<event->getDisplayName());    
+        return converter.toJSValueRef(event->getDisplayName());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSMedia::getPropertyFilePath(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getFilePath());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSMedia::getPropertyThumbnailPath(
+                                       JSContextRef context,
+                                       JSObjectRef object, 
+                                       JSStringRef propertyName, 
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getThumbnailPath());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSMedia::getPropertyDescription(
+                                       JSContextRef context,
+                                       JSObjectRef object, 
+                                       JSStringRef propertyName, 
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getDescription());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSMedia::getPropertyCreatedDate(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getCreatedDate());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef JSMedia::getPropertyModifiedDate(
+                                       JSContextRef context,
+                                       JSObjectRef object, 
+                                       JSStringRef propertyName, 
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getModifiedDate());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSMedia::getPropertyReleasedDate(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getReleasedDate());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+
+}
+
+
+JSValueRef JSMedia::getPropertyFavorite(
+                                       JSContextRef context,
+                                       JSObjectRef object, 
+                                       JSStringRef propertyName, 
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getFavorite());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSMedia::getPropertyType(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("getPropertyType::entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+        return converter.toJSValueRef(event->getMediaType());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+bool   JSMedia::setPropertyFavorite(
+                               JSContextRef context,
+                               JSObjectRef object,
+                               JSStringRef propertyName,
+                               JSValueRef value,
+                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentMediaPtr event = getMediaObject(object);
+           int rating = converter.toInt(value);
+
+           LogDebug("value : " << rating);
+        event->setFavorite(rating);
+        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/Mediacontent/JSMedia.h b/src/standards/Tizen/Mediacontent/JSMedia.h
new file mode 100644 (file)
index 0000000..2ec6789
--- /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. 
+*/
+
+
+#ifndef _JS_TIZEN_MEDIA_H_
+#define _JS_TIZEN_MEDIA_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<Api::Mediacontent::MediacontentMediaPtr, NoOwnership> MediaPrivObject;
+
+class JSMedia
+{
+       public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static Api::Mediacontent::MediacontentMediaPtr getMediaObject(JSObjectRef object);
+
+
+       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       getPropertyType(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyMimeType(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+       
+       static JSValueRef       getPropertyDisplayName(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyFilePath(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef   getPropertyDescription(
+                                               JSContextRef context,
+                                               JSObjectRef object, 
+                                               JSStringRef propertyName, 
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyThumbnailPath(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyCreatedDate(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyReleasedDate(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyModifiedDate(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyFavorite(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);    
+
+       static bool                     setPropertyFavorite(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                   JSValueRef value,
+                                               JSValueRef* exception);  
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_MEDIA_H_ */
diff --git a/src/standards/Tizen/Mediacontent/JSMediaLyrics.cpp b/src/standards/Tizen/Mediacontent/JSMediaLyrics.cpp
new file mode 100644 (file)
index 0000000..2700603
--- /dev/null
@@ -0,0 +1,238 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSDOMExceptionFactory.h>
+
+#include "JSMediacontent.h"
+#include "JSMediaLyrics.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+#define TIZEN_MEDIACONTENT_MEDIA_LYRICS                "MediaLyrics"
+#define TIZEN_MEDIACONTENT_LYRICS_TYPE         "type"
+#define TIZEN_MEDIACONTENT_LYRICS_TIMESTAMP "timeStamps"
+#define TIZEN_MEDIACONTENT_LYRICS_TEXT         "texts"
+
+
+
+
+
+
+JSClassDefinition JSMediaLyrics::m_classInfo =
+{
+    0,
+    kJSClassAttributeNone,
+    TIZEN_MEDIACONTENT_MEDIA_LYRICS,
+    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 JSMediaLyrics::m_property[] =
+{
+    //EventProperties
+    { TIZEN_MEDIACONTENT_LYRICS_TYPE, getPropertyLyricsType, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_LYRICS_TIMESTAMP, getPropertyTimeStamps, NULL, kJSPropertyAttributeReadOnly},
+    { TIZEN_MEDIACONTENT_LYRICS_TEXT, getPropertyTexts, NULL, kJSPropertyAttributeReadOnly},    
+    { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSMediaLyrics::m_jsClassRef = JSClassCreate(JSMediaLyrics::getClassInfo());
+
+void JSMediaLyrics::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    LyricsPrivObject *priv = static_cast<LyricsPrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) 
+       {
+        MediacontentLyricsPtr privateData(new MediacontentLyrics());
+        priv = new LyricsPrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("private object is created");
+    }
+    else 
+       {
+        LogDebug("private object already exists");
+    }
+}
+
+void JSMediaLyrics::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+    LyricsPrivObject *priv = static_cast<LyricsPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSMediaLyrics::getClassRef()
+{
+       LogDebug("JSMediaLyrics::getClassRef()");
+    if (!m_jsClassRef) 
+       {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSMediaLyrics::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+MediacontentLyricsPtr JSMediaLyrics::getLyricsObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    LyricsPrivObject *priv = static_cast<LyricsPrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) 
+       {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentLyricsPtr result = priv->getObject();
+    if (!result) 
+       {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+
+JSValueRef     JSMediaLyrics::getPropertyLyricsType(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+               Converter converter(context);
+
+        MediacontentLyricsPtr lyrics = getLyricsObject(object);
+
+        return converter.toJSValueRef(lyrics->getMediaLyricsType());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef     JSMediaLyrics::getPropertyTimeStamps(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+       Converter converter(context);
+        MediacontentLyricsPtr lyrics = getLyricsObject(object);
+        
+               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+               vector<unsigned long> timeStamps = lyrics->getMediaLyricsTimeStamps();
+               if(timeStamps.size() > 0)
+               {
+                       if (NULL == jsResult) 
+                       {
+                ThrowMsg(NullPointerException, "Could not create js array object");
+            }
+            for(unsigned int i=0; i<timeStamps.size(); i++) 
+            {
+               JSValueRef val = converter.toJSValueRef(timeStamps.at(i));
+                if(!JSSetArrayElement(context, jsResult, i, val)) 
+                {
+                   ThrowMsg(UnknownException, "Could not insert value into js array");
+                }
+            }
+               }
+        return jsResult;
+
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return JSValueMakeUndefined(context);
+
+}
+
+JSValueRef     JSMediaLyrics::getPropertyTexts(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+               Converter converter(context);
+        MediacontentLyricsPtr lyrics = getLyricsObject(object);
+               JSObjectRef jsResult = JSCreateArrayObject(context, 0, NULL);
+               vector<string> texts = lyrics->getMediaLyricsTexts();
+               if(texts.size() >0)
+               {
+                       if (NULL == jsResult) 
+                       {
+                ThrowMsg(NullPointerException, "Could not create js array object");
+            }
+            for(unsigned int i=0; i<texts.size(); i++) 
+            {
+               JSValueRef val = converter.toJSValueRef(texts.at(i));
+                if(!JSSetArrayElement(context, jsResult, i, val)) 
+                {
+                   ThrowMsg(UnknownException, "Could not insert value into js array");
+                }
+            }
+               }
+
+        return jsResult;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+
+    return JSValueMakeUndefined(context);
+
+}
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Mediacontent/JSMediaLyrics.h b/src/standards/Tizen/Mediacontent/JSMediaLyrics.h
new file mode 100644 (file)
index 0000000..5ca2205
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+* 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_MEDIA_LYRICS_H_
+#define _JS_TIZEN_MEDIA_LYRICS_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentLyrics.h>
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<MediacontentLyricsPtr, NoOwnership> LyricsPrivObject;
+
+class JSMediaLyrics
+{
+       public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static MediacontentLyricsPtr getLyricsObject(JSObjectRef object);
+
+
+       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       getPropertyLyricsType(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyTimeStamps(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception);
+
+       static JSValueRef       getPropertyTexts(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSStringRef propertyName,
+                                               JSValueRef* exception); 
+
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_MEDIA_LYRICS_H_ */
diff --git a/src/standards/Tizen/Mediacontent/JSMediacontent.cpp b/src/standards/Tizen/Mediacontent/JSMediacontent.cpp
new file mode 100644 (file)
index 0000000..e6597f2
--- /dev/null
@@ -0,0 +1,706 @@
+/*
+* 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 <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/JSPendingOperation.h>
+
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <Tizen/Tizen/FilterConverter.h>
+
+
+
+#include <API/Mediacontent/MediacontentFactory.h>
+#include "MediacontentController.h"
+#include "JSMediacontent.h"
+#include "JSMediacontentManager.h"
+#include "JSMedia.h"
+#include "MediaConverter.h"
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace TizenApis::Tizen1_0::Tizen;
+
+
+#define TIZEN_MEDIACONTENT_ATTRIBUTENAME       "MediaSource"
+
+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 Mediacontent {
+
+
+JSClassDefinition JSMediacontent::m_classInfo =
+{
+    0,
+    kJSClassAttributeNone,
+    TIZEN_MEDIACONTENT_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 JSMediacontent::m_property[] =
+{
+    {0, 0, 0, 0}
+};
+
+JSStaticFunction JSMediacontent::m_function[] =
+{
+    { "findItems", findMedia, kJSPropertyAttributeNone },
+    { "findFolders", findFolders, kJSPropertyAttributeNone },
+    { "updateItem", updateItem, kJSPropertyAttributeNone },    
+    { 0, 0, 0 }
+};
+
+JSClassRef JSMediacontent::m_jsClassRef = JSClassCreate(JSMediacontent::getClassInfo());
+
+void JSMediacontent::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug("JSMediacontent::initialize entered");
+    MediacontentPrivObject *priv = static_cast<MediacontentPrivObject*>(JSObjectGetPrivate(object));
+    if (!priv) 
+       {
+        //create default instance
+        LogWarning("create default instance");
+        IMediacontentPtr mediacontent = MediacontentFactory::getInstance().createMediacontentObject();
+        priv = new MediacontentPrivObject(context, mediacontent);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(priv))) 
+               {
+            delete priv;
+        }
+    } 
+       else
+    {
+        LogDebug("private object alrerady exists");
+    }
+
+}
+
+void JSMediacontent::finalize(JSObjectRef object)
+{
+    LogDebug("entered");
+    MediacontentPrivObject *priv = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSMediacontent::getClassRef()
+{
+    if (!m_jsClassRef) 
+       {
+        m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+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);
+    
+       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]))) //||
+//            (argumentCount >= 3 && (!JSValueIsObject(context, arguments[2]) /*&& !validator.isNullOrUndefined(arguments[2])*/)) 
+//            (argumentCount >= 4 && (!JSValueIsObject(context, arguments[3]) /*&& !validator.isNullOrUndefined(arguments[3])*/)) ||
+//            (argumentCount >= 5 && (!JSValueIsObject(context, arguments[4]) /*&& !validator.isNullOrUndefined(arguments[4]))*/)) ||
+            /*(argumentCount >= 6 && (!JSValueIsObject(context, arguments[5]) && !validator.isNullOrUndefined(arguments[4]))))*/)
+        {
+            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])) 
+               {
+                       SortModeArrayPtr sortModes(new 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::findFolders(
+                                                       JSContextRef context, 
+                                                       JSObjectRef object,
+                                                       JSObjectRef thisObject, 
+                                                       size_t argumentCount,
+                                                       const JSValueRef arguments[], 
+                                                       JSValueRef* exception )
+{
+
+       LogDebug("JSMediacontent::findFolders entered");
+
+    MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+    assert(privateObject);
+
+
+       //TODO.
+       //AceSecurityStatus status = CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_FIND);
+       //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]))) ||
+            (argumentCount >= 3 && (!JSValueIsObject(context, arguments[2]) /*&& !validator.isNullOrUndefined(arguments[2])*/)) 
+//            (argumentCount >= 4 && (!JSValueIsObject(context, arguments[3]) /*&& !validator.isNullOrUndefined(arguments[3])*/)) ||
+//            (argumentCount >= 5 && (!JSValueIsObject(context, arguments[4]) /*&& !validator.isNullOrUndefined(arguments[4]))*/)) ||
+            /*(argumentCount >= 6 && (!JSValueIsObject(context, arguments[5]) && !validator.isNullOrUndefined(arguments[4]))))*/)
+        {
+            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);
+               }
+
+        IEventFindFolderPtr dplEvent(new IEventFindFolder());
+        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])) 
+               {
+                       SortModeArrayPtr sortModes(new 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->findFolder(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::updateItem(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSObjectRef thisObject,
+                                               size_t argumentCount,
+                                               const JSValueRef arguments[],
+                                               JSValueRef* exception)
+{
+               LogDebug("updateItem::entered");
+
+       
+               MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+               assert(privateObject);
+
+               //AceSecurityStatus
+               //TIZEN_SYNC_ACCESS_HANDLER
+               Validator validator(context);
+               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+
+               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)
+               {
+                   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::findPlaylist(
+                                                       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);
+
+
+
+    JSCallbackManagerPtr cbm(NULL);
+    Try
+    {
+        IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+        if (argumentCount < 1) 
+               {
+            LogError("No callback parameters");
+            Throw(InvalidArgumentException);
+        }
+        JSValueRef onError = (argumentCount > 1 ? getFunctionOrNull(context, arguments[1]) : NULL);
+        JSContextRef globalContext = privateObject->getContext();
+        JSCallbackManagerPtr 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]))
+               {
+            Throw(InvalidArgumentException);
+        }
+
+
+               //dy.kim-todo:Filter 
+               
+        IEventFindPlaylistPtr dplEvent(new IEventFindPlaylist());
+        dplEvent->setPrivateData( DPL::StaticPointerCast<IEventPrivateData> (cbm));
+        dplEvent->setForAsynchronousCall(&MediacontentManagerController::getInstance());
+        mediacontent->findPlaylist(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::deletePlaylist(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSObjectRef thisObject,
+                                               size_t argumentCount,
+                                               const JSValueRef arguments[],
+                                               JSValueRef* exception)
+{
+               LogDebug("deletePlaylist::entered");
+       
+               MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+               assert(privateObject);
+       
+               //CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD_EVENT);
+       
+               Try
+               {
+                       IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+                       if (argumentCount != 1) 
+                       {
+                               LogError("Wrong number of parameters.");
+                               Throw(InvalidArgumentException);
+                       }
+       
+                       if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) 
+                       {
+                               Throw(InvalidArgumentException);
+                               //return JSValueMakeNull(context);
+                       }
+       
+                       MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
+                       string playlistID = converter->toString(arguments[0]);
+
+                       LogDebug("deletePlaylist::entered" << playlistID);
+                       IEventDeletePlaylistPtr dplEvent(new IEventDeletePlaylist());
+                       LogDebug("deletePlaylist::entered11");
+                       dplEvent->setPlaylistId(playlistID);
+                       LogDebug("deletePlaylist::entered22");
+                       dplEvent->setForSynchronousCall();
+                       LogDebug("deletePlaylist::entered33");
+                       mediacontent->deletePlaylist(dplEvent);
+                       LogDebug("deletePlaylist::entered44");
+       
+                       if (dplEvent->getResult()) 
+                       {;
+//                             return converter->toJSValueRef(dplEvent->getPlaylist()->getPlaylistId());
+                       } else
+                       {
+                               Throw(InvalidArgumentException);
+                       }
+               }
+               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::addAudioToPlaylist(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSObjectRef thisObject,
+                                               size_t argumentCount,
+                                               const JSValueRef arguments[],
+                                               JSValueRef* exception)
+{
+                       LogDebug("addAudioToPlaylist::entered");
+               
+                       MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+                       assert(privateObject);
+               
+                       //CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD_EVENT);
+               
+                       Try
+                       {
+                               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+                               if (argumentCount != 2) 
+                               {
+                                       LogError("Wrong number of parameters.");
+                                       Throw(InvalidArgumentException);
+                               }
+               
+                               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) 
+                               {
+                                       Throw(InvalidArgumentException);
+                                       //return JSValueMakeNull(context);
+                               }
+               
+                               MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
+                               string playlistID = converter->toString(arguments[0]);
+                               string mediaUID = converter->toString(arguments[1]);
+               
+                               IEventAddAudioToPlaylistPtr dplEvent(new IEventAddAudioToPlaylist());
+                               dplEvent->setPlaylistId(playlistID);
+                               dplEvent->setMediaUID(mediaUID);                                
+                               dplEvent->setForSynchronousCall();
+                               mediacontent->addAudioToPlaylist(dplEvent);
+               
+                               if (dplEvent->getResult()) 
+                               {
+                               ;
+//                                     return converter->toJSValueRef(dplEvent->getPlaylist()->getPlaylistId());
+                               } else
+                               {
+                                       Throw(InvalidArgumentException);
+                               }
+                       }
+                   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 (NotFoundException)
+                   {
+                       return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::NOT_FOUND_ERROR);
+                   }
+                   Catch(Exception)
+                   {
+                       return TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+                   }                   
+       
+                       return JSValueMakeNull(context);
+
+}
+
+JSValueRef JSMediacontent::deleteAudioToPlaylist(
+                                               JSContextRef context,
+                                               JSObjectRef object,
+                                               JSObjectRef thisObject,
+                                               size_t argumentCount,
+                                               const JSValueRef arguments[],
+                                               JSValueRef* exception)
+{
+                       LogDebug("deleteAudioToPlaylist::entered");
+               
+                       MediacontentPrivObject *privateObject = static_cast<MediacontentPrivObject*>( JSObjectGetPrivate( thisObject ) ) ;
+                       assert(privateObject);
+               
+                       //CALENDAR_CHECK_ACCESS(privateObject->getContext(), CALENDAR_FUNCTION_API_ADD_EVENT);
+               
+                       Try
+                       {
+                               IMediacontentPtr mediacontent = getMediacontentObject(context, thisObject, exception);
+                               if (argumentCount != 2) 
+                               {
+                                       LogError("Wrong number of parameters.");
+                                       Throw(InvalidArgumentException);
+                               }
+               
+                               if (JSValueIsUndefined(context, arguments[0]) || JSValueIsNull(context, arguments[0])) 
+                               {
+                                       Throw(InvalidArgumentException);
+                                       //return JSValueMakeNull(context);
+                               }
+               
+                               MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(context);
+                               string playlistID = converter->toString(arguments[0]);
+                               string mediaUID = converter->toString(arguments[1]);
+               
+                               IEventDeleteAudioToPlaylistPtr dplEvent(new IEventDeleteAudioToPlaylist());
+                               dplEvent->setPlaylistId(playlistID);
+                               dplEvent->setMediaUID(mediaUID);                                
+                               dplEvent->setForSynchronousCall();
+                               mediacontent->deleteAudioToPlaylist(dplEvent);
+               
+                               if (dplEvent->getResult()) 
+                               {;
+       //                              return converter->toJSValueRef(dplEvent->getPlaylist()->getPlaylistId());
+                               } else
+                               {
+                                       Throw(NotFoundException);
+                               }
+                       }
+                       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);
+
+}
+
+
+*/
+
+
+
+IMediacontentPtr JSMediacontent::getMediacontentObject(
+                                               JSContextRef ctx,
+                                       const JSObjectRef object,
+                                       JSValueRef* exception)
+{
+    MediacontentPrivObject *priv = static_cast<MediacontentPrivObject*>(JSObjectGetPrivate(object));
+    if (priv) 
+       {
+        return priv->getObject();
+    }
+    ThrowMsg(NullPointerException, "Private object is NULL.");
+}
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Mediacontent/JSMediacontent.h b/src/standards/Tizen/Mediacontent/JSMediacontent.h
new file mode 100644 (file)
index 0000000..ba0f4ac
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* 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_MEDIACONTENT_H_
+#define _JS_TIZEN_MEDIACONTENT_H_
+
+#include <vector>
+#include <string>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <API/Mediacontent/IMediacontent.h>
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+
+typedef PrivateObject<IMediacontentPtr, NoOwnership> MediacontentPrivObject;
+
+class JSMediacontent
+{
+       public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static IMediacontentPtr getMediacontentObject(
+                       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);
+
+       static JSValueRef findMedia(
+                       JSContextRef context, 
+                       JSObjectRef object,
+                       JSObjectRef thisObject, 
+                       size_t argumentCount,
+                       const JSValueRef arguments[], 
+                       JSValueRef* exception);
+
+       static JSValueRef findFolders(
+                       JSContextRef context, 
+                       JSObjectRef object,
+                       JSObjectRef thisObject, 
+                       size_t argumentCount,
+                       const JSValueRef arguments[], 
+                       JSValueRef* exception);
+
+       static JSValueRef updateItem(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+       
+/*
+       static JSValueRef findPlaylist(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception );
+
+
+    static JSValueRef addPlaylist(
+                       JSContextRef context,
+            JSObjectRef object,
+            JSObjectRef thisObject,
+            size_t argumentCount,
+            const JSValueRef arguments[],
+            JSValueRef* exception);
+
+       static JSValueRef deletePlaylist(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef addAudioToPlaylist(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef deleteAudioToPlaylist(
+                       JSContextRef context,
+                       JSObjectRef object,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception); 
+
+*/
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_MEDIACONTENT_H_ */
+
diff --git a/src/standards/Tizen/Mediacontent/JSMediacontentManager.cpp b/src/standards/Tizen/Mediacontent/JSMediacontentManager.cpp
new file mode 100644 (file)
index 0000000..84c7f84
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+* 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 <memory>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/Utils.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <API/Mediacontent/MediacontentFactory.h>
+
+#include "MediaConverter.h"
+#include "JSMediacontentManager.h"
+#include "MediacontentController.h"
+
+using namespace TizenApis::Commons;
+
+
+#define TIZEN_MEDIACONTENT_MANAGER_ATTRIBUTENAME                               "mediacontent"
+#define TIZEN_MEDIACONTENT_MANAGER_GET_LOCAL_MEDIA_SOURCE              "getLocalMediaSource"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+JSStaticValue JSMediacontentManager::m_property[] =
+{
+    { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSMediacontentManager::m_function[] = {
+    { TIZEN_MEDIACONTENT_MANAGER_GET_LOCAL_MEDIA_SOURCE, getMediacontent, kJSPropertyAttributeNone },
+    { 0, 0, 0 }
+};
+
+
+JSClassRef JSMediacontentManager::m_jsClassRef = NULL;
+
+JSClassDefinition JSMediacontentManager::m_classInfo =
+{
+               0,
+               kJSClassAttributeNone,
+               TIZEN_MEDIACONTENT_MANAGER_ATTRIBUTENAME,
+               0,
+               m_property,
+               m_function,
+               initialize,
+               finalize,
+               NULL, //hasProperty,
+               NULL, //getProperty,
+               NULL, //setProperty,
+               NULL, //deleteProperty,
+               NULL, //getPropertyNames,
+               NULL, //callAsFunction,
+               NULL, //callAsConstructor,
+               NULL,
+               NULL, //convertToType
+};
+
+
+
+JSValueRef JSMediacontentManager::getMediacontent(
+                                                               JSContextRef context,
+                                                       JSObjectRef object,
+                                                       JSObjectRef thisObject,
+                                                       size_t argumentCount,
+                                                       const JSValueRef arguments[],
+                                                       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);
+    }
+
+    JSContextRef globalContext = privateObject->getContext();
+
+       /*dy.kim-todo
+    AceSecurityStatus status = CALENDAR_CHECK_ACCESS(globalContext, CALENDAR_FUNCTION_API_GET_DEFAULT_CALENDAR);
+
+       */
+
+    Try 
+    {
+        if (argumentCount > 0) 
+        {
+            ThrowMsg(InvalidArgumentException, "Wrong number of parameters.");
+        }
+
+        MediaConverter converter(globalContext); 
+  
+        IEventGetMediacontentPtr dplEvent(new IEventGetMediacontent());
+        dplEvent->setForSynchronousCall();
+
+        privateObject->getObject()->getMediacontent(dplEvent);
+
+        // Process the result.
+        if (dplEvent->getResult()) 
+        {
+            return converter.toJSValueRefMediacontent(dplEvent->getMediacontent());
+        } 
+        else 
+        {
+            ThrowMsg(UnknownException, "Getting calendar failed by unkown 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 JSValueMakeNull(context);
+
+}
+
+
+
+
+const JSClassRef JSMediacontentManager::getClassRef() {
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+
+const JSClassDefinition* JSMediacontentManager::getClassInfo() 
+{
+       return &m_classInfo;
+}
+
+void JSMediacontentManager::initialize(JSContextRef context, JSObjectRef object) 
+{
+    LogDebug("JSMediacontentManager  initialize entered");
+    MediacontentManagerPrivObject *privateObject = static_cast<MediacontentManagerPrivObject*>(JSObjectGetPrivate(object));
+    if (NULL == privateObject) 
+       {
+        IMediacontentManagerPtr mediacontentManager = MediacontentFactory::getInstance().createMediacontentManagerObject();
+        privateObject = new MediacontentManagerPrivObject(context, mediacontentManager);
+        if (!JSObjectSetPrivate(object, static_cast<void*>(privateObject))) 
+               {
+            delete privateObject;
+        }
+    }
+
+}
+
+void JSMediacontentManager::finalize(JSObjectRef object) 
+{
+       LogDebug("Entered");
+       MediacontentManagerPrivObject* priv = static_cast<MediacontentManagerPrivObject*> (JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting coordinates object");
+       delete priv;
+}
+
+
+
+
+}
+} 
+} 
+
diff --git a/src/standards/Tizen/Mediacontent/JSMediacontentManager.h b/src/standards/Tizen/Mediacontent/JSMediacontentManager.h
new file mode 100644 (file)
index 0000000..a6330df
--- /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 _JS_TIZEN_MEDIACONTENT_H_
+#define _JS_TIZEN_MEDIACONTENT_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/IMediacontentManager.h>
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<IMediacontentManagerPtr, NoOwnership> MediacontentManagerPrivObject;
+
+
+class JSMediacontentManager 
+{
+
+public:
+       static const JSClassDefinition* getClassInfo();
+       static const JSClassRef getClassRef();
+
+private:
+
+       static JSValueRef getMediacontent(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSObjectRef thisObject,
+                                       size_t argumentCount,
+                                       const JSValueRef arguments[],
+                                       JSValueRef* exception);
+       static IMediacontentManagerPtr getIMediacontentManager(
+                                       JSContextRef ctx,
+                                       const JSObjectRef object,
+                                       JSValueRef* exception);
+
+           
+       /**
+        * 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;
+       static JSStaticFunction m_function[];
+
+       /**
+        * This structure describes a statically declared value property.
+        */
+       static JSStaticValue m_property[];
+
+       static JSClassRef m_jsClassRef;
+};
+
+}
+} // Wac
+} // WrtPlugins
+
+#endif //_JS_TIZEN_MEDIACONTENT_H_
+
diff --git a/src/standards/Tizen/Mediacontent/JSVideo.cpp b/src/standards/Tizen/Mediacontent/JSVideo.cpp
new file mode 100644 (file)
index 0000000..9f7e55c
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+* 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 <CommonsJavaScript/PrivateObject.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+
+#include "JSMediacontent.h"
+#include "JSVideo.h"
+
+#define TIZEN_MEDIACONTENT_VIDEO_ATTRIBUTENAME         "Video"
+#define TIZEN_MEDIACONTENT_VIDEO_GEOLOCATION           "geolocation"
+#define TIZEN_MEDIACONTENT_VIDEO_ALBUM                         "album"
+#define TIZEN_MEDIACONTENT_VIDEO_ARTIST                        "artist"
+#define TIZEN_MEDIACONTENT_VIDEO_PLAYEDTIME            "playedTime" 
+#define TIZEN_MEDIACONTENT_VIDEO_PLAYCOUNT                     "playCount" 
+#define TIZEN_MEDIACONTENT_VIDEO_DURATION                      "duration"      
+#define TIZEN_MEDIACONTENT_VIDEO_WIDTH                         "width"
+#define TIZEN_MEDIACONTENT_VIDEO_HEIGHT                        "height"
+
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Api::Mediacontent;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+
+JSClassDefinition JSVideo::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       TIZEN_MEDIACONTENT_VIDEO_ATTRIBUTENAME,
+       JSMedia::getClassRef(),
+       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 JSVideo::m_property[] =
+{
+       { TIZEN_MEDIACONTENT_VIDEO_GEOLOCATION, getPropertyGeoLocation, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_VIDEO_ALBUM, getPropertyAlbum, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_VIDEO_ARTIST, getPropertyArtist, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_VIDEO_PLAYEDTIME, getPropertyPlayedTime, setPropertyPlayedTime, kJSPropertyAttributeNone},
+       { TIZEN_MEDIACONTENT_VIDEO_PLAYCOUNT, getPropertyPlayCount, setPropertyPlayCount, kJSPropertyAttributeNone},    
+       { TIZEN_MEDIACONTENT_VIDEO_DURATION, getPropertyDuration, NULL, kJSPropertyAttributeReadOnly},    
+       { TIZEN_MEDIACONTENT_VIDEO_WIDTH, getPropertyWidth, NULL, kJSPropertyAttributeReadOnly},
+       { TIZEN_MEDIACONTENT_VIDEO_HEIGHT, getPropertyHeight, NULL, kJSPropertyAttributeReadOnly},    
+       { 0, 0, 0, 0 }
+};
+
+
+JSClassRef JSVideo::m_jsClassRef = JSClassCreate(JSVideo::getClassInfo());
+
+void JSVideo::initialize(JSContextRef context, JSObjectRef object)
+{
+    LogDebug( "entered" );
+    VideoPrivObject *priv = static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) );
+    if (!priv) 
+    {
+        MediacontentVideoPtr privateData(new MediacontentVideo());
+        priv = new VideoPrivObject(context, privateData);
+        JSObjectSetPrivate(object, static_cast<void*>(priv));
+        LogDebug("new event is created" );
+    }
+    else {
+        LogDebug("private object already exists");
+    }
+}
+
+void JSVideo::finalize(JSObjectRef object)
+{
+    LogDebug( "entered" );
+       VideoPrivObject *priv =  static_cast<VideoPrivObject*>( JSObjectGetPrivate( object ) ) ;
+    delete priv;
+}
+
+const JSClassRef JSVideo::getClassRef()
+{
+       LogDebug("JSVideo::getClassRef()");
+
+    if (!m_jsClassRef) 
+    {
+            m_jsClassRef = JSClassCreate(&m_classInfo);
+    }
+    return m_jsClassRef;
+}
+
+const JSClassDefinition* JSVideo::getClassInfo()
+{
+    return &m_classInfo;
+}
+
+
+MediacontentVideoPtr JSVideo::getVideoObject(JSObjectRef object)
+{
+    LogDebug("entered");
+    VideoPrivObject *priv = static_cast<VideoPrivObject*>(JSObjectGetPrivate(object));
+    if(!priv) 
+    {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    MediacontentVideoPtr result = priv->getObject();
+    if (!result) 
+    {
+        ThrowMsg(NullPointerException, "Private object is null");
+    }
+    return result;
+}
+
+                       
+JSValueRef JSVideo::getPropertyGeoLocation(
+                                                                               JSContextRef context,
+                                                                       JSObjectRef object,
+                                                                       JSStringRef propertyName,
+                                                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        //Todo
+        return converter.toJSValueRef(event->getVideoLongitude());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSVideo::getPropertyAlbum(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object, 
+                                                               JSStringRef propertyName, 
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoAlbum());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSVideo::getPropertyArtist(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object, 
+                                                               JSStringRef propertyName, 
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoArtist());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSVideo::getPropertyPlayedTime(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object,
+                                                               JSStringRef propertyName,
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoPlayedTime());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSVideo::getPropertyPlayCount(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object,
+                                                               JSStringRef propertyName,
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoPlayCount());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+JSValueRef JSVideo::getPropertyDuration(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object,
+                                                               JSStringRef propertyName,
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoDuration());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSVideo::getPropertyWidth(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object,
+                                                               JSStringRef propertyName,
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoWidth());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+JSValueRef JSVideo::getPropertyHeight(
+                                                                       JSContextRef context,
+                                                               JSObjectRef object,
+                                                               JSStringRef propertyName,
+                                                               JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        return converter.toJSValueRef(event->getVideoHeight());
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to get incorrect value");
+    }
+    return JSValueMakeUndefined(context);
+}
+
+
+
+bool JSVideo::setPropertyPlayedTime(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        int rating = converter.toLong(value);
+        event->setVideoPlayedTime(rating);
+        return true;
+    }
+    Catch(Exception)
+    {
+        LogWarning("trying to set incorrect value");
+        TizenApis::Commons::JSTizenExceptionFactory::postException(context, exception, TizenApis::Commons::JSTizenException::TYPE_MISMATCH_ERROR);
+    }
+
+    return false;
+
+
+}
+bool JSVideo::setPropertyPlayCount(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef value,
+                                       JSValueRef* exception)
+{
+    LogDebug("entered");
+    Try
+    {
+        Converter converter(context);
+        MediacontentVideoPtr event = getVideoObject(object);
+        int rating = converter.toInt(value);
+        event->setVideoPlayCount(rating);
+        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/Mediacontent/JSVideo.h b/src/standards/Tizen/Mediacontent/JSVideo.h
new file mode 100644 (file)
index 0000000..1efe9c5
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+* 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_VIDEO_H_
+#define _JS_TIZEN_VIDEO_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+#include <API/Mediacontent/MediacontentVideo.h>
+#include "JSMedia.h"
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef PrivateObject<MediacontentVideoPtr, NoOwnership> VideoPrivObject;
+
+class JSVideo
+{
+public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static const JSClassRef getClassRef();
+
+       static Api::Mediacontent::MediacontentVideoPtr getVideoObject(JSObjectRef object);
+
+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  getPropertyGeoLocation(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyAlbum(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyArtist(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyDuration(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static bool                setPropertyPlayedTime(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                   JSValueRef value,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyPlayedTime(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception); 
+
+    static bool                setPropertyPlayCount(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                   JSValueRef value,
+                                       JSValueRef* exception);
+
+
+    static JSValueRef  getPropertyPlayCount(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception); 
+
+
+    static JSValueRef  getPropertyWidth(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+
+    static JSValueRef  getPropertyHeight(
+                                       JSContextRef context,
+                                       JSObjectRef object,
+                                       JSStringRef propertyName,
+                                       JSValueRef* exception);
+    
+
+
+       //todo-dykim
+       //static JSValueRef     setPropertyPlayedTime
+
+};
+
+}
+}
+}
+
+#endif /* _JS_TIZEN_VIDEO_H_ */
diff --git a/src/standards/Tizen/Mediacontent/MediaConverter.cpp b/src/standards/Tizen/Mediacontent/MediaConverter.cpp
new file mode 100644 (file)
index 0000000..0372f91
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+* 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 <CommonsJavaScript/JSUtils.h>
+#include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+
+#include "MediaConverter.h"
+#include "JSMedia.h"
+#include "JSImage.h"
+#include "JSVideo.h"
+#include "JSAudio.h"
+#include "JSFolder.h"
+#include "JSMediacontent.h"
+#include "JSMediaLyrics.h"
+
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+MediaConverter::MediaConverter(JSContextRef context) : Converter(context)
+{
+    LogDebug("entered");
+}
+
+JSValueRef MediaConverter::toFunctionOrNull(const JSValueRef& arg)
+{
+    if (Validator(m_context).isCallback(arg)) 
+       {
+        return arg;
+    } else if (!JSValueIsNull(m_context,arg) && !JSValueIsUndefined(m_context, arg)) 
+    {
+        ThrowMsg(ConversionException, "Not a function nor JS null.");
+    }
+    return NULL;
+}
+
+JSValueRef MediaConverter::toFunction(const JSValueRef& arg)
+{
+    if (Validator(m_context).isCallback(arg)) 
+       {
+        return 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.");
+}
+
+JSValueRef MediaConverter::toJSValueRefMediacontent(const IMediacontentPtr& arg)
+{
+    MediacontentPrivObject *priv = new MediacontentPrivObject(m_context, arg);
+    return JSObjectMake(m_context, JSMediacontent::getClassRef(), priv);
+}
+
+
+JSValueRef MediaConverter::toJSValueRefMedia(const MediacontentMediaPtr& arg)
+{
+       if(arg->getMediaType() == "IMAGE")
+       {
+           return JSUtils::makeObject(m_context, JSImage::getClassRef(), arg);
+       }
+       if(arg->getMediaType() == "VIDEO")
+       {
+           return JSUtils::makeObject(m_context, JSVideo::getClassRef(), arg);
+       }
+       if(arg->getMediaType() == "AUDIO")
+       {
+           return JSUtils::makeObject(m_context, JSAudio::getClassRef(), arg);
+       }
+       return JSUtils::makeObject(m_context, JSMedia::getClassRef(), arg);
+}
+
+JSValueRef MediaConverter::toJSValueRefFolder(const MediacontentFolderPtr& arg)
+{
+    return JSUtils::makeObject(m_context, JSFolder::getClassRef(), arg);
+}
+
+JSValueRef MediaConverter::toJSValueRef(const std::vector<MediacontentMediaPtr> &arg)
+{
+       return toJSValueRef_(arg, &MediaConverter::toJSValueRefMedia, this);
+}
+
+JSValueRef MediaConverter::toJSValueRef(const std::vector<MediacontentFolderPtr> &arg)
+{
+       return toJSValueRef_(arg, &MediaConverter::toJSValueRefFolder, this);
+}
+
+JSValueRef MediaConverter::toJSValueRef(const MediacontentLyricsPtr &arg)
+{
+       return JSUtils::makeObject(m_context, JSMediaLyrics::getClassRef(), arg);
+}
+
+
+}
+}
+}
diff --git a/src/standards/Tizen/Mediacontent/MediaConverter.h b/src/standards/Tizen/Mediacontent/MediaConverter.h
new file mode 100644 (file)
index 0000000..fad9a71
--- /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 _TIZEN_MEDIACONTENT_CONVERTER_H_
+#define _TIZEN_MEDIACONTENT_CONVERTER_H_
+
+#include <vector>
+#include <string>
+#include <CommonsJavaScript/Converter.h>
+#include <API/Mediacontent/IMediacontent.h>
+#include <API/Mediacontent/MediacontentMedia.h>
+#include <API/Mediacontent/MediacontentFolder.h>
+#include <API/Mediacontent/MediacontentLyrics.h>
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+       
+
+class MediaConverter : public Converter
+{
+       public:
+       using Converter::toJSValueRef;
+
+       public:
+       explicit MediaConverter(JSContextRef context);
+
+       JSValueRef toJSValueRefMediacontent(const IMediacontentPtr& 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);
+       JSValueRef toJSValueRefMedia(const MediacontentMediaPtr& arg);
+       JSValueRef toJSValueRefFolder(const MediacontentFolderPtr& arg);
+       JSValueRef toJSValueRef(const std::vector<MediacontentMediaPtr> &arg);
+       JSValueRef toJSValueRef(const std::vector<MediacontentFolderPtr> &arg);
+       JSValueRef toJSValueRef(const MediacontentLyricsPtr &arg);
+       //MediacontentLyricsPtr
+       static std::vector<std::string> m_allowedMediaAttributes;
+       static std::vector<std::string> m_allowedFolderAttributes;
+
+    
+};
+
+typedef ConverterFactory<MediaConverter> MediaConverterFactory;
+
+
+}
+}
+}
+
+#endif // _TIZEN_MEDIACONTENT_CONVERTER_H_
\ No newline at end of file
diff --git a/src/standards/Tizen/Mediacontent/MediacontentController.cpp b/src/standards/Tizen/Mediacontent/MediacontentController.cpp
new file mode 100644 (file)
index 0000000..8062349
--- /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 <dpl/log/log.h>
+#include <CommonsJavaScript/JSCallbackManager.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include "MediacontentController.h"
+#include "MediaConverter.h"
+#include "JSMediacontent.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+
+MediacontentManagerController& MediacontentManagerController::getInstance()
+{
+    static MediacontentManagerController instance;
+    return instance;
+}
+
+
+MediacontentManagerController::MediacontentManagerController():
+       EventFindMediaAnswerReceiver(ThreadEnum::NULL_THREAD),
+       EventFindFolderAnswerReceiver(ThreadEnum::NULL_THREAD)
+{
+       LogDebug("create a MediacontentManagerController");
+}
+
+MediacontentManagerController::~MediacontentManagerController() 
+{
+       LogDebug("<<<");
+       LogDebug(">>>");
+}
+
+
+void MediacontentManagerController::OnAnswerReceived(const IEventFindMediaPtr &event)
+{
+
+       LogDebug("MediacontentManagerController::OnAnswerReceived:entered");
+
+    JSCallbackManagerPtr cbm = DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) 
+       {
+        LogError("no callback manager");
+        return;
+    }
+    Try
+    {
+        if (event->getResult()) 
+               {
+            MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(cbm->getContext());
+            const std::vector<MediacontentMediaPtr> &results = event->getMedia();
+            JSValueRef result = converter->toJSValueRef(results);
+            cbm->callOnSuccess(result);
+            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 IEventFindFolderPtr &event)
+{
+
+       LogDebug("MediacontentManagerController::OnAnswerReceived:entered");
+
+    JSCallbackManagerPtr cbm = DPL::StaticPointerCast<JSCallbackManager>(event->getPrivateData());
+    if (!cbm) 
+       {
+        LogError("no callback manager");
+        return;
+    }
+    Try
+    {
+        if (event->getResult()) 
+               {
+            MediaConverterFactory::ConverterType converter = MediaConverterFactory::getConverter(cbm->getContext());
+            const std::vector<MediacontentFolderPtr> &results = event->getFolder();
+            JSValueRef result = converter->toJSValueRef(results);
+            cbm->callOnSuccess(result);
+            return;
+        }
+    }
+    Catch(Exception)
+    {
+        LogError("error during processing answer");
+    }
+    JSValueRef errorObject = TizenApis::Commons::JSTizenExceptionFactory::makeErrorObject(
+            cbm->getContext(), TizenApis::Commons::JSTizenException::UNKNOWN_ERROR);
+    cbm->callOnError(errorObject);
+
+}
+
+
+}
+}
+}
+
diff --git a/src/standards/Tizen/Mediacontent/MediacontentController.h b/src/standards/Tizen/Mediacontent/MediacontentController.h
new file mode 100644 (file)
index 0000000..210bb25
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+* 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 _TIZEN_CONTROLLER_H_
+#define _TIZEN_CONTROLLER_H_
+
+#include <API/Mediacontent/IEventGetMediacontent.h>
+#include <API/Mediacontent/IEventFindMedia.h>
+#include <API/Mediacontent/IEventFindFolder.h>
+//#include <API/Mediacontent/IEventFolderFindMedia.h>
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+typedef EventAnswerReceiver<IEventFindMedia> EventFindMediaAnswerReceiver;
+typedef EventAnswerReceiver<IEventFindFolder> EventFindFolderAnswerReceiver;
+
+
+class MediacontentManagerController :
+       public EventFindMediaAnswerReceiver,
+       public EventFindFolderAnswerReceiver
+{
+    public:
+    static MediacontentManagerController& getInstance();
+
+    protected:
+       void OnAnswerReceived(const IEventFindMediaPtr &event);
+       void OnAnswerReceived(const IEventFindFolderPtr &event);
+
+    private:
+       MediacontentManagerController();
+       virtual ~MediacontentManagerController();       
+
+};
+
+}
+}
+} 
+
+#endif //_TIZEN_CONTROLLER_H_
\ No newline at end of file
diff --git a/src/standards/Tizen/Mediacontent/config.xml b/src/standards/Tizen/Mediacontent/config.xml
new file mode 100644 (file)
index 0000000..67415d2
--- /dev/null
@@ -0,0 +1,27 @@
+<?xml version="1.0" ?>
+<!DOCTYPE plugin-properties SYSTEM "/usr/etc/tizen-apis/config.dtd">
+<plugin-properties>
+    <library-name>libwrt-plugins-tizen-1.0-mediacontent.so</library-name>
+    <feature-install-uri>mediacontet.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/mediacontent</name>
+        <device-capability>mediacontent</device-capability>
+        <Object name="MediacontentManager">
+            <Function name="getLocalMediaSource"/>
+        </Object>
+    </api-feature>
+
+    <api-feature>
+        <name>http://tizen.org/api/mediacontent</name>
+        <device-capability>mediacontent</device-capability>
+        <Object name="MediaSource">
+            <Function name="findItems"/>
+            <Function name="findFolders"/>
+            <Function name="updateItem"/>            
+        </Object>  
+    </api-feature>         
+</plugin-properties>
diff --git a/src/standards/Tizen/Mediacontent/plugin_initializer.cpp b/src/standards/Tizen/Mediacontent/plugin_initializer.cpp
new file mode 100644 (file)
index 0000000..705ad6a
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+* 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/WrtWrapper/WrtWrappersMgr.h>
+#include <Commons/Exception.h>
+#include "JSMediacontentManager.h"
+
+
+using namespace TizenApis::Api::Mediacontent;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Mediacontent {
+
+void on_widget_start_callback(
+                               int widgetId,
+                               JavaScriptContext context,
+                               const engine_interface_t *interface)
+{
+    LogDebug("[Tizen\\mediacontent] 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\\mediacontent] 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,
+        "mediacontent",
+        JSMediacontentManager::getClassRef(),
+        NULL)
+PLUGIN_CLASS_MAP_END
+
+}
+}
+}
index 98a84ff..82b5909 100755 (executable)
@@ -32,9 +32,16 @@ set(SRCS_MESSAGING
   #../Filesystem/FilesystemUtils.cpp
   
   ../Tizen/FilterConverter.cpp
+  ../Tizen/JSAttributeFilter.cpp
+  ../Tizen/JSAttributeRangeFilter.cpp
+  ../Tizen/JSCompositeFilter.cpp
+  ../Tizen/JSAbstractFilterArray.cpp
+  ../Tizen/JSSortMode.cpp
+
   ../Common/JSTizenException.cpp
   ../Common/TizenExceptionData.cpp
   ../Common/JSTizenExceptionFactory.cpp
+  ../Common/JSGlobalContextFactory.cpp 
 
   plugin_config.cpp
   plugin_initializer.cpp
index dd549e0..3697464 100755 (executable)
@@ -400,15 +400,15 @@ Api::Messaging::MessageType ConverterMessage::toMessageType(JSObjectRef arg)
        std::string strMsgType = toString(arg);
        LogDebug("Messasge Type : " << strMsgType);
 
-       if ( strMsgType.compare("tizen.sms") == 0 ) 
+       if ( strMsgType.compare("messaging.sms") == 0 ) 
        {
                return Api::Messaging::SMS;
        }
-       else if ( strMsgType.compare("tizen.mms") == 0 ) 
+       else if ( strMsgType.compare("messaging.mms") == 0 ) 
        {
                return Api::Messaging::MMS;
        }
-       else if ( strMsgType.compare("tizen.email") == 0 )
+       else if ( strMsgType.compare("messaging.email") == 0 )
        {
                return Api::Messaging::EMAIL;
        }
@@ -426,11 +426,11 @@ std::string ConverterMessage::toMessageType( long msgtype )
        switch (msgtype)
        {
                case Api::Messaging::SMS:
-                       return "tizen.sms";
+                       return "messaging.sms";
                case Api::Messaging::MMS:
-                       return "tizen.mms";
+                       return "messaging.mms";
                case Api::Messaging::EMAIL:
-                       return "tizen.email";
+                       return "messaging.email";
                default :
                        ThrowMsg(WrtDeviceApis::Commons::ConversionException, "message type not supported");
        }
index 781331d..bd1365a 100755 (executable)
@@ -72,9 +72,9 @@ const char* JSConversation::CC = "cc";
 const char* JSConversation::BCC = "bcc"; 
 const char* JSConversation::LASTMESSAGEID = "lastMessageId";   
 
-const std::string JSConversation::TYPE_SMS              = "tizen.sms";
-const std::string JSConversation::TYPE_MMS              = "tizen.mms";
-const std::string JSConversation::TYPE_EMAIL    = "tizen.email";
+const std::string JSConversation::TYPE_SMS              = "messaging.sms";
+const std::string JSConversation::TYPE_MMS              = "messaging.mms";
+const std::string JSConversation::TYPE_EMAIL    = "messaging.email";
 
 JSStaticValue JSConversation::m_properties[] = {
        {"id", JSConversation::getProperty, NULL, kJSPropertyAttributeReadOnly },
index 8ac4798..d9d5069 100755 (executable)
 #include <Tizen/Common/JSTizenException.h>
 #include <Tizen/Common/SecurityExceptions.h>
 
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+
 #include "MessagingErrorMsg.h"
 #include "JSMessageAttachment.h"
 #include "plugin_config.h"
 
+#include <Messaging/Sms.h>
+
+
 using namespace std;
 using namespace TizenApis::Api::Messaging;
 using namespace TizenApis::Commons;
 using namespace WrtDeviceApis::Commons;
+using namespace TizenApis::Platform::Messaging;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
 namespace TizenApis {
@@ -70,7 +76,7 @@ JSClassDefinition JSMessage::m_classInfo = {
     NULL, //deleteProperty,
     NULL, //getPropertyNames,
     NULL, //callAsFunction,
-    NULL, //callAsConstructor,
+    constructor, //callAsConstructor,
     NULL, //hasInstance,
     NULL, //convertToType,
 };
@@ -94,7 +100,8 @@ JSStaticValue JSMessage::m_property[] = {
     { "subject", getSubject, setSubject, kJSPropertyAttributeNone },
     { "inResponseTo", getInResponseTo, NULL, kJSPropertyAttributeNone },
     { "messageStatus", getMessageStatus, NULL, kJSPropertyAttributeReadOnly},
-    { "attachments", getAttachments, NULL, kJSPropertyAttributeReadOnly },
+    { "attachments", getAttachments, setAttachments, kJSPropertyAttributeNone },
+    { "hasAttachment", hasAttachment, NULL, kJSPropertyAttributeReadOnly},
     //{ "uid", getUID, NULL, kJSPropertyAttributeReadOnly},
     { 0, 0, 0, 0 }
 };
@@ -209,16 +216,39 @@ JSValueRef JSMessage::createJSObject(JSContextRef context,
     return createJSObject(context, msg, NULL);
 }
 
+JSValueRef JSMessage::createDummyMessageJSObject(JSContextRef context,
+       Api::Messaging::MessageType msgType)
+{
+       Api::Messaging::IMessagePtr msg;
+
+       if (msgType == Api::Messaging::EMAIL )
+       {
+               msg = Api::Messaging::MessageFactory::createEmailMessage();
+       }
+       else
+       {
+               LogError("message type is invalid");
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException); 
+       }
+
+       return createJSObject(context, msg);
+}
+
 void JSMessage::initialize(JSContextRef context,
         JSObjectRef object)
 {
+
     LogInfo("enter");
-    JSMessagePrivateObject* priv =
-        static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
-    LogDebug("priv=" << priv);
-    if (!priv) {
-        LogWarning("empty jsObject creation");
+
+    if (!JSObjectGetPrivate(object)) {
+               IMessagePtr msg(new Sms());
+               JSMessagePrivateObject *priv = new JSMessagePrivateObject(context, msg);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       LogInfo("set Private Failed...");
+                       delete priv;
+               }
     }
+       
 }
 
 void JSMessage::finalize(JSObjectRef object)
@@ -294,6 +324,196 @@ bool JSMessage::hasInstance(JSContextRef context,
     return true;
 }
 
+JSObjectRef JSMessage::constructor(JSContextRef context, 
+               JSObjectRef constructor, 
+               size_t argumentCount, 
+               const JSValueRef arguments[], 
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       
+       JSMessagePrivateObject* priv = static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(constructor));
+       JSContextRef globalContext = priv ? priv->getContext() : context;
+       
+       if (globalContext)
+       {
+               try 
+               {
+
+                       if ( argumentCount < 1 || argumentCount > 2) {
+                               LogError("Wrong argument count");
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong Message argumentCount");
+                       }
+                       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();
+                               }
+                               else if (msgType == Api::Messaging::MMS || msgType == Api::Messaging::SMS)
+                               {
+                                       msg = Api::Messaging::MessageFactory::createMessage(msgType);   //create message
+                               }
+                               else
+                               {
+                                       LogError("message type is invalid");
+                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException); 
+                               }
+                               
+                               if (msg)
+                               {
+                                       if ( argumentCount == 2 )
+                                       {
+                                               LogDebug ("##### msg type is " << msgType);
+                                                                       
+                                               const ScopedJSStringRef subjectStr(JSStringCreateWithUTF8CString("subject"));
+                                               const ScopedJSStringRef toStr(JSStringCreateWithUTF8CString("to"));
+                                               const ScopedJSStringRef ccStr(JSStringCreateWithUTF8CString("cc"));
+                                               const ScopedJSStringRef bccStr(JSStringCreateWithUTF8CString("bcc"));
+                                               const ScopedJSStringRef plainBodyStr(JSStringCreateWithUTF8CString("plainBody"));
+                                               const ScopedJSStringRef htmlBodyStr(JSStringCreateWithUTF8CString("htmlBody"));
+                                               const ScopedJSStringRef priorityStr(JSStringCreateWithUTF8CString("priority"));
+
+                                               JSObjectRef arg = converter->toJSObjectRef(arguments[1]);       //get dictionary
+                                               JSValueRef subjectData = JSObjectGetProperty(globalContext, arg, subjectStr.get(), NULL);
+                                               JSValueRef toData = JSObjectGetProperty(globalContext, arg, toStr.get(), NULL);
+                                               JSValueRef ccData = JSObjectGetProperty(globalContext, arg, ccStr.get(), NULL);
+                                               JSValueRef bccData = JSObjectGetProperty(globalContext, arg, bccStr.get(), NULL);
+                                               JSValueRef plainBodyData = JSObjectGetProperty(globalContext, arg, plainBodyStr.get(), NULL);
+                                               JSValueRef htmlBodyData = JSObjectGetProperty(globalContext, arg, htmlBodyStr.get(), NULL);
+                                               JSValueRef priorityData = JSObjectGetProperty(globalContext, arg, priorityStr.get(), NULL);     
+
+                                               //subject
+                                                if (!JSValueIsUndefined(globalContext, subjectData) ) 
+                                                {
+                                                       LogDebug ( " Subject : " << converter->toString(subjectData) );                                         
+                                                       std::string subject = converter->toString(subjectData);
+                                                        switch (msgType) 
+                                                        {
+                                                       case Api::Messaging::MMS:
+                                                       {
+                                                           Api::Messaging::IMmsPtr mms = Api::Messaging::MessageFactory::convertToMms(msg);
+                                                           mms->setSubject(subject);
+                                                           break;
+                                                       }
+                                                       case Api::Messaging::EMAIL:
+                                                       {
+                                                           Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                                                           email->setSubject(subject);
+                                                           break;
+                                                       }
+                                                         default:
+                                                         {
+                                                           LogError("message not supported");
+                                                           //Throw(WrtDeviceApis::Commons::UnsupportedException);
+                                                           //break;
+                                                         }
+                                                       }
+                                                }
+                                               //to
+                                               if (!JSValueIsUndefined(globalContext, toData) )
+                                               {
+                                                       Api::Messaging::Recipients to = converter->toRecipients(toData);
+                                                       LogDebug("setting to field, size=" << to.getRecipientSize());
+                                                       msg->setToRecipients(to);
+                                               }
+                                               //cc
+                                               if (msgType == Api::Messaging::EMAIL )
+                                               {
+                                                       Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                                                       if (!JSValueIsUndefined(globalContext, ccData))
+                                                       {
+                                                               Api::Messaging::Recipients cc = converter->toRecipients(ccData);
+                                                       email->setCcRecipients(cc);
+                                                       }
+
+                                                       if (!JSValueIsUndefined(globalContext, bccData))
+                                                       {
+                                                               Api::Messaging::Recipients bcc = converter->toRecipients(bccData);
+                                                       email->setBccRecipients(bcc);
+                                                       }
+
+                                                       if (!JSValueIsUndefined(globalContext, htmlBodyData))
+                                                       {
+                                                               std::string body = converter->toString(htmlBodyData);
+                                                               LogDebug("html body : " << body);
+                                                               email->setHtmlBody(body);
+                                                       }
+
+                                                       if (!JSValueIsUndefined(globalContext, priorityData))
+                                                       {
+                                                               email->setPriority(converter->toMessagePriority(priorityData));
+                                                       }
+                                                       
+                                               }
+
+                                               if (!JSValueIsUndefined(globalContext, plainBodyData) )
+                                               {
+                                                       std::string body = converter->toString(plainBodyData);
+                                                       LogDebug("plain body  : " << body);
+                                                       msg->setBody(body);
+                                               }
+                                       
+                                       }
+
+                                       //return
+                                       JSClassRef jsClassRef = JSClassCreate(getClassInfo());
+                                       LogDebug("jsClassRef success");
+                                       JSMessagePrivateObject* priv = new JSMessagePrivateObject(globalContext, msg);
+                                       LogDebug("priv success");
+                                       
+                                       JSObjectRef jsObjRef = JSObjectMake(globalContext, jsClassRef, static_cast<void*>(priv));
+                                       LogDebug("JSObjectMake success");
+                                       JSClassRelease(jsClassRef);
+                                       if (NULL == jsObjRef) {
+                                               LogError("object creation error");
+                                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "JSObject make error"); 
+                                       }
+                                       return jsObjRef;
+
+                               }       
+                               else
+                               {
+                                       LogDebug("Message Creation failed");
+                                       ThrowMsg(WrtDeviceApis::Commons::PlatformException, "message has been not created"); 
+                               }                                       
+
+                       }
+                       
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       return NULL;
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+                       return NULL;
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);     
+                       return NULL;
+               }
+               
+       }
+       else
+       {
+               LogDebug(" globalContext is NULL ");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);     
+               return NULL;
+       }
+       
+       return NULL;
+}
+
 JSValueRef JSMessage::convertToType(JSContextRef context,
         JSObjectRef object,
         JSType type,
@@ -311,11 +531,17 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
     LogInfo("enter");
     Try
     {
+         JSMessagePrivateObject* priv = static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
+        if (!priv)
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);        
+               
+         JSContextRef globalContext = priv->getContext();
+               
         ConverterMessageFactory::ConverterType converter =
             ConverterMessageFactory::getConverter(context);
         Api::Messaging::IMessagePtr msg = converter->toIMessage(object);
         Api::Messaging::MessageType msgType = msg->getMessageType();
-
+         LogInfo("msgType=" << msgType);
         // prepare common values
         JSCallbackManagerPtr emptyCallbackMgr = JSCallbackManager::createObject(
                 converter->toJSGlobalContext(object),
@@ -333,7 +559,7 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
                        if ( msgType == Api::Messaging::MMS )
                        {
                                Api::Messaging::AttachmentsPtr mmsAttachments =
-                                       DPL::StaticPointerCast<Api::Messaging::Attachments>(Api::Messaging::MessageFactory::convertToEmail(msg));
+                                       DPL::StaticPointerCast<Api::Messaging::Attachments>(Api::Messaging::MessageFactory::convertToMms(msg));
                                attachments = mmsAttachments->getAttachments();
                        }
                        else
@@ -351,9 +577,9 @@ JSValueRef JSMessage::getAttachments(JSContextRef context,
                        for (int index = 0 ; index < attachments.size(); index++ )
                        {
                                LogDebug( "Attachment ID : " << attachments[index]->getAttachmentID());
-                               jsMessageAttachmentObject[index] = JSMessageAttachment::createJS(context, attachments[index] );
+                               jsMessageAttachmentObject[index] = JSMessageAttachment::createJS(globalContext, attachments[index] );
                        }                       
-                       JSObjectRef result = JSObjectMakeArray(context, count, jsMessageAttachmentObject, NULL);
+                       JSObjectRef result = JSObjectMakeArray(globalContext, count, jsMessageAttachmentObject, NULL);
                        
                        return result;
                                                        
@@ -918,6 +1144,110 @@ JSValueRef JSMessage::getUID(JSContextRef context,
                return JSValueMakeUndefined(context);
        }
 
+bool JSMessage::setAttachments(JSContextRef context,
+        JSObjectRef object,
+        JSStringRef propertyName,
+        JSValueRef value,
+        JSValueRef* exception)
+{
+       LogInfo("enter");
+
+       Try
+       {
+        JSMessagePrivateObject* priv =
+            static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
+               if (priv) {
+
+                       JSContextRef globalContext = priv->getContext();
+                       if (!globalContext)
+                       {
+                               LogDebug("globalContext is NULL");
+                               globalContext = context;
+                       }
+                       ConverterMessageFactory::ConverterType converter =
+                       ConverterMessageFactory::getConverter(context);
+                       
+                       vector<IAttachmentPtr> attachments;
+                       if (JSIsArrayValue(context, value)) {
+                               JSObjectRef valueObj = converter->toJSObjectRef(value);
+                               unsigned int len = JSGetArrayLength(context, valueObj);
+                               LogDebug("Array Length = " << len);
+                               for (unsigned int i = 0; i < len; ++i) {
+
+                                       JSValueRef att = JSGetArrayElement(context, valueObj, i);
+                                       if (JSValueIsUndefined(context, att) || JSValueIsNull(context, att)) {
+                                           LogWarning("Invalid array element. Skipping.");
+                                           continue;
+                                       }
+                                       Api::Messaging::IAttachmentPtr attachment = converter->toIAttachment(att);
+
+                                       LogDebug("Adding attachment , shotname: " << attachment->getShortName());
+                                       attachments.push_back(attachment);
+                               }                               
+                       }
+                       else
+                       {       
+                               Api::Messaging::IAttachmentPtr attachment = converter->toIAttachment(value);
+                               LogDebug("Adding attachment , shotname: " << attachment->getShortName());
+                               attachments.push_back(attachment);
+                       }
+                       
+                       LogDebug("Attachment Size =" << attachments.size());
+                       if ( attachments.size() > 0)                            
+                       {
+                               Api::Messaging::IMessagePtr msg = converter->toIMessage(object);
+                               if (msg)
+                               {
+                                       Api::Messaging::MessageType msgType = msg->getMessageType();
+                                       switch (msgType) {
+                                               case Api::Messaging::MMS:
+                                               {
+                                                       Api::Messaging::IMmsPtr mms = Api::Messaging::MessageFactory::convertToMms(msg);
+                                                       mms->setAttachments(attachments);
+                                               break;
+                                               }
+                                               case Api::Messaging::EMAIL:
+                                               {
+                                                       Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+                                                       email->setAttachments(attachments);
+                                               break;
+                                               }
+                                               default:
+                                                       LogError("not supported message type");
+                                                       Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+                                       }
+                               
+                                       return true;
+                               }
+                               else
+                               {
+                                       LogError("Message converter failed...");
+                                       Throw(WrtDeviceApis::Commons::NullPointerException);
+                               }
+                       }
+                                                       
+               }
+         
+       }
+       Catch(WrtDeviceApis::Commons::ConversionException) {
+               LogError("Error on conversion");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+       }
+       Catch(WrtDeviceApis::Commons::NullPointerException) {
+               LogError("Error on pointer, null value");
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
+       Catch(WrtDeviceApis::Commons::UnsupportedException) {
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::NOT_SUPPORTED_ERROR, JSMESSAGING_EXCEPTION_MSG_NOT_SUPPORTED);
+       }
+       
+       return false;   
+}
+
+
 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
 bool JSMessage::setAttachments(JSContextRef context,
         JSObjectRef object,
@@ -1485,6 +1815,64 @@ JSValueRef JSMessage::getMessageStatus(JSContextRef context,
        return JSValueMakeUndefined(context);
 }
 
+
+JSValueRef JSMessage::hasAttachment(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception)
+{
+       LogInfo("hasAttachment");
+
+       Try
+       {
+               JSMessagePrivateObject* priv = static_cast<JSMessagePrivateObject*>(JSObjectGetPrivate(object));
+               Assert(priv && "Private object is NULL.");
+
+               JSContextRef globalContext = priv->getContext();
+
+               ConverterMessageFactory::ConverterType converter =  ConverterMessageFactory::getConverter(globalContext);
+
+               Api::Messaging::IMessagePtr msg = converter->toIMessage(object); //get message point
+
+               bool hasAttachmentFlag = false;
+
+                if ( msg->getMessageType() == EMAIL)
+                       {
+                       Api::Messaging::IEmailPtr email = Api::Messaging::MessageFactory::convertToEmail(msg);
+
+                       if (email->hasAttachment())
+                               hasAttachmentFlag = true;
+                       }
+               else if  ( msg->getMessageType() == MMS)
+               {
+                       Api::Messaging::IMmsPtr mms = Api::Messaging::MessageFactory::convertToMms(msg);
+
+                       if (mms->hasAttachment())
+                               hasAttachmentFlag = true;
+               }
+               else
+               {
+                        return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+               }
+                        
+               return converter->toJSValueRef(hasAttachmentFlag);
+                       
+       }
+       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::NullPointerException) {
+               LogError("Error on pointer, null value");
+         return JSTizenExceptionFactory::postException(context, exception, 
+                JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
+       
+       return JSValueMakeUndefined(context);
+}
+
 #if 0
 JSValueRef JSMessage::getAttachmentExistence(JSContextRef context,
                        JSObjectRef object,
index 7ea5d93..3d00ab5 100755 (executable)
@@ -88,6 +88,9 @@ class JSMessage
     static JSValueRef createJSObject(JSContextRef context,
                  const Api::Messaging::IMessagePtr& msg);
 
+       static JSValueRef createDummyMessageJSObject(JSContextRef context,
+               Api::Messaging::MessageType msgType);
+
   private:
     /**
      * The callback invoked when an object is first created.
@@ -157,6 +160,12 @@ class JSMessage
             JSValueRef possibleInstance,
             JSValueRef* exception);
 
+    static JSObjectRef constructor(JSContextRef ctx, 
+                       JSObjectRef constructor, 
+                       size_t argumentCount, 
+                       const JSValueRef arguments[], 
+                       JSValueRef* exception);
+
     /**
      * The callback invoked when converting an object to a particular JavaScript type.
      */
@@ -239,6 +248,12 @@ class JSMessage
             JSValueRef value,
             JSValueRef* exception);
 #endif
+    static bool setAttachments(JSContextRef context,
+            JSObjectRef object,
+            JSStringRef propertyName,
+            JSValueRef value,
+            JSValueRef* exception);
+
     static bool setBccAddress(JSContextRef context,
             JSObjectRef object,
             JSStringRef propertyName,
@@ -295,12 +310,16 @@ class JSMessage
                        JSStringRef propertyName,
                        JSValueRef* exception);
 
-
     static JSValueRef getMessageStatus(JSContextRef context,
                                JSObjectRef object,
                                JSStringRef propertyName,
                                JSValueRef* exception);
 
+    static JSValueRef hasAttachment(JSContextRef context,
+                               JSObjectRef object,
+                               JSStringRef propertyName,
+                               JSValueRef* exception);
+
     /**
      * This structure describes a statically declared function property.
      */
index 44bc12a..8d9e895 100755 (executable)
@@ -31,8 +31,9 @@
 #include <API/Filesystem/IManager.h>
 #include <Tizen/Common/JSTizenExceptionFactory.h>
 #include <Tizen/Common/JSTizenException.h>
-
+#include <API/Messaging/AttachmentFactory.h>
 #include "MessagingErrorMsg.h"
+#include <Messaging/Attachment.h>
 
 namespace {
 const char* MSG_ATTACHMENT_MIMETYPE            = "MIMEType";
@@ -49,6 +50,7 @@ using namespace TizenApis::Commons;
 using namespace TizenApis::Api::Messaging;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace TizenApis::Platform::Messaging;
 
 JSClassRef JSMessageAttachment::m_jsClassRef = NULL;
 
@@ -69,18 +71,19 @@ JSClassDefinition JSMessageAttachment::m_classInfo = {
     NULL, //deleteProperty,
     NULL, //getPropertyNames,
     NULL, //callAsFunction,
-    NULL, //callAsConstructor,
+    constructor, //callAsConstructor,
     NULL, //hasInstance,
     NULL, //convertToType,
 };
 
 JSStaticValue JSMessageAttachment::m_property[] = {
     //{ "MIMEType", JSMessageAttachment::getMIMEType, NULL, kJSPropertyAttributeReadOnly },
+    { "id", JSMessageAttachment::getContentID, NULL, kJSPropertyAttributeNone },
     { "messageId", JSMessageAttachment::getMessageID, NULL, kJSPropertyAttributeReadOnly },
     //{ "contentLocation", JSMessageAttachment::getContentLocation, NULL, kJSPropertyAttributeNone },
-    { "contentId", JSMessageAttachment::getContentID, NULL, kJSPropertyAttributeNone },
+    { "mimeType", JSMessageAttachment::getMIMEType, NULL, kJSPropertyAttributeReadOnly },
     { "loaded", JSMessageAttachment::getLoaded, NULL, kJSPropertyAttributeReadOnly },
-    { "file", JSMessageAttachment::getFile, NULL, kJSPropertyAttributeReadOnly },
+    { "filePath", JSMessageAttachment::getFile, NULL, kJSPropertyAttributeReadOnly },
     { 0, 0, 0, 0 }
 };
 const JSClassDefinition* JSMessageAttachment::getClassInfo()
@@ -99,7 +102,16 @@ JSClassRef JSMessageAttachment::getClassRef()
 void JSMessageAttachment::initialize(JSContextRef context,
         JSObjectRef object)
 {
-    LogDebug("enter");
+       LogDebug("enter");
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               IAttachmentPtr attachment(new Attachment());
+                                               
+               JSMessageAttachmentPrivate *priv = new JSMessageAttachmentPrivate(context, attachment);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
 }
 
 void JSMessageAttachment::finalize(JSObjectRef object)
@@ -188,6 +200,12 @@ JSValueRef JSMessageAttachment::getContentID(JSContextRef context,
                  
                  WrtDeviceApis::CommonsJavaScript::Converter converter(context);
                  LogDebug("Attachment Loaded :" << (attachment->getDownloaded() ));
+
+                 if ( attachment->getAttachmentID() < 0)
+                 {
+                        JSValueMakeUndefined(context);
+                 }
+                 
                  return converter.toJSValueRef(attachment->getAttachmentID());
            }
            Catch(WrtDeviceApis::Commons::InvalidArgumentException)
@@ -243,6 +261,53 @@ JSValueRef JSMessageAttachment::getFile(JSContextRef context,
           JSStringRef propertyName,
           JSValueRef* exception)
 {
+       LogDebug("enter");
+
+       JSMessageAttachmentPrivate* priv = static_cast<JSMessageAttachmentPrivate*>(JSObjectGetPrivate(object));
+       if (priv)
+               LogDebug("priv is vaild");
+       JSContextRef globalContext = priv ? priv->getContext() : context;
+       
+       Api::Messaging::IAttachmentPtr attachment = getAttachment(context, object);
+       
+       if ( attachment )
+       {
+               Try
+               {
+                       std::string fullPath = attachment->getFullPath();
+                       LogDebug("fullPath=" << fullPath);
+
+                       if (fullPath.empty()) {
+                               return JSValueMakeNull(context);
+                       }
+                       else
+                       {       
+                               WrtDeviceApis::CommonsJavaScript::Converter converter(context);
+                               std::string virtualpath = AttachmentFactory::getVirtualPathFromRealPath(globalContext, fullPath);       
+                               return converter.toJSValueRef(virtualpath);
+                       }
+               }
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException)
+               {
+                  LogError("invalid value conversion");
+                  return JSTizenExceptionFactory::postException(context, exception, 
+                          JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+               }
+               Catch(WrtDeviceApis::Commons::Exception)
+               {
+                   LogError("Unkown Exception");
+                   return JSTizenExceptionFactory::postException(context, exception, 
+                               JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+               }
+               return JSValueMakeUndefined(context);
+               
+       }
+       else
+       {
+               return JSTizenExceptionFactory::postException(context, exception, 
+                       JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);
+       }
+       
 #if 0 // MESSAGING ATTACHMENT IS BLOCKED
                LogDebug("enter");
                Try
@@ -341,7 +406,90 @@ JSMessageAttachmentPrivate* JSMessageAttachment::getPrivate(JSObjectRef thisObje
     return thisPrivate;
 }
 
+JSObjectRef JSMessageAttachment::constructor(JSContextRef context, 
+               JSObjectRef constructor, 
+               size_t argumentCount, 
+               const JSValueRef arguments[], 
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+       JSMessageAttachmentPrivate* priv = static_cast<JSMessageAttachmentPrivate*>(JSObjectGetPrivate(constructor));
+       JSContextRef globalContext = priv ? priv->getContext() : context;
+       
+       if (globalContext)
+       {
+               try
+               {
+                       LogDebug("argumentCount=" << argumentCount);
+                       if ( argumentCount < 1 || argumentCount > 2) {
+                               LogError("Wrong argument count");
+                               ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "Wrong Message argumentCount");
+                       }
+                       else
+                       {       
+                               ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
+                               
+                               std::string path = converter->toString(arguments[0]);   //filepath
+                               std::string mimetype;
+                               
+                               if ( argumentCount == 2)
+                                       mimetype = converter->toString(arguments[1]);   //filepath
+
+                               //IPathPtr src = Utils::fromVirtualPath(globalContext, path);
+                               path = AttachmentFactory::getRealPathFromVirtualPath(globalContext,path);
+                               LogDebug("real path = " << path);
+                               Api::Messaging::IAttachmentPtr attachment = AttachmentFactory::createAttachment(
+                                                                                   path,
+                                                                                   mimetype);
+                               if (attachment)
+                               {
+                                       JSClassRef jsClassRef = JSClassCreate(getClassInfo());
+                                       LogDebug("jsClassRef success");
+                                       JSMessageAttachmentPrivate* priv = new JSMessageAttachmentPrivate(globalContext, attachment);
+                                       LogDebug("priv success");
+                                       
+                                       JSObjectRef jsObjRef = JSObjectMake(globalContext, jsClassRef, static_cast<void*>(priv));
+                                       LogDebug("JSObjectMake success");
+                                       JSClassRelease(jsClassRef);
+                                       if (NULL == jsObjRef) {
+                                               LogError("object creation error");
+                                               ThrowMsg(WrtDeviceApis::Commons::PlatformException, "JSObject make error"); 
+                                       }
+                                       return jsObjRef;
+                               }
+                               else
+                               {
+                                       LogDebug("attachment can't create");
+                                       ThrowMsg(WrtDeviceApis::Commons::InvalidArgumentException, "attachment create failed..."); 
+                               }
+                       }
+
+               }       
+               Catch(WrtDeviceApis::Commons::InvalidArgumentException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, JSMESSAGING_EXCEPTION_MSG_INVALID_ARGUMENT);
+                       return NULL;
+               }
+               Catch(WrtDeviceApis::Commons::ConversionException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, JSMESSAGING_EXCEPTION_MSG_TYPE_MISMATCH);
+                       return NULL;
+               }
+               Catch(WrtDeviceApis::Commons::PlatformException) {
+                       *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);     
+                       return NULL;
+               }
+       }
+       else
+       {
+               LogDebug(" globalContext is NULL ");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, JSMESSAGING_EXCEPTION_MSG_UNKNOWN);     
+               return NULL;
+       }
+
+       return NULL;
 }
-}
 
 
+}
+}
+
index 42cca02..0788bb1 100755 (executable)
@@ -63,6 +63,11 @@ private:
             JSObjectRef object,
             JSStringRef propertyName);
 
+    static JSObjectRef constructor(JSContextRef ctx, 
+                       JSObjectRef constructor, 
+                       size_t argumentCount, 
+                       const JSValueRef arguments[], 
+                       JSValueRef* exception);
 
     /**
      * Get MIME Type of Attachment File.  readonly
index 1d0c080..1607ace 100755 (executable)
@@ -74,9 +74,9 @@ const char* JSMessageFolder::PATH = "path";
 const char* JSMessageFolder::TYPE = "type";
 const char* JSMessageFolder::SYNCHRONIZABLE = "synchronizable";
 
-const std::string JSMessageFolder::TYPE_SMS             = "tizen.sms";
-const std::string JSMessageFolder::TYPE_MMS             = "tizen.mms";
-const std::string JSMessageFolder::TYPE_EMAIL   = "tizen.email";
+const std::string JSMessageFolder::TYPE_SMS             = "messaging.sms";
+const std::string JSMessageFolder::TYPE_MMS             = "messaging.mms";
+const std::string JSMessageFolder::TYPE_EMAIL   = "messaging.email";
 
 const std::string JSMessageFolder::FOLDER_INBOX                 = "INBOX";
 const std::string JSMessageFolder::FOLDER_OUTBOX        = "OUTBOX";
index 501921d..a9092d9 100755 (executable)
@@ -40,6 +40,7 @@
 #include "MessagingErrorMsg.h"
 #include "ConverterMessage.h"
 #include "JSMessagingListener.h"
+#include "JSMessagingStorage.h"
 #include "JSMessage.h"
 #include "EventSendMessagePrivateData.h"       //for send message
 #include "EventMessagingServicePrivateData.h"
@@ -47,6 +48,7 @@
 
 using namespace std;
 using namespace DPL;
+using namespace WrtDeviceApis;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace TizenApis::Api::Messaging;
@@ -81,6 +83,7 @@ namespace Tizen1_0 {
            {"id",                      getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"type",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
            {"name",                            getProperty, NULL, kJSPropertyAttributeReadOnly},
+           {"messagingStorage",                                getProperty, NULL, kJSPropertyAttributeReadOnly},
            { 0, 0, 0, 0 }
        };
 
@@ -151,6 +154,10 @@ namespace Tizen1_0 {
                                        }
                                        
                                        retVal = converter->toJSValueRef(stream.str());
+                               } else if (JSStringIsEqualToUTF8CString(propertyName, "messagingStorage")) {
+                                       LogDebug("messagingStorage" << ":" <<  imessagingService->getAccountID());
+                                       JSContextRef l_globalContext = converter->toJSGlobalContext(object);                                    
+                                       retVal = JSUtils::makeObject(l_globalContext, JSMessagingStorage::getClassRef(), NULL);
                                } else{
                                        retVal = JSValueMakeUndefined(context);
                                }
@@ -363,8 +370,7 @@ JSValueRef JSMessagingService::sendMessage(JSContextRef context,
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr callbackManager = JSCallbackManager::createObject(globalContext);
     WrtDeviceApis::CommonsJavaScript::JSCallbackManagerPtr recipientCallbackManager;
 
-    ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);
-
+    ConverterMessageFactory::ConverterType converter = ConverterMessageFactory::getConverter(context);  
        Try {           
 
                if ( argumentCount > 1 && argumentCount < 4)
index 66a0248..efbb1e2 100755 (executable)
@@ -63,7 +63,7 @@ namespace Tizen1_0 {
        JSClassDefinition JSMessagingStorage::m_classInfo = {
                0,
                kJSClassAttributeNone,
-               "messageStorage",
+               "messagingStorage",
                NULL,
                NULL,
                m_function,
index 8a7104d..69253ce 100755 (executable)
@@ -15,7 +15,7 @@
         <Object name="messaging">
             <Function name="getMessageServices"/>
         </Object>
-    <Object name="messageStorage">
+    <Object name="messagingStorage">
             <Function name="addDraftMessage"/>    
             <Function name="findMessages"/>
             <Function name="removeMessages"/>
index 9eade7d..d7f2fff 100755 (executable)
@@ -18,6 +18,7 @@
 #include <Commons/plugin_initializer_def.h>
 #include "JSMessagingServiceManager.h"
 #include "JSMessagingStorage.h"
+#include "JSMessage.h"
 
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 #define OBJECT_MESSAGING ".messaging"
@@ -43,9 +44,14 @@ PLUGIN_CLASS_MAP_BEGIN
 #if 1
        PLUGIN_CLASS_MAP_ADD_CLASS(
                WRT_JS_EXTENSION_OBJECT_TIZEN OBJECT_MESSAGING,
-               "messageStorage",
+               "messagingStorage",
                TizenApis::Tizen1_0::JSMessagingStorage::getClassRef(),
                NULL)
 #endif
+     PLUGIN_CLASS_MAP_ADD_CLASS(
+               WRT_JS_EXTENSION_OBJECT_TIZEN,
+               "Message",
+               TizenApis::Tizen1_0::JSMessage::getClassRef(),
+               NULL) 
 
 PLUGIN_CLASS_MAP_END
index bf8dae4..93fedb6 100755 (executable)
@@ -12,6 +12,10 @@ set(SRCS
   JSNFCTagMifareUltra.cpp
        JSNdefMessage.cpp
        JSNdefRecord.cpp
+       JSNdefRecordText.cpp
+       JSNdefRecordURI.cpp
+       JSNdefRecordMedia.cpp
+       JSNdefRecordArray.cpp
        JSNFCTarget.cpp
        NFCConverter.cpp
        EventNFCChangedPrivateData.cpp
index 5fec926..0e528fd 100755 (executable)
@@ -102,12 +102,6 @@ JSStaticFunction JSNFCManager::m_function[] = {
        {"setSEEventListener",      JSNFCManager::setSEEventListener, kJSPropertyAttributeNone },
        {"unsetSEEventListener",       JSNFCManager::unsetSEEventListener, kJSPropertyAttributeNone},
        {"getCachedMessage", JSNFCManager::getCachedMessage, kJSPropertyAttributeNone},
-       {"createNDEFMessage", JSNFCManager::createNDEFMessage, kJSPropertyAttributeNone},
-       {"createNDEFMessageFromRawData", JSNFCManager::createNDEFMessageFromRawData, kJSPropertyAttributeNone},
-       {"createNDEFRecord", JSNFCManager::createNDEFRecord, kJSPropertyAttributeNone},
-       {"createNDEFRecordText", JSNFCManager::createNDEFRecordText, kJSPropertyAttributeNone},
-       {"createNDEFRecordURI", JSNFCManager::createNDEFRecordURI, kJSPropertyAttributeNone},
-       {"createNDEFRecordMedia", JSNFCManager::createNDEFRecordMedia, kJSPropertyAttributeNone},
        { 0, 0, 0}
 };
 
@@ -184,7 +178,7 @@ JSValueRef JSNFCManager::getProperty(JSContextRef context, JSObjectRef object,
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
 
-       return JSValueMakeUndefined(context);
+    return JSValueMakeUndefined(context);
 }
 
 JSValueRef JSNFCManager::setTagListener (JSContextRef context, JSObjectRef object,
@@ -204,10 +198,10 @@ JSValueRef JSNFCManager::setTagListener (JSContextRef context, JSObjectRef objec
        AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount == 0) {
+       if ((argumentCount == 0) || (argumentCount > 3)) {
                /* Argument count must be 1, 2 or 3. */
                LogError("JSNFCManager::setTagListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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. */
@@ -248,8 +242,7 @@ JSValueRef JSNFCManager::setTagListener (JSContextRef context, JSObjectRef objec
                //process the filter object
                TagFilterPtr tagFilter;
                if ((argumentCount > 2) &&  !JSValueIsNull(context, arguments[2])) {
-                       if (!JSValueIsNull(context, arguments[2]) &&
-                               !JSValueIsUndefined(context, arguments[2]) &&
+                       if (!JSValueIsUndefined(context, arguments[2]) &&
                                JSIsArrayValue(context, arguments[2])) {
                                        tagFilter = nfcConverter.toNFCTagFilter(arguments[2]);
 
@@ -279,12 +272,18 @@ JSValueRef JSNFCManager::setTagListener (JSContextRef context, JSObjectRef objec
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::setTagListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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);
        }
-       return JSValueMakeUndefined(context);
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeNull(context);
 }
 
 JSValueRef JSNFCManager::setPeerListener (JSContextRef context, JSObjectRef object,
@@ -304,10 +303,10 @@ JSValueRef JSNFCManager::setPeerListener (JSContextRef context, JSObjectRef obje
        AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_P2P_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount == 0) {
-               /* Argument count must be 1, 2 or 3. */
+       if ((argumentCount == 0) || (argumentCount > 2)) {
+               /* Argument count must be 1 or 2. */
                LogError("JSNFCManager::setPeerListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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. */
@@ -363,12 +362,18 @@ JSValueRef JSNFCManager::setPeerListener (JSContextRef context, JSObjectRef obje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::setPeerListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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);
        }
-       return JSValueMakeUndefined(context);
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeNull(context);
 }
 
 JSValueRef JSNFCManager::setNDEFListener (JSContextRef context, JSObjectRef object,
@@ -387,10 +392,10 @@ JSValueRef JSNFCManager::setNDEFListener (JSContextRef context, JSObjectRef obje
        AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount == 0) {
+       if ((argumentCount == 0) || (argumentCount > 2)) {
                /* Argument count must be 1 or 2. */
                LogError("JSNFCManager::setNDEFListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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. */
@@ -433,12 +438,18 @@ JSValueRef JSNFCManager::setNDEFListener (JSContextRef context, JSObjectRef obje
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::setNDEFListener InvalidArgumentException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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);
        }
-       return JSValueMakeUndefined(context);
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeNull(context);
 }
 
 JSValueRef JSNFCManager::setSEEventListener (JSContextRef context, JSObjectRef object,
@@ -457,10 +468,10 @@ JSValueRef JSNFCManager::setSEEventListener (JSContextRef context, JSObjectRef o
        AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_SE_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-       if (argumentCount == 0) {
+       if ((argumentCount == 0) || (argumentCount > 2)) {
                /* Argument count must be 1 or 2. */
                LogError("JSNFCManager::setSEEventListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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. */
@@ -500,15 +511,21 @@ JSValueRef JSNFCManager::setSEEventListener (JSContextRef context, JSObjectRef o
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::setSEEventListener : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::setSEEventListener InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
        }
-       return JSValueMakeUndefined(context);
+       callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       return JSValueMakeNull(context);
 }
 
 JSValueRef JSNFCManager::unsetTagListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
@@ -524,17 +541,23 @@ JSValueRef JSNFCManager::unsetTagListener(JSContextRef context, JSObjectRef obje
        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 JSValueMakeUndefined(context);
+               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 JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSNFCManager::unsetPeerListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
@@ -550,17 +573,23 @@ JSValueRef JSNFCManager::unsetPeerListener(JSContextRef context, JSObjectRef obj
        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 JSValueMakeUndefined(context);
+               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 JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSNFCManager::unsetNDEFListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
@@ -576,17 +605,23 @@ JSValueRef JSNFCManager::unsetNDEFListener(JSContextRef context, JSObjectRef obj
        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 JSValueMakeUndefined(context);
+               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 JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSNFCManager::unsetSEEventListener(JSContextRef context, JSObjectRef object, JSObjectRef thisObject,
@@ -602,17 +637,23 @@ JSValueRef JSNFCManager::unsetSEEventListener(JSContextRef context, JSObjectRef
        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 JSValueMakeUndefined(context);
+               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 JSValueMakeUndefined(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSNFCManager::getCachedMessage (JSContextRef context, JSObjectRef object,
@@ -630,7 +671,13 @@ JSValueRef JSNFCManager::getCachedMessage (JSContextRef context, JSObjectRef obj
        AceSecurityStatus status = NFC_CHECK_ACCESS(global_context, NFC_FUNCTION_API_TAG_FUNCS);
        TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-Try {
+       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)
@@ -645,244 +692,7 @@ Try {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
-       return JSValueMakeUndefined(context);
-}
-
-JSValueRef JSNFCManager::createNDEFMessage(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 1) || JSValueIsNull(context, arguments[0])) {
-                       LogError("NdefRecordArray parameter is JSNull/JSUndefined/Not Number");
-                       return JSNdefMessage::createJSObject(privateObject->getContext());
-               } else if ((JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0]))) {
-                       Throw(ConversionException);
-               }
-
-               return JSNdefMessage::createJSObject(privateObject->getContext(), convert.toVectorOfRecordHandles(arguments[0]));
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::createNDEFMessageFromRawData(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 1) || JSValueIsNull(context, arguments[0])) {
-                       LogError("NdefRecordArray parameter is JSNull/JSUndefined/Not Number");
-                       return JSNdefMessage::createJSObject(privateObject->getContext());
-               } else if ((JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0]))) {
-                       Throw(ConversionException);
-               }
-
-               return JSNdefMessage::createJSObject(privateObject->getContext(), convert.toVectorOfUChars(arguments[0]));
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::createNDEFRecord(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 2) || (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]))
-                       || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSIsArrayValue(context, arguments[1]))) {
-                       LogError("parameter is JSNull/JSUndefined/Not array");
-                       Throw(ConversionException);
-               }
-
-               return JSNdefRecord::createJSObject(privateObject->getContext(), convert.toNdefRecordProperties(arguments[0], exception), convert.toVectorOfUChars(arguments[1]));
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::createNDEFRecordText(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 2) || (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsString(context, arguments[0]))
-                       || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSValueIsString(context, arguments[1]))) {
-                       LogError("parameter is JSNull/JSUndefined/Not array");
-                       Throw(ConversionException);
-               }
-
-               short encodeType = NFC_TEXT_ENCODE_UTF_8;
-
-               if ((argumentCount > 2) && (!JSValueIsNull(context, arguments[2]))) {
-                       if (JSValueIsUndefined(context, arguments[2]) || !JSValueIsString(context, arguments[2]))
-                               Throw(ConversionException);
-                       encodeType = convert.toNfcTextEncodeUTF(convert.toString(arguments[2]));
-               }
-
-               return JSNdefRecord::createJSObject(privateObject->getContext(), convert.toString(arguments[0]), convert.toString(arguments[1]), encodeType);
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::createNDEFRecordURI(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 1) || (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsString(context, arguments[0]))) {
-                       LogError("parameter is JSNull/JSUndefined/Not array");
-                       Throw(ConversionException);
-               }
-
-               return JSNdefRecord::createJSObject(privateObject->getContext(), convert.toString(arguments[0]));
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNFCManager::createNDEFRecordMedia(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered ");
-       Try {
-               NFCManagerPrivObject* privateObject = static_cast<NFCManagerPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INFCManagerPtr NFCManager(privateObject->getObject());
-               NFCConverter convert(context);
-
-               if ((argumentCount < 2) || (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsString(context, arguments[0]))
-                       || (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || !JSIsArrayValue(context, arguments[1]))) {
-                       LogError("parameter is JSNull/JSUndefined/Not array");
-                       Throw(InvalidArgumentException);
-               }
-
-               return JSNdefRecord::createJSObject(privateObject->getContext(), convert.toString(arguments[0]), convert.toVectorOfUChars(arguments[1]));
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 }
index bd484d0..d2dc969 100755 (executable)
@@ -127,48 +127,6 @@ private:
                size_t argumentCount,
                const JSValueRef arguments[],
                JSValueRef* exception);
-
-    static JSValueRef createNDEFMessage(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef createNDEFMessageFromRawData(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef createNDEFRecord(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef createNDEFRecordText(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef createNDEFRecordURI(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef createNDEFRecordMedia(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
 };
 
 }
index 56bdbd9..779acfd 100755 (executable)
@@ -71,7 +71,7 @@ namespace Tizen1_0 {
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     NULL, //CallAsConstructor,
-    NULL, //HasInstance,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -177,6 +177,8 @@ JSValueRef JSNFCTag::getProperty(JSContextRef context, JSObjectRef object,
                        INFCManagerPtr NFCManager(privateNFCManager->getObject());
                        return convert.toJSValueRef(NFCManager->isValidHandle(NFCTag->getHandle()));
                }
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -185,6 +187,14 @@ JSValueRef JSNFCTag::getProperty(JSContextRef context, JSObjectRef object,
        return JSValueMakeUndefined(context);
 }
 
+bool JSNFCTag::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
 JSValueRef JSNFCTag::readNDEF(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
@@ -205,9 +215,9 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
 
        Validator validator(context, exception);
 
-       if (argumentCount < 1) {
+       if ((argumentCount == 0) || (argumentCount > 2)) {
                LogError("JSNFCTag::readNDEF TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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. */
@@ -244,15 +254,21 @@ JSValueRef JSNFCTag::readNDEF(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::readNDEF : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::readNDEF InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -277,11 +293,11 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2 ) {
+       if ((argumentCount < 1) || (argumentCount > 3)) {
                LogError("JSNFCTag::writeNdef TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        }
-       if (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])))) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
                LogError("JSNFCTag::writeNdef TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -293,7 +309,7 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[1])) {
+       if ((argumentCount > 1) && (validator.isCallback(arguments[1]))) {
                onSuccessForCbm = arguments[1];
        }
 
@@ -315,15 +331,21 @@ JSValueRef JSNFCTag::writeNDEF(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::writeNDEF : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::writeNDEF InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -348,9 +370,9 @@ JSValueRef JSNFCTag::transceive(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2 ) {
+       if ((argumentCount < 2) || (argumentCount > 3)) {
                LogError("JSNFCTag::transceive TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        }
 
        if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSIsArrayValue(context, arguments[0])) {
@@ -393,15 +415,21 @@ JSValueRef JSNFCTag::transceive(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::transceive : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::transceive InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -426,11 +454,11 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 1) {
+       if (argumentCount > 3) {
                LogError("JSNFCTag::formatNDEF TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               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("JSNFCTag::formatNDEF TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
@@ -442,7 +470,7 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
        }
        
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[0])) {
+       if ((argumentCount > 0) && (validator.isCallback(arguments[0]))) {
                onSuccessForCbm = arguments[0];
        }
 
@@ -472,15 +500,21 @@ JSValueRef JSNFCTag::formatNDEF(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::formatNDEF : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::formatNDEF InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
index adc2caa..cf2d992 100755 (executable)
@@ -75,6 +75,14 @@ private:
     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);
+
     static JSValueRef readNDEF(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
index a5fe44f..a72bef0 100755 (executable)
@@ -64,7 +64,7 @@ namespace Tizen1_0 {
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     NULL, //CallAsConstructor,
-    NULL, //HasInstance,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -124,6 +124,14 @@ 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,
@@ -145,30 +153,30 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyA(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyA TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::authenticateWithKeyA key or sectorIndex TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::authenticateWithKeyA ErrorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
+       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
                onSuccessForCbm = arguments[2];
        }
        if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
@@ -187,15 +195,21 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyA(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::authenticateWithKeyA : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::authenticateWithKeyA InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -220,25 +234,25 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyB(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareClassic::authenticateWithKeyB TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::authenticateWithKeyB key or sectorIndex TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::authenticateWithKeyB ErrorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
@@ -262,15 +276,21 @@ JSValueRef JSNFCTagMifareClassic::authenticateWithKeyB(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::authenticateWithKeyB : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::authenticateWithKeyB InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -295,24 +315,24 @@ JSValueRef JSNFCTagMifareClassic::readBlock(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2) {
-               LogError("JSNFCTagMifareClassic::readBlock TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::readBlock errorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
@@ -336,15 +356,21 @@ JSValueRef JSNFCTagMifareClassic::readBlock(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::readBlock : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::readBlock InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -369,30 +395,30 @@ JSValueRef JSNFCTagMifareClassic::writeBlock(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareClassic::writeBlock TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::writeBlock blockIndex or block TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::writeBlock errorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
+       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
                onSuccessForCbm = arguments[2];
        }
        if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
@@ -411,15 +437,21 @@ JSValueRef JSNFCTagMifareClassic::writeBlock(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::writeBlock : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR,"Invalid Parameter"));
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::writeBlock InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -444,30 +476,30 @@ JSValueRef JSNFCTagMifareClassic::incrementBlockValue(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareClassic::incrementBlockValue TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::incrementBlockValue index or value TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::incrementBlockValue errorCallbackTypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
+       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
                onSuccessForCbm = arguments[2];
        }
        if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
@@ -486,15 +518,21 @@ JSValueRef JSNFCTagMifareClassic::incrementBlockValue(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::incrementBlockValue : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::incrementBlockValue InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -519,30 +557,30 @@ JSValueRef JSNFCTagMifareClassic::decrementBlockValue(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareClassic::decrementBlockValue TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::decrementBlockValue index or value TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::decrementBlockValue errorCallbackTypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
+       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
                onSuccessForCbm = arguments[2];
        }
        if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
@@ -561,15 +599,21 @@ JSValueRef JSNFCTagMifareClassic::decrementBlockValue(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::decrementBlockValue : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::decrementBlockValue InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -593,29 +637,29 @@ JSValueRef JSNFCTagMifareClassic::transfer(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2) {
-               LogError("JSNFCTagMifareClassic::transfer TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::transfer 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])) {
+       if ((argumentCount > 2) && !JSValueIsNull(context, arguments[2]) && (JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2]))) {
                /* 2nd argument must be Callback. */
-               LogError("JSNFCTagMifareClassic::transfer TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::transfer errorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
        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]))) {
@@ -634,15 +678,21 @@ JSValueRef JSNFCTagMifareClassic::transfer(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::transfer : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::transfer InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -666,29 +716,29 @@ JSValueRef JSNFCTagMifareClassic::restore(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2) {
-               LogError("JSNFCTagMifareClassic::restore TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::restore 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])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareClassic::restore errorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
        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]))) {
@@ -704,18 +754,24 @@ JSValueRef JSNFCTagMifareClassic::restore(JSContextRef context,
                event->setForAsynchronousCall(&NFCResponseDispatcher::getInstance());
                NFCTagMifareClassic->restore(event);
                
-               return JSValueMakeNull(context);;
+               return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::restore : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::restore InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
index 14b9516..303f22c 100755 (executable)
@@ -68,6 +68,14 @@ private:
      */
     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,
index 103e994..f0bb6f4 100755 (executable)
@@ -64,7 +64,7 @@ namespace Tizen1_0 {
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     NULL, //CallAsConstructor,
-    NULL, //HasInstance,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -119,6 +119,14 @@ 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,
@@ -140,24 +148,24 @@ JSValueRef JSNFCTagMifareUltra::readPage(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2) {
-               LogError("JSNFCTagMifareUltra::readPage TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareUltra::readPage errorCallback TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
@@ -181,15 +189,21 @@ JSValueRef JSNFCTagMifareUltra::readPage(JSContextRef context,
                return JSValueMakeNull(context);;
        } Catch (ConversionException) {
                LogError("JSNFCManager::readPage : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::readPage InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -214,30 +228,30 @@ JSValueRef JSNFCTagMifareUltra::writePage(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 3) {
-               LogError("JSNFCTagMifareUltra::writePage TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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 TypeMismatchException!");
+               LogError("JSNFCTagMifareUltra::writePage pageIndex or page TypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
-       if (JSValueIsNull(context, arguments[2]) || JSValueIsUndefined(context, arguments[2]) || !validator.isCallback(arguments[2])) {
+       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 TypeMismatchException!");
+               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 TypeMismatchException!");
+               LogError("JSNFCTagMifareUltra::writePage errorCallbackTypeMismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
        
        JSValueRef onSuccessForCbm = NULL, onErrorForCbm = NULL;
-       if (validator.isCallback(arguments[2])) {
+       if ((argumentCount > 2) && (validator.isCallback(arguments[2]))) {
                onSuccessForCbm = arguments[2];
        }
        if ((argumentCount > 3) && (validator.isCallback(arguments[3]))) {
@@ -256,15 +270,21 @@ JSValueRef JSNFCTagMifareUltra::writePage(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::writePage : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::writePage InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
index bb33c41..da43d70 100755 (executable)
@@ -68,8 +68,12 @@ private:
     static void finalize(JSObjectRef object);
 
     /**
-     * Getters and setters for properties
+     * 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 readPage(JSContextRef context,
                JSObjectRef object,
index bcfa492..84633be 100755 (executable)
@@ -66,7 +66,7 @@ namespace Tizen1_0 {
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     NULL, //CallAsConstructor,
-    NULL, //HasInstance,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -155,12 +155,22 @@ JSValueRef JSNFCTarget::getProperty(JSContextRef context, JSObjectRef object,
                }
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
        return JSValueMakeUndefined(context);
 }
 
+bool JSNFCTarget::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
 JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
@@ -182,19 +192,19 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 1) {
-               LogError("JSNFCTarget::setReceiveNDEFListener TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       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])) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTarget::setReceiveNDEFListener TypeMismatchException!");
+               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])) {
                        /* 2nd argument must be Callback. */
-                       LogError("JSNFCTarget::setReceiveNDEFListener TypeMismatchException!");
+                       LogError("JSNFCTarget::setReceiveNDEFListener errorCallback TypeMismatchException!");
                        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
                }
        }
@@ -220,15 +230,21 @@ JSValueRef JSNFCTarget::setReceiveNDEFListener(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::setReceiveNDEFListener : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::setReceiveNDEFListener InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
@@ -241,6 +257,11 @@ 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");
+               }
+
                NFCTargetPrivObject* privateObject = static_cast<NFCTargetPrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
@@ -265,7 +286,7 @@ JSValueRef JSNFCTarget::unsetReceiveNDEFListener(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeNull(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 JSValueRef JSNFCTarget::sendNDEF(JSContextRef context,
@@ -290,18 +311,18 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context,
        NFCConverter convert(context);
        Validator validator(context, exception);
 
-       if (argumentCount < 2 ) {
-               LogError("JSNFCTarget::sendNDEF TypeMismatchException");
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       if ((argumentCount < 1) || (argumentCount > 3)) {
+               LogError("JSNFCTarget::sendNDEF argumentCount error");
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        }
-       if (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]))) {
                /* 1st argument is mandatory. And 1st argument must be Callback. */
-               LogError("JSNFCTarget::sendNDEF TypeMismatchException!");
+               LogError("JSNFCTarget::sendNDEF 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("JSNFCTarget::sendNDEF TypeMismatchException!");
+               LogError("JSNFCTarget::sendNDEF errorCallbackType MismatchException!");
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        }
 
@@ -326,15 +347,21 @@ JSValueRef JSNFCTarget::sendNDEF(JSContextRef context,
                return JSValueMakeNull(context);
        } Catch (ConversionException) {
                LogError("JSNFCManager::sendNDEF : ConversionException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
                LogError("JSNFCManager::sendNDEF InvalidArgumentException");
-               callbackManager->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"Invalid Parameter"));
+               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);
 }
 
index 7c101c0..849ca44 100755 (executable)
@@ -75,6 +75,14 @@ private:
     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);
+
     static JSValueRef setReceiveNDEFListener(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
index c16697f..db7e698 100755 (executable)
 
 #include "JSNdefMessage.h"
 #include "JSNdefRecord.h"
+#include "JSNdefRecordText.h"
+#include "JSNdefRecordURI.h"
+#include "JSNdefRecordMedia.h"
+#include "JSNdefRecordArray.h"
 #include "NFCConverter.h"
 
 #include <dpl/log/log.h>
@@ -35,11 +39,9 @@ using namespace TizenApis::Commons;
 using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 
-namespace {
-    const char* TIZEN10_NDEFMESSAGE_ATTRIBUTENAME     = "NDEFMessage";
-
-    const char* TIZEN10_NDEFMESSAGE_RECORDCOUNT= "recordCount";
-}
+#define TIZEN10_NDEFMESSAGE_ATTRIBUTENAME "NDEFMessage"
+#define TIZEN10_NDEFMESSAGE_RECORDCOUNT "recordCount"
+#define TIZEN10_NDEFMESSAGE_RECORDS "records"
 
 namespace TizenApis {
 namespace Tizen1_0 {
@@ -56,12 +58,12 @@ namespace Tizen1_0 {
     finalize,
     NULL, //hasProperty,
     NULL,
-    NULL, //setProperty,
+    setProperty, //setProperty,
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
-    NULL, //CallAsConstructor,
-    NULL, //HasInstance,
+    constructor, //CallAsConstructor,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -70,15 +72,13 @@ JSStaticValue JSNdefMessage::m_property[] =
     //NdefMessageProperties
     { TIZEN10_NDEFMESSAGE_RECORDCOUNT, getProperty,
             NULL, kJSPropertyAttributeReadOnly},
+     { TIZEN10_NDEFMESSAGE_RECORDS, getProperty,
+            setProperty, kJSPropertyAttributeNone},
     { 0, 0, 0, 0 }
 };
 
 JSStaticFunction JSNdefMessage::m_function[] = {
     {"toByte", JSNdefMessage::toByte, kJSPropertyAttributeNone},
-    {"getNDEFRecord", JSNdefMessage::getNDEFRecord, kJSPropertyAttributeNone},
-    {"insertNDEFRecord", JSNdefMessage::insertNDEFRecord, kJSPropertyAttributeNone},
-    {"appendNDEFRecord", JSNdefMessage::appendNDEFRecord, kJSPropertyAttributeNone},
-    {"removeNDEFRecord", JSNdefMessage::removeNDEFRecord, kJSPropertyAttributeNone},
     { 0, 0, 0}
 };
 
@@ -112,6 +112,18 @@ JSObjectRef JSNdefMessage::createJSObject(JSContextRef context) {
        return JSObjectMake(context, getClassRef(), priv);
 }
 
+JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, INdefMessagePtr message) {
+       LogDebug("entered");
+
+       NdefMessagePrivObject *priv = new NdefMessagePrivObject(context, message);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefMessage object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
 JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, std::vector<void *> ndefRcords) {
        LogDebug("entered");
 
@@ -141,6 +153,16 @@ JSObjectRef JSNdefMessage::createJSObject(JSContextRef context, std::vector<unsi
 }
 void JSNdefMessage::initialize(JSContextRef context, JSObjectRef object)
 {
+       LogDebug("entered");
+
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject();
+               NdefMessagePrivObject *priv = new NdefMessagePrivObject(context, NdefMessage);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
 }
 
 void JSNdefMessage::finalize(JSObjectRef object)
@@ -166,6 +188,66 @@ const JSClassDefinition* JSNdefMessage::getClassInfo()
        return &m_classInfo;
 }
 
+JSObjectRef JSNdefMessage::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       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])))
+                               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]));
+                       }
+
+                       JSObjectRef objArg = convert.toJSObjectRef(arguments[0]);
+                       if (JSGetArrayLength(ctx, objArg) > 0) {
+                               JSValueRef element;
+                               for (std::size_t i = 0; i < JSGetArrayLength(ctx, objArg); ++i) {
+                                       element = JSGetArrayElement(ctx, objArg, i);
+                                       if (!JSValueIsNull(ctx, element))
+                                               break;
+                               }
+                               if (JSValueIsNull(ctx, element))
+                                       return createJSObject(global_context);
+                               else if (convert.isNdefRecord(element))
+                                       return createJSObject(global_context, convert.toVectorOfRecordHandles(arguments[0]));
+                               else
+                                       return createJSObject(global_context, convert.toVectorOfUChars(arguments[0]));
+                       } else
+                               return createJSObject(global_context);
+               }
+               else
+                       ThrowMsg(InvalidArgumentException, "ArgumentCount is not correct");
+
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
+}
+
 JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
         JSStringRef propertyName, JSValueRef* exception)
 {
@@ -179,163 +261,85 @@ JSValueRef JSNdefMessage::getProperty(JSContextRef context, JSObjectRef object,
                }
 
                INdefMessagePtr NdefMessage(privateObject->getObject());
-               Converter convert(context);
+               NFCConverter convert(context);
 
+               LogDebug("propertyName : " << convert.toString(propertyName));
                if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFMESSAGE_RECORDCOUNT)) {
                        return convert.toJSValueRefLong(NdefMessage->getRecordCount());
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFMESSAGE_RECORDS)) {
+                       return JSNdefRecordArray::createArray(privateObject->getContext(), NdefMessage);
                }
-
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
        }
        return JSValueMakeUndefined(context);
 }
 
-JSValueRef JSNdefMessage::toByte(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
+bool JSNdefMessage::setProperty(JSContextRef context, JSObjectRef object,
+        JSStringRef propertyName, JSValueRef value,  JSValueRef* exception)
 {
-       LogDebug("Entered ");
-       Try {
-               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");
-               }
-
-               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) {
-               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");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       return JSValueMakeNull(context);
-}
-
-JSValueRef JSNdefMessage::getNDEFRecord(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-       Try {
-               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");
-               }
-
-               AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (argumentCount < 1) {
-                       LogError("Wrong argument count");
-                       Throw(InvalidArgumentException);
-               }
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-                       LogError("Index parameter is JSNull/JSUndefined/Not Number");
-                       Throw(InvalidArgumentException);
-               }
-
-               INdefMessagePtr NdefMessage(privateObject->getObject());
-               NFCConverter convert(context);
+       LogDebug("Enter");
 
-               return JSNdefRecord::createJSObject(privateObject->getContext(), NdefMessage->getNDEFRecord(convert.toLong(arguments[0])));
+       Try     {
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFMESSAGE_RECORDS)) {
+                       NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+                       if (!privateObject) {
+                               LogError("Private object is not set.");
+                               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))) {
+                               LogError("value is invald.");
+                               ThrowMsg(ConversionException, "value is invald.");
+                       }
+
+                       NdefMessagePrivObject *priv;
+                       if (JSNdefRecordArray::isObjectOfClass(context, value))
+                               priv = new NdefMessagePrivObject(context, JSNdefRecordArray::getNdefRecordArray(context, value));
+                       else {
+                               std::vector<void *> records = convert.toVectorOfRecordHandles(value);
+                               priv = new NdefMessagePrivObject(context, NFCFactory::getInstance().createNDEFMessageObject(records));
+                       }
+                       if (!JSObjectSetPrivate(object, priv)) {
+                               delete priv;
+                                       ThrowMsg(NullPointerException, "Private object not set");
+                       }
+                       delete privateObject;
+                       return true;
+                }
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
        } Catch (InvalidArgumentException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
        } Catch (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
+       return false;
 
-       return JSValueMakeNull(context);
 }
 
-JSValueRef JSNdefMessage::insertNDEFRecord(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
+bool JSNdefMessage::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
         JSValueRef* exception)
 {
-       LogDebug("Entered ");
-       Try {
-               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");
-               }
-
-               AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (argumentCount < 2) {
-                       LogError("Wrong argument count");
-                       Throw(InvalidArgumentException);
-               }
-               if ((JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) ||
-                       (JSValueIsNull(context, arguments[1]) || JSValueIsUndefined(context, arguments[1]) || (!JSValueIsObjectOfClass(context, arguments[1], JSNdefRecord::getClassRef())))) {
-                       LogError("Index parameter is JSNull/JSUndefined/Not Number");
-                       Throw(InvalidArgumentException);
-               }
-
-               INdefMessagePtr NdefMessage(privateObject->getObject());
-               NFCConverter convert(context);
-
-               long index = convert.toLong(arguments[0]);
-               void *record = convert.getRecordHandle(arguments[1]);
-
-               NdefMessage->insertNDEFRecord(index, record);
-       } Catch (InvalidArgumentException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
-JSValueRef JSNdefMessage::appendNDEFRecord(JSContextRef context,
+JSValueRef JSNdefMessage::toByte(JSContextRef context,
         JSObjectRef object,
         JSObjectRef thisObject,
         size_t argumentCount,
@@ -344,54 +348,11 @@ JSValueRef JSNdefMessage::appendNDEFRecord(JSContextRef context,
 {
        LogDebug("Entered ");
        Try {
-               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");
-               }
-
-               AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               if (argumentCount < 1) {
-                       LogError("Wrong argument count");
-                       Throw(InvalidArgumentException);
+               if (argumentCount != 0) {
+                       LogError("JSNdefMessage::toByte TypeMismatchException");
+                       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
                }
 
-               INdefMessagePtr NdefMessage(privateObject->getObject());
-               NFCConverter convert(context);
-
-               void *record = convert.getRecordHandle(arguments[0]);
-
-               NdefMessage->appendNDEFRecord(record);
-       } Catch (InvalidArgumentException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
-       } Catch(ConversionException) {
-               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");
-       } Catch(NullPointerException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               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 JSValueMakeNull(context);
-}
-
-JSValueRef JSNdefMessage::removeNDEFRecord(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
-        JSValueRef* exception)
-{
-       LogDebug("Entered ");
-       Try {
                NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
                if (NULL == privateObject) {
                        LogError("private object is null");
@@ -401,25 +362,10 @@ JSValueRef JSNdefMessage::removeNDEFRecord(JSContextRef context,
                AceSecurityStatus status = NFC_CHECK_ACCESS(privateObject->getContext(),NFC_FUNCTION_API_TAG_P2P_FUNCS);
                TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
-               if (argumentCount < 1) {
-                       LogError("Wrong argument count");
-                       Throw(InvalidArgumentException);
-               }
-               if (JSValueIsNull(context, arguments[0]) || JSValueIsUndefined(context, arguments[0]) || !JSValueIsNumber(context, arguments[0])) {
-                       LogError("Index parameter is JSNull/JSUndefined/Not Number");
-                       Throw(InvalidArgumentException);
-               }
-
                INdefMessagePtr NdefMessage(privateObject->getObject());
                NFCConverter convert(context);
 
-               NdefMessage->removeNDEFRecord(convert.toLong(arguments[0]));
-       } Catch (InvalidArgumentException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Value");
-       } Catch(ConversionException) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return convert.toJSValueRef(NdefMessage->toByte());
        } Catch (PlatformException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
@@ -431,7 +377,7 @@ JSValueRef JSNdefMessage::removeNDEFRecord(JSContextRef context,
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
 
-       return JSValueMakeNull(context);
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
 }
 
 }
index 983f72c..b069c86 100755 (executable)
@@ -38,6 +38,7 @@ public:
 
     static JSObjectRef createJSObject(JSContextRef context);
     static JSObjectRef createJSObject(JSContextRef context, void *messageHandle);
+    static JSObjectRef createJSObject(JSContextRef context, Api::NFC::INdefMessagePtr message);
     static JSObjectRef createJSObject(JSContextRef context, std::vector<void *> ndefRcords);
     static JSObjectRef createJSObject(JSContextRef context, std::vector<unsigned char> rawdata);
 
@@ -72,41 +73,24 @@ private:
      */
     static void finalize(JSObjectRef object);
 
+    static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
     /**
      * Getters and setters for properties
      */
     static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
             JSStringRef propertyName, JSValueRef* exception);
-
-    static JSValueRef toByte(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef getNDEFRecord(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef insertNDEFRecord(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
-               JSValueRef* exception);
-
-    static JSValueRef appendNDEFRecord(JSContextRef context,
-               JSObjectRef object,
-               JSObjectRef thisObject,
-               size_t argumentCount,
-               const JSValueRef arguments[],
+    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,
+            JSObjectRef constructor,
+            JSValueRef possibleInstance,
                JSValueRef* exception);
 
-    static JSValueRef removeNDEFRecord(JSContextRef context,
+    static JSValueRef toByte(JSContextRef context,
                JSObjectRef object,
                JSObjectRef thisObject,
                size_t argumentCount,
index ecd143c..d489bca 100755 (executable)
@@ -38,15 +38,10 @@ using namespace WrtDeviceApis::Commons;
 using namespace WrtDeviceApis::CommonsJavaScript;
 using namespace Api::NFC;
 
-#define TIZEN10_NDEFRECORD_PROPERTIES "properties"
-
-#define TIZEN10_NDEFRECORD_TEXT_TEXT "text"
-#define TIZEN10_NDEFRECORD_TEXT_LANGCODE "langCode"
-#define TIZEN10_NDEFRECORD_TEXT_ENCODETYPE "encodeType"
-
-#define TIZEN10_NDEFRECORD_URI_URI "uri"
-
-#define TIZEN10_NDEFRECORD_MEDIA_MIMETYPE "mimeType"
+#define TIZEN10_NDEFRECORD_TNF "tnf"
+#define TIZEN10_NDEFRECORD_TYPENAME "typeName"
+#define TIZEN10_NDEFRECORD_ID "id"
+#define TIZEN10_NDEFRECORD_PAYLOAD "payload"
 
 JSClassDefinition JSNdefRecord::m_classInfo =
 {
@@ -55,7 +50,7 @@ JSClassDefinition JSNdefRecord::m_classInfo =
        "NDEFRecord",
        0,
        m_property,
-       m_function,
+       NULL,
        initialize,
        finalize,
        NULL, //HasProperty,
@@ -64,27 +59,20 @@ JSClassDefinition JSNdefRecord::m_classInfo =
        NULL, //DeleteProperty,
        NULL, //GetPropertyNames,
        NULL, //CallAsFunction,
-       NULL, //CallAsConstructor,
-       NULL,
+       constructor, //CallAsConstructor,
+       hasInstance,
        NULL, //ConvertToType
 };
 
 JSStaticValue JSNdefRecord::m_property[] =
 {
-       {TIZEN10_NDEFRECORD_PROPERTIES,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_TEXT_TEXT,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_TEXT_LANGCODE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_TEXT_ENCODETYPE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_URI_URI,  getProperty, NULL, kJSPropertyAttributeReadOnly},
-       {TIZEN10_NDEFRECORD_MEDIA_MIMETYPE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_TNF,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_TYPENAME,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_ID,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       {TIZEN10_NDEFRECORD_PAYLOAD,  getProperty, NULL, kJSPropertyAttributeReadOnly},
        { 0, 0, 0, 0 }
 };
 
-JSStaticFunction JSNdefRecord::m_function[] = {
-    {"getPayload", JSNdefRecord::getPayload, kJSPropertyAttributeNone},
-    { 0, 0, 0}
-};
-
 const JSClassRef JSNdefRecord::getClassRef() {
        if (!m_jsClassRef) {
                m_jsClassRef = JSClassCreate(&m_classInfo);
@@ -115,52 +103,74 @@ JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, const NdefRecordP
        return JSObjectMake(context, getClassRef(), priv);
 }
 
-JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, const std::string &text, const std::string &langCode, const short encodeType) {
-       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(text, langCode, encodeType);
-
-       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
-
-       if (!priv) {
-               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+void JSNdefRecord::initialize(JSContextRef context, JSObjectRef object) {
+       LogDebug("entered");
+
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject();
+               NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
        }
-
-       return JSObjectMake(context, getClassRef(), priv);
 }
 
-JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, const std::string &uri) {
-       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(uri);
-
-       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
-
-       if (!priv) {
-               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
-       }
-
-       return JSObjectMake(context, getClassRef(), priv);
+void JSNdefRecord::finalize(JSObjectRef object) {
+       LogDebug("Entered");
+       NdefRecordPrivObject* priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting ndefrecord object");
+       delete priv;
 }
 
-JSObjectRef JSNdefRecord::createJSObject(JSContextRef context, const std::string &mimeType, std::vector<unsigned char> data) {
-       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(mimeType, data);
+JSObjectRef JSNdefRecord::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       LogDebug("entered");
 
-       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+       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");
+               }
+               NFCConverter convert(ctx);
 
-       if (!priv) {
-               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
-       }
+               NdefRecordProperties prop;
+               prop.tnf = static_cast<nfcTNF>(convert.toLong(arguments[0]));
 
-       return JSObjectMake(context, getClassRef(), priv);
-}
+               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");
+                       prop.id = convert.toVectorOfUChars(arguments[3]);
+               }
 
-void JSNdefRecord::initialize(JSContextRef context, JSObjectRef object) {
-       LogDebug("Entered. Nothing to do.");
-}
+               return createJSObject(global_context, prop, convert.toVectorOfUChars(arguments[2]));
 
-void JSNdefRecord::finalize(JSObjectRef object) {
-       LogDebug("Entered");
-       NdefRecordPrivObject* priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-       JSObjectSetPrivate(object, NULL);
-       LogDebug("Deleting ndefrecord object");
-       delete priv;
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
 }
 
 JSValueRef JSNdefRecord::getProperty(JSContextRef context, JSObjectRef object,
@@ -169,87 +179,25 @@ JSValueRef JSNdefRecord::getProperty(JSContextRef context, JSObjectRef object,
 
        Try     {
                NFCConverter convert(context);
-               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_PROPERTIES)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       NdefRecordProperties props = NdefRecord->getNDEFRecordProperties();
-
-                       return convert.toJSValueRef(props);
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_TEXT)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       char * text = NULL;
-                       if (NdefRecord->getText(&text)) {
-                               std::string result(text);
-                               free(text);
-                               LogDebug("text : " << result);
-                               return convert.toJSValueRef(result);
-                       }
-                       LogDebug("This record is not Text Type");
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_LANGCODE)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       char * landCode = NULL;
-                       if (NdefRecord->getLangCode(&landCode)) {
-                               std::string result(landCode);
-                               free(landCode);
-                               LogDebug("landCode : " << result);
-                               return convert.toJSValueRef(result);
-                       }
-                       LogDebug("This record is not Text Type");
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_ENCODETYPE)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       nfcTextEncodeUTF encodeType = NFC_TEXT_ENCODE_UTF_16;
-                       if (NdefRecord->getEncodeType(&encodeType)) {
-                               LogDebug("encodeType : " << encodeType);
-                               return convert.toJSValueRef(convert.toNfcTextEncodeUTFString(encodeType));
-                       }
-                       LogDebug("This record is not Text Type");
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_URI_URI)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       char * uri = NULL;
-                       if (NdefRecord->getUri(&uri)) {
-                               std::string result(uri);
-                               free(uri);
-                               LogDebug("uri : " << result);
-                               return convert.toJSValueRef(result);
-                       }
-                       LogDebug("This record is not URI Type");
-               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_MEDIA_MIMETYPE)) {
-                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
-                       if (!priv) {
-                               ThrowMsg(NullPointerException, "Private object not set.");
-                       }
-                       INdefRecordPtr NdefRecord = priv->getObject();
-                       char * mimeType = NULL;
-                       if (NdefRecord->getMimeType(&mimeType)) {
-                               std::string result(mimeType);
-                               free(mimeType);
-                               LogDebug("mimeType : " << result);
-                               return convert.toJSValueRef(result);
-                       }
-                       LogDebug("This record is not MEDIA Type");
+               NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       ThrowMsg(NullPointerException, "Private object not set.");
                }
-
+               INdefRecordPtr NdefRecord = priv->getObject();
+
+               LogDebug("propertyName : " << convert.toString(propertyName));
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TNF))
+                       return convert.toJSValueRef(NdefRecord->getTNF());
+               else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TYPENAME))
+                       return convert.toJSValueRef(NdefRecord->getTypeName());
+               else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_ID))
+                       return convert.toJSValueRef(NdefRecord->getID());
+               else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_PAYLOAD))
+                       return convert.toJSValueRef(NdefRecord->getPayload());
        } Catch (ConversionException) {
                LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
        } Catch (WrtDeviceApis::Commons::Exception) {
@@ -258,41 +206,12 @@ JSValueRef JSNdefRecord::getProperty(JSContextRef context, JSObjectRef object,
        return JSValueMakeUndefined(context);
 }
 
-
-JSValueRef JSNdefRecord::getPayload(JSContextRef context,
-        JSObjectRef object,
-        JSObjectRef thisObject,
-        size_t argumentCount,
-        const JSValueRef arguments[],
+bool JSNdefRecord::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
         JSValueRef* exception)
 {
-       LogDebug("Entered ");
-       Try {
-               NdefRecordPrivObject* privateObject = static_cast<NdefRecordPrivObject*>(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_P2P_FUNCS);
-               TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
-
-               INdefRecordPtr NdefRecord(privateObject->getObject());
-               NFCConverter convert(context);
-
-               return convert.toJSValueRef(NdefRecord->getPayload());
-       } 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");
-       } Catch (WrtDeviceApis::Commons::Exception) {
-               LogError("Exception: " << _rethrown_exception.GetMessage());
-               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
-       }
-
-       return JSValueMakeNull(context);
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
 }
 
 } //Tizen1_0
index 03d8ef5..68231d3 100755 (executable)
@@ -39,12 +39,6 @@ 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, const std::string &text, 
-               const std::string &langCode, const short encodeType);
-       static JSObjectRef createJSObject(JSContextRef context, const std::string &uri);
-       static JSObjectRef createJSObject(JSContextRef context, 
-               const std::string &mimeType, std::vector<unsigned char> data);
 private:
        /**
      * The callback invoked when an object is first created.
@@ -56,6 +50,8 @@ private:
      */
        static void finalize(JSObjectRef object);
 
+       static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
        /**
      * The callback invoked when getting a property's value.
      */
@@ -63,15 +59,17 @@ private:
 
 
        /**
-     * This structure contains properties and callbacks that define a type of object.
+     * The callback invoked when an object is used as the target of an 'instanceof' expression.
      */
-       static JSClassDefinition m_classInfo;
+    static bool hasInstance(JSContextRef context,
+            JSObjectRef constructor,
+            JSValueRef possibleInstance,
+            JSValueRef* exception);
 
        /**
-     * This structure describes a statically declared function property.
+     * This structure contains properties and callbacks that define a type of object.
      */
-       static JSStaticFunction m_function[];
-       
+       static JSClassDefinition m_classInfo;
        /**
      * This structure describes a statically declared value property.
      */
diff --git a/src/standards/Tizen/NFC/JSNdefRecordArray.cpp b/src/standards/Tizen/NFC/JSNdefRecordArray.cpp
new file mode 100755 (executable)
index 0000000..857a405
--- /dev/null
@@ -0,0 +1,703 @@
+/*
+ * 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 <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "JSNdefRecordArray.h"
+#include "JSNdefMessage.h"
+#include "NFCConverter.h"
+#include <API/NFC/NFCFactory.h>
+
+namespace {
+const char* FUNCTION_CONCAT = "concat";
+const char* FUNCTION_JOIN = "join";
+const char* FUNCTION_POP = "pop";
+const char* FUNCTION_PUSH = "push";
+const char* FUNCTION_REVERSE = "reverse";
+const char* FUNCTION_SHIFT = "shift";
+const char* FUNCTION_SLICE = "slice";
+const char* FUNCTION_SORT = "sort";
+const char* FUNCTION_SPLICE = "splice";
+const char* FUNCTION_TOSTRING = "toString";
+const char* FUNCTION_UNSHIFT = "unshift";
+const char* FUNCTION_VALUEOF = "valueOf";
+const char *ARRAY = "Array";
+const char *ATTRIBUTE_LENGTH = "length";
+}
+
+namespace TizenApis {
+namespace Tizen1_0 {
+using namespace TizenApis::Commons;
+using namespace Api::NFC;
+using namespace WrtDeviceApis;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+       
+JSClassDefinition JSNdefRecordArray::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 JSNdefRecordArray::m_property[] = {
+       { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSNdefRecordArray::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 JSNdefRecordArray::m_jsClassRef = JSClassCreate(
+               JSNdefRecordArray::getClassInfo());
+
+JSValueRef JSNdefRecordArray::getLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("Enter");
+       Try
+       {
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(NullPointerException);
+               }
+               INdefMessagePtr privateDatas = priv->getObject();
+               if (privateDatas) {
+                       Converter converter(context);
+                       return converter.toJSValueRefLong(privateDatas->getRecordCount());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid conversion");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSObjectRef JSNdefRecordArray::createArray(JSContextRef context,
+               const INdefMessagePtr &privateDatas)
+{
+       LogDebug("Enter");
+       NdefMessagePrivObject *priv = new NdefMessagePrivObject(context, privateDatas);
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassDefinition* JSNdefRecordArray::getClassInfo()
+{
+       return &(m_classInfo);
+}
+
+JSClassRef JSNdefRecordArray::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+bool JSNdefRecordArray::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+INdefMessagePtr 
+       JSNdefRecordArray::getNdefRecordArray(JSContextRef context, JSValueRef value)
+{
+       LogDebug("Enter");
+       if (!isObjectOfClass(context, value)) {
+               Throw(InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(InvalidArgumentException);
+       }
+       NdefMessagePrivObject *priv = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSNdefRecordArray::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+       LogDebug("Enter");      
+}
+
+void JSNdefRecordArray::finalize(JSObjectRef object)
+{
+       NdefMessagePrivObject* priv =
+               static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+bool JSNdefRecordArray::hasProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName)
+{      
+       LogDebug("Enter");
+       Converter converter(context);
+       Try
+       {
+               size_t index = converter.toSizeT(propertyName);
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(NullPointerException);
+               }
+               INdefMessagePtr privateDatas = priv->getObject();
+               if (static_cast<long>(index) < privateDatas->getRecordCount()) {
+                       return true;
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               //not reporting error is intended
+       }
+       return false;
+}
+
+JSValueRef JSNdefRecordArray::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("Enter");      
+
+       Try
+       {
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(NullPointerException);
+               }
+
+               NFCConverter converter(priv->getContext());
+               size_t index = converter.toSizeT(propertyName);
+
+               INdefMessagePtr privateDatas = priv->getObject();
+               if (static_cast<long>(index) < privateDatas->getRecordCount()) {
+                       NdefRecordData result = privateDatas->getNDEFRecord(index);
+                       return converter.toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSNdefRecordArray::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{      
+       LogDebug("Enter");
+       NFCConverter converter(context);
+       Try
+       {
+               size_t index = converter.toSizeT(propertyName);
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(NullPointerException);
+               }
+               INdefMessagePtr privateDatas = priv->getObject();
+               if (!privateDatas) {
+                       Throw(NullPointerException);
+               }
+               void *record = converter.getRecordHandle(value);
+               if (privateDatas->getRecordCount() == static_cast<long>(index)) {
+                       privateDatas->appendNDEFRecord(record);
+               } else if (privateDatas->getRecordCount() > static_cast<long>(index)) {
+                       privateDatas->removeNDEFRecord(static_cast<long>(index));
+                       privateDatas->insertNDEFRecord(static_cast<long>(index), record);
+               } else
+                       Throw(InvalidArgumentException);
+
+               return true;
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } 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(WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       }
+       return false;
+}
+
+JSValueRef JSNdefRecordArray::concat(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");
+       Try
+       {
+               //copy current privateDatas
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               if (!priv) {
+                       LogError("Private object is not set.");
+                       ThrowMsg(NullPointerException, "Private object not initialized");
+               }
+
+               INdefMessagePtr myMessage = priv->getObject();
+               
+               INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(myMessage->toByte());
+
+               if (argumentCount == 0)
+                       return createArray(priv->getContext(), NdefMessage);
+
+               NFCConverter converter(context);
+               for (int 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++)
+                                       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");
+                               }
+                               INdefMessagePtr argMessage = argPriv->getObject();
+                               for (long j = 0 ; j < argMessage->getRecordCount(); j++)
+                                       NdefMessage->appendNDEFRecord(argMessage->getRecordHandle(j));
+                       } else
+                               ThrowMsg(ConversionException, "No Array");
+               }
+               
+               return createArray(priv->getContext(), NdefMessage);;
+       } Catch(NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       } 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 JSNdefRecordArray::join(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");
+       Try
+       {
+               std::string result;
+               std::string separator(",");
+               NFCConverter converter(context);
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+               if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
+                       separator = converter.toString(arguments[0]);
+               }
+               for (size_t i = 0; i < myMessage->getRecordCount(); i++) {
+                       if (i != 0) {
+                               result += separator;
+                       }
+                       result += "[object " + converter.toRecordClassName(myMessage->getNDEFRecord(i)) + "]";
+               }
+               return converter.toJSValueRef(result);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+}
+
+JSValueRef JSNdefRecordArray::pop(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{      
+       LogDebug("Enter");
+       Try
+       {
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+
+               NFCConverter converter(priv->getContext());
+               long recordCount = myMessage->getRecordCount();
+               if (recordCount > 0) {
+                       NdefRecordData result = myMessage->getNDEFRecord(recordCount - 1);
+                       myMessage->removeNDEFRecord(recordCount - 1);
+                       return converter.toJSValueRef(result);
+               }
+               return JSCreateArrayObject(context, 0, NULL);
+       } Catch(NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       } 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 JSNdefRecordArray::push(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{      
+       LogDebug("Enter");
+       Try
+       {
+               NFCConverter converter(context);
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       void *record = converter.getRecordHandle(arguments[i]);
+                       myMessage->appendNDEFRecord(record);
+               }
+               return converter.toJSValueRefLong(myMessage->getRecordCount());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+}
+
+JSValueRef JSNdefRecordArray::reverse(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");      
+       Try
+       {
+               NFCConverter converter(context);
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+
+               long recordCounts = myMessage->getRecordCount();
+               if (recordCounts > 0) {
+                       std::vector<void *> records;
+                       for (long i = recordCounts; i > 0; i--) {
+                               records.push_back(myMessage->getRecordHandle(i-1));
+                       }
+                       myMessage->changeAllRecords(records);
+               }
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSNdefRecordArray::shift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");      
+       Try
+       {
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+
+               NFCConverter converter(priv->getContext());
+               long recordCount = myMessage->getRecordCount();
+               if (recordCount > 0) {
+                       NdefRecordData result = myMessage->getNDEFRecord(0);
+                       myMessage->removeNDEFRecord(0);
+                       return converter.toJSValueRef(result);
+               }
+               return JSCreateArrayObject(context, 0, NULL);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSNdefRecordArray::slice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");      
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSValueMakeUndefined(context);
+               }
+
+               NdefMessagePrivObject* priv =
+                       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");
+               
+               long recordCount = myMessage->getRecordCount();
+               long start = converter.toLong(arguments[0]);
+               long end = recordCount;
+               if ((argumentCount > 1) && !JSValueIsNull(context, arguments[1]))
+                       end = converter.toLong(arguments[1]) < recordCount ? converter.toLong(arguments[1]) : recordCount;
+
+               if (start < 0)
+                       start = recordCount + start;
+
+               if (start > end) {
+                       INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject();
+                       return createArray(priv->getContext(), NdefMessage);
+               }
+
+               std::vector<void *> sliceRecords;
+               for (long i = start; i < end; i++) {
+                       void * record = myMessage->getRecordHandle(i);
+                       sliceRecords.push_back(record);
+               }
+               INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(sliceRecords);
+               return createArray(priv->getContext(), NdefMessage);
+}
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+}
+
+JSValueRef JSNdefRecordArray::sort(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("Enter");      
+       return thisObject;
+}
+
+JSValueRef JSNdefRecordArray::splice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSCreateArrayObject(context, 0, NULL);
+               }
+       
+               NdefMessagePrivObject* priv =
+                       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");
+               
+               long recordCount = myMessage->getRecordCount();
+               long start = converter.toLong(arguments[0]);
+               long howmany = 0;
+               if (argumentCount > 1)
+                       howmany= converter.toLong(arguments[1]);
+
+               if (start < 0)
+                       start = recordCount + start;
+
+               JSObjectRef result;
+               if (howmany > 0 ) {
+                       if ((start + howmany) > recordCount)
+                               howmany = recordCount - start;
+
+                       std::vector<void *> spliceRecords;
+                       for (long i = 0; i < howmany; i++) {
+                               void * record = myMessage->getRecordHandle(i + start);
+                               spliceRecords.push_back(record);
+                       }
+                       INdefMessagePtr NdefMessage = NFCFactory::getInstance().createNDEFMessageObject(spliceRecords);
+
+                       result = createArray(priv->getContext(), NdefMessage);
+               } else
+                       result = JSCreateArrayObject(context, 0, NULL);
+
+               if (argumentCount > 2) {
+                       for (long j = 2; j < argumentCount; j++) {
+                               void *record = converter.getRecordHandle(arguments[j]);
+                               if (start < recordCount)
+                                       myMessage->appendNDEFRecord(record);
+                               else
+                                       myMessage->insertNDEFRecord(start++, record);
+                       }
+               }
+               return result;
+       } Catch(NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+       } 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 JSNdefRecordArray::toString(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return join(context, function, thisObject, 0, arguments, exception);
+}
+
+JSValueRef JSNdefRecordArray::unshift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       Try
+       {
+               NdefMessagePrivObject* priv =
+                       static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(thisObject));
+               INdefMessagePtr myMessage = priv->getObject();
+       
+               NFCConverter converter(priv->getContext());
+
+               if (argumentCount > 0) {
+                       for (int i = 0; i < argumentCount; i++) {
+                               if (converter.isNdefRecord(arguments[i]) == false)
+                                       ThrowMsg(ConversionException, "parameter is Not record");
+                       }
+
+                       for (long i = 0 ; i < argumentCount; i++) {
+                               void *record = converter.getRecordHandle(arguments[i]);
+                               myMessage->insertNDEFRecord(i, record);                 
+                       }
+               }
+               return converter.toJSValueRefLong(myMessage->getRecordCount());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+}
+
+JSValueRef JSNdefRecordArray::valueOf(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       
+       return join(context, function, thisObject, 0, arguments, exception);
+}
+}
+}
diff --git a/src/standards/Tizen/NFC/JSNdefRecordArray.h b/src/standards/Tizen/NFC/JSNdefRecordArray.h
new file mode 100755 (executable)
index 0000000..18f38cf
--- /dev/null
@@ -0,0 +1,168 @@
+/*
+ * 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_NDEFRECORD_ARRAY_H_
+#define WRTPLUGINS_TIZEN_JS_NDEFRECORD_ARRAY_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/NFC/INdefMessage.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class JSNdefRecordArray
+{
+  public:
+
+    static const JSClassDefinition* getClassInfo();
+
+    static JSClassRef getClassRef();
+
+    static JSObjectRef createArray(JSContextRef context,
+            const Api::NFC::INdefMessagePtr &recordArray);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static Api::NFC::INdefMessagePtr 
+               getNdefRecordArray(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);
+
+    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 bool checkValue(const std::string &value);
+    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
diff --git a/src/standards/Tizen/NFC/JSNdefRecordMedia.cpp b/src/standards/Tizen/NFC/JSNdefRecordMedia.cpp
new file mode 100755 (executable)
index 0000000..8469c96
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * 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 <memory>
+#include <string>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+
+#include <API/NFC/NFCFactory.h>
+
+#include "JSNdefRecordMedia.h"
+#include "NFCConverter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace Api::NFC;
+
+#define TIZEN10_NDEFRECORD_MEDIA_MIMETYPE "mimeType"
+
+JSClassDefinition JSNdefRecordMedia::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "NDEFRecordMedia",
+       JSNdefRecord::getClassRef(),
+       m_property,
+       NULL,
+       initialize,
+       finalize,
+       NULL, //HasProperty,
+       NULL,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //GetPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       hasInstance,
+       NULL, //ConvertToType
+};
+
+JSStaticValue JSNdefRecordMedia::m_property[] =
+{
+       {TIZEN10_NDEFRECORD_MEDIA_MIMETYPE,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSNdefRecordMedia::getClassRef() {
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSNdefRecordMedia::getClassInfo() {
+       return &m_classInfo;
+}
+
+JSClassRef JSNdefRecordMedia::m_jsClassRef = JSClassCreate(JSNdefRecordMedia::getClassInfo());
+
+JSObjectRef JSNdefRecordMedia::createJSObject(JSContextRef context, const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(ndefRecordProperties, payload);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSObjectRef JSNdefRecordMedia::createJSObject(JSContextRef context, const std::string &mimeType, std::vector<unsigned char> data) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(mimeType, data);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSNdefRecordMedia::initialize(JSContextRef context, JSObjectRef object) {
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject();
+               NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
+}
+
+void JSNdefRecordMedia::finalize(JSObjectRef object) {
+       LogDebug("Entered");
+       NdefRecordPrivObject* priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting ndefrecord object");
+       delete priv;
+}
+
+JSObjectRef JSNdefRecordMedia::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       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]))) {
+                       ThrowMsg(ConversionException, "parameter is JSNull/JSUndefined/Not array");
+               }
+
+               Converter convert(ctx);
+               return createJSObject(global_context, 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");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
+
+}
+
+JSValueRef JSNdefRecordMedia::getProperty(JSContextRef context, JSObjectRef object,
+       JSStringRef propertyName, JSValueRef* exception) {
+       LogDebug("Enter");
+
+       Try     {
+               NFCConverter convert(context);
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_MEDIA_MIMETYPE)) {
+                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+                       if (!priv) {
+                               ThrowMsg(NullPointerException, "Private object not set.");
+                       }
+                       INdefRecordPtr NdefRecord = priv->getObject();
+                       char * mimeType = NULL;
+                       if (NdefRecord->getMimeType(&mimeType)) {
+                               std::string result(mimeType);
+                               free(mimeType);
+                               LogDebug("mimeType : " << result);
+                               return convert.toJSValueRef(result);
+                       }
+                       LogDebug("This record is not MEDIA Type");
+               }
+
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSNdefRecordMedia::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+} //Tizen1_0
+} //TizenApis
+
diff --git a/src/standards/Tizen/NFC/JSNdefRecordMedia.h b/src/standards/Tizen/NFC/JSNdefRecordMedia.h
new file mode 100755 (executable)
index 0000000..d30a4da
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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_NDEFRECORD_MEDIA_H_
+#define WRTPLUGINS_TIZEN_JS_NDEFRECORD_MEDIA_H_
+
+#include "JSNdefRecord.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class JSNdefRecordMedia
+{
+public:
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context, 
+               const Api::NFC::NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
+
+       static JSObjectRef createJSObject(JSContextRef context, 
+               const std::string &mimeType, std::vector<unsigned char> data);
+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 JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+     * 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
+} //TizenApis
+
+#endif
+
diff --git a/src/standards/Tizen/NFC/JSNdefRecordText.cpp b/src/standards/Tizen/NFC/JSNdefRecordText.cpp
new file mode 100755 (executable)
index 0000000..a7c1afd
--- /dev/null
@@ -0,0 +1,237 @@
+/*
+ * 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 <memory>
+#include <string>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+
+#include <API/NFC/NFCFactory.h>
+
+#include "JSNdefRecordText.h"
+#include "NFCConverter.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::Commons;
+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"
+
+JSClassDefinition JSNdefRecordText::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "NDEFRecordText",
+       JSNdefRecord::getClassRef(),
+       m_property,
+       NULL,
+       initialize,
+       finalize,
+       NULL, //HasProperty,
+       NULL,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //GetPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       hasInstance,
+       NULL, //ConvertToType
+};
+
+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},
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSNdefRecordText::getClassRef() {
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSNdefRecordText::getClassInfo() {
+       return &m_classInfo;
+}
+
+JSClassRef JSNdefRecordText::m_jsClassRef = JSClassCreate(JSNdefRecordText::getClassInfo());
+
+JSObjectRef JSNdefRecordText::createJSObject(JSContextRef context, const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(ndefRecordProperties, payload);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSObjectRef JSNdefRecordText::createJSObject(JSContextRef context, const std::string &text, const std::string &langCode, const short encodeType) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(text, langCode, encodeType);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+void JSNdefRecordText::initialize(JSContextRef context, JSObjectRef object) {
+       LogDebug("entered");
+
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject();
+               NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
+}
+
+void JSNdefRecordText::finalize(JSObjectRef object) {
+       LogDebug("Entered");
+       NdefRecordPrivObject* priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting ndefrecord object");
+       delete priv;
+}
+
+JSObjectRef JSNdefRecordText::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       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");
+               }
+
+               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);
+                       encodeType = convert.toNfcTextEncodeUTF(convert.toString(arguments[2]));
+               }
+
+               return createJSObject(global_context, convert.toString(arguments[0]), convert.toString(arguments[1]), encodeType);
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
+
+}
+JSValueRef JSNdefRecordText::getProperty(JSContextRef context, JSObjectRef object,
+       JSStringRef propertyName, JSValueRef* exception) {
+       LogDebug("Enter");
+
+       Try     {
+               NFCConverter convert(context);
+               NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       ThrowMsg(NullPointerException, "Private object not set.");
+               }
+               INdefRecordPtr NdefRecord = priv->getObject();
+
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_TEXT)) {
+                       char * text = NULL;
+                       if (NdefRecord->getText(&text)) {
+                               std::string result(text);
+                               free(text);
+                               LogDebug("text : " << result);
+                               return convert.toJSValueRef(result);
+                       }
+                       LogDebug("This record is not Text Type");
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_LANGCODE)) {
+                       char * landCode = NULL;
+                       if (NdefRecord->getLangCode(&landCode)) {
+                               std::string result(landCode);
+                               free(landCode);
+                               LogDebug("landCode : " << result);
+                               return convert.toJSValueRef(result);
+                       }
+                       LogDebug("This record is not Text Type");
+               } else if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_TEXT_ENCODETYPE)) {
+                       nfcTextEncodeUTF encodeType = NFC_TEXT_ENCODE_UTF_16;
+                       if (NdefRecord->getEncodeType(&encodeType)) {
+                               LogDebug("encodeType : " << encodeType);
+                               return convert.toJSValueRef(convert.toNfcTextEncodeUTFString(encodeType));
+                       }
+                       LogDebug("This record is not Text Type");
+               }
+
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSNdefRecordText::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+} //Tizen1_0
+} //TizenApis
+
diff --git a/src/standards/Tizen/NFC/JSNdefRecordText.h b/src/standards/Tizen/NFC/JSNdefRecordText.h
new file mode 100755 (executable)
index 0000000..57ed2e8
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * 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_NDEFRECORD_TEXT_H_
+#define WRTPLUGINS_TIZEN_JS_NDEFRECORD_TEXT_H_
+
+#include "JSNdefRecord.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class JSNdefRecordText
+{
+public:
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context, 
+               const Api::NFC::NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
+
+       static JSObjectRef createJSObject(JSContextRef context, const std::string &text, 
+               const std::string &langCode, const short encodeType);
+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 JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+     * 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
+} //TizenApis
+
+#endif
+
diff --git a/src/standards/Tizen/NFC/JSNdefRecordURI.cpp b/src/standards/Tizen/NFC/JSNdefRecordURI.cpp
new file mode 100755 (executable)
index 0000000..ba04b38
--- /dev/null
@@ -0,0 +1,207 @@
+/*
+ * 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 <memory>
+#include <string>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/JSUtils.h>
+
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/SecurityExceptions.h>
+
+#include <API/NFC/NFCFactory.h>
+
+#include "JSNdefRecordURI.h"
+#include <CommonsJavaScript/Converter.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+using namespace TizenApis::Commons;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+using namespace Api::NFC;
+
+#define TIZEN10_NDEFRECORD_URI_URI "uri"
+
+JSClassDefinition JSNdefRecordURI::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       "NDEFRecordURI",
+       JSNdefRecord::getClassRef(),
+       m_property,
+       NULL,
+       initialize,
+       finalize,
+       NULL, //HasProperty,
+       NULL,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //GetPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       hasInstance,
+       NULL, //ConvertToType
+};
+
+JSStaticValue JSNdefRecordURI::m_property[] =
+{
+       {TIZEN10_NDEFRECORD_URI_URI,  getProperty, NULL, kJSPropertyAttributeReadOnly},
+       { 0, 0, 0, 0 }
+};
+
+const JSClassRef JSNdefRecordURI::getClassRef() {
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+const JSClassDefinition* JSNdefRecordURI::getClassInfo() {
+       return &m_classInfo;
+}
+
+JSClassRef JSNdefRecordURI::m_jsClassRef = JSClassCreate(JSNdefRecordURI::getClassInfo());
+
+void JSNdefRecordURI::initialize(JSContextRef context, JSObjectRef object) {
+       LogDebug("entered");
+
+       if (!JSObjectGetPrivate(object)) {
+               LogDebug("Private object not set... setting it.");
+               INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject();
+               NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
+}
+
+void JSNdefRecordURI::finalize(JSObjectRef object) {
+       LogDebug("Entered");
+       NdefRecordPrivObject* priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+       JSObjectSetPrivate(object, NULL);
+       LogDebug("Deleting ndefrecord object");
+       delete priv;
+}
+
+JSObjectRef JSNdefRecordURI::createJSObject(JSContextRef context, const NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(ndefRecordProperties, payload);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSObjectRef JSNdefRecordURI::createJSObject(JSContextRef context, const std::string &uri) {
+       INdefRecordPtr NdefRecord = NFCFactory::getInstance().createNDEFRecordObject(uri);
+
+       NdefRecordPrivObject *priv = new NdefRecordPrivObject(context, NdefRecord);
+
+       if (!priv) {
+               ThrowMsg(NullPointerException, "Can not new a NdefRecord object");
+       }
+
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+JSObjectRef JSNdefRecordURI::constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
+{
+       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");
+               }
+
+               Converter convert(ctx);
+
+               return createJSObject(global_context, convert.toString(arguments[0]));
+       } Catch(ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+               return NULL;
+       } Catch (InvalidArgumentException) {
+               LogError("InvalidArgumentException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::INVALID_VALUES_ERROR, "Invalid Values");
+               return NULL;
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+               return NULL;
+       }
+       *exception = JSTizenExceptionFactory::makeErrorObject(ctx, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       return NULL;
+
+}
+JSValueRef JSNdefRecordURI::getProperty(JSContextRef context, JSObjectRef object,
+       JSStringRef propertyName, JSValueRef* exception) {
+       LogDebug("Enter");
+
+       Try     {
+               if (JSStringIsEqualToUTF8CString(propertyName, TIZEN10_NDEFRECORD_URI_URI)) {
+                       NdefRecordPrivObject *priv = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(object));
+                       if (!priv) {
+                               ThrowMsg(NullPointerException, "Private object not set.");
+                       }
+                       INdefRecordPtr NdefRecord = priv->getObject();
+                       char * uri = NULL;
+                       if (NdefRecord->getUri(&uri)) {
+                               Converter convert(context);
+                               std::string result(uri);
+                               free(uri);
+                               LogDebug("uri : " << result);
+                               return convert.toJSValueRef(result);
+                       }
+                       LogDebug("This record is not URI Type");
+               }
+       } Catch (ConversionException) {
+               LogError("ConversionException: " << _rethrown_exception.GetMessage());
+       } Catch (PlatformException) {
+               LogError("PlatformException: " << _rethrown_exception.GetMessage());
+       } Catch (NullPointerException) {
+               LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSNdefRecordURI::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+} //Tizen1_0
+} //TizenApis
+
diff --git a/src/standards/Tizen/NFC/JSNdefRecordURI.h b/src/standards/Tizen/NFC/JSNdefRecordURI.h
new file mode 100755 (executable)
index 0000000..adc07ab
--- /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_JS_NDEFRECORD_URI_H_
+#define WRTPLUGINS_TIZEN_JS_NDEFRECORD_URI_H_
+
+#include "JSNdefRecord.h"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+
+class JSNdefRecordURI
+{
+public:
+       static const JSClassDefinition* getClassInfo();
+
+       static const JSClassRef getClassRef();
+
+       static JSObjectRef createJSObject(JSContextRef context, 
+               const Api::NFC::NdefRecordProperties &ndefRecordProperties, std::vector<unsigned char> payload);
+
+       static JSObjectRef createJSObject(JSContextRef context, const std::string &uri);
+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 JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+
+       /**
+     * 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
+} //TizenApis
+
+#endif
+
index aa67e7a..327c069 100755 (executable)
 #include <CommonsJavaScript/Validator.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/JSUtils.h>
+#include <API/NFC/NFCFactory.h>
 #include "NFCConverter.h"
 #include "JSNdefRecord.h"
+#include "JSNdefRecordText.h"
+#include "JSNdefRecordURI.h"
+#include "JSNdefRecordMedia.h"
 #include "JSNdefMessage.h"
 
 using namespace std;
@@ -173,7 +177,7 @@ nfcTextEncodeUTF NFCConverter::toNfcTextEncodeUTF(std::string encodeString) {
        else if (encodeString == "UTF-16")
                return NFC_TEXT_ENCODE_UTF_16;
        else
-               Throw(ConversionException);
+               Throw(InvalidArgumentException);
 }
 
 std::string NFCConverter::toNfcTextEncodeUTFString(nfcTextEncodeUTF encode) {
@@ -200,7 +204,7 @@ JSValueRef NFCConverter::toJSValueRef(const std::vector<unsigned char>& arg) {
     JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
 
     if (NULL == jsResult) {
-        ThrowMsg(Commons::NullPointerException, "Could not create js array object");
+        ThrowMsg(Commons::UnknownException, "Could not create js array object");
     }
 
     for (std::size_t i = 0; i < arg.size(); ++i) {
@@ -213,24 +217,22 @@ JSValueRef NFCConverter::toJSValueRef(const std::vector<unsigned char>& arg) {
     return jsResult;
 }
 
-JSValueRef NFCConverter::toJSValueRef(NdefRecordProperties props) {
-       JSObjectRef propertyRef = JSObjectMake(m_context, NULL, NULL);
-       
-       ScopedJSStringRef jsTNFString(JSStringCreateWithUTF8CString("tnf"));
-       ScopedJSStringRef jsTypeString(JSStringCreateWithUTF8CString("typeName"));
-       ScopedJSStringRef jsIdString(JSStringCreateWithUTF8CString("id"));
-       
-       JSObjectSetProperty(m_context, propertyRef, jsTNFString.get(), toJSValueRef(static_cast<int>(props.tnf)), kJSPropertyAttributeNone, NULL);
-       JSObjectSetProperty(m_context, propertyRef, jsTypeString.get(), toJSValueRef(props.typeName), kJSPropertyAttributeNone, NULL);
-       JSObjectSetProperty(m_context, propertyRef, jsIdString.get(), toJSValueRef(props.id), kJSPropertyAttributeNone, NULL);
-
-       return propertyRef;
+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);
+       }
+       return JSNdefRecord::createJSObject(m_context, arg.properties, arg.payload);
 }
 
 JSValueRef NFCConverter::toJSValueRef(std::vector<NFCTagProperties> props) {
        JSObjectRef jsResult = JSCreateArrayObject(m_context, 0, NULL);
        if (NULL == jsResult) {
-               ThrowMsg(WrtDeviceApis::Commons::NullPointerException,
+               ThrowMsg(WrtDeviceApis::Commons::UnknownException,
                         "Could not create js array object");
        }
 
@@ -244,36 +246,24 @@ JSValueRef NFCConverter::toJSValueRef(std::vector<NFCTagProperties> props) {
        return jsResult;
 }
 
-NdefRecordProperties NFCConverter::toNdefRecordProperties(JSValueRef value, JSValueRef* exception) {
-       if (JSValueIsNull(m_context, value) || JSValueIsUndefined(m_context, value)) {
-               ThrowMsg(Commons::InvalidArgumentException,
-                        "Message is JS null or JS undefined.");
-       }
-       JSObjectRef obj = toJSObjectRef(value);
-       
-       if (!obj) {
-               LogError("Object is null");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
-       }
-       
-       NdefRecordProperties props;
-       JSValueRef tnf_JSProperty = JSUtils::getJSProperty(m_context, value, "tnf", exception);
-       JSValueRef type_JSProperty = JSUtils::getJSProperty(m_context, value, "typeName", exception);
-       JSValueRef id_JSProperty = JSUtils::getJSProperty(m_context, value, "id", exception);
-
-       if (tnf_JSProperty != NULL && JSValueIsNumber(m_context, tnf_JSProperty)) {
-               props.tnf = static_cast<nfcTNF>(toLong(tnf_JSProperty));
+bool NFCConverter::isNdefRecord(const JSValueRef& arg) {
+       LogDebug("Entered");
+       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
+               LogDebug("Object is Null or Undefied");
+               return false;
        }
+       if (JSValueIsObjectOfClass(m_context, arg, JSNdefRecord::getClassRef())
+               || JSValueIsObjectOfClass(m_context, arg, JSNdefRecordText::getClassRef())
+               || JSValueIsObjectOfClass(m_context, arg, JSNdefRecordURI::getClassRef())
+               || JSValueIsObjectOfClass(m_context, arg, JSNdefRecordMedia::getClassRef()))
+               return true;
 
-       props.typeName= toVectorOfUChars(type_JSProperty);
-       props.id= toVectorOfUChars(id_JSProperty);
-
-       return props;
+       return false;
 }
 
 std::vector<void *> NFCConverter::toVectorOfRecordHandles(const JSValueRef& arg) {
     if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg)) {
-               ThrowMsg(Commons::InvalidArgumentException,
+               ThrowMsg(Commons::ConversionException,
                         "NdefRecordArray is JS null or JS undefined.");
     }
 
@@ -285,27 +275,42 @@ std::vector<void *> NFCConverter::toVectorOfRecordHandles(const JSValueRef& arg)
     JSObjectRef objArg = toJSObjectRef(arg);
     for (std::size_t i = 0; i < JSGetArrayLength(m_context, objArg); ++i) {
         JSValueRef element = JSGetArrayElement(m_context, objArg, i);
-        result.push_back(getRecordHandle(element));
+       if (isNdefRecord(element))
+               result.push_back(getRecordHandle(element));
+       else
+               ThrowMsg(Commons::ConversionException, "JS array has no record.");
     }
     return result;
 }
 
+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;
+       }
+       return JSNdefRecord::getClassInfo()->className;
+}
+
 void *NFCConverter::getRecordHandle(const JSValueRef& arg) {
-       if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) ||
-               (!JSValueIsObjectOfClass(m_context, arg, JSNdefRecord::getClassRef()))) {
-               ThrowMsg(Commons::InvalidArgumentException,
+       LogDebug("Entered");
+       if (!isNdefRecord(arg)) {
+               ThrowMsg(Commons::ConversionException,
                         "Message is JS null or JS undefined.");
        }
        JSObjectRef obj = toJSObjectRef(arg);
        
        if (!obj) {
                LogError("Object is null");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Object is null");
        }
        NdefRecordPrivObject* privateObject = static_cast<NdefRecordPrivObject*>(JSObjectGetPrivate(obj));
        if (!privateObject) {
                LogError("Private object is not set.");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object not set");
        }
 
        INdefRecordPtr record = privateObject->getObject();
@@ -316,19 +321,19 @@ void *NFCConverter::getRecordHandle(const JSValueRef& arg) {
 void *NFCConverter::getMessageHandle(const JSValueRef& arg) {
        if (JSValueIsNull(m_context, arg) || JSValueIsUndefined(m_context, arg) ||
                (!JSValueIsObjectOfClass(m_context, arg, JSNdefMessage::getClassRef()))) {
-               ThrowMsg(Commons::InvalidArgumentException,
+               ThrowMsg(Commons::ConversionException,
                         "Message is JS null or JS undefined.");
        }
        JSObjectRef obj = toJSObjectRef(arg);
        
        if (!obj) {
                LogError("Object is null");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Object is null");
        }
        NdefMessagePrivObject* privateObject = static_cast<NdefMessagePrivObject*>(JSObjectGetPrivate(obj));
        if (!privateObject) {
                LogError("Private object is not set.");
-               ThrowMsg(Commons::NullPointerException, "Private object not initialized");
+               ThrowMsg(Commons::ConversionException, "Private object is not set");
        }
 
        INdefMessagePtr message = privateObject->getObject();
index c59299c..f520620 100755 (executable)
@@ -26,6 +26,7 @@
 #include <API/NFC/TagFilter.h>
 #include <API/NFC/NdefRecordProperties.h>
 #include <API/NFC/NFCTagProperties.h>
+#include <API/NFC/INdefRecord.h>
 #include "NFCChangedCallback.h"
 
 using namespace TizenApis::Api::NFC;
@@ -47,10 +48,11 @@ class NFCConverter : public WrtDeviceApis::CommonsJavaScript::Converter
        nfcTextEncodeUTF toNfcTextEncodeUTF(std::string encodeString);
        std::string toNfcTextEncodeUTFString(nfcTextEncodeUTF encode);
        JSValueRef toJSValueRef(const std::vector<unsigned char>& arg);
-       JSValueRef toJSValueRef(NdefRecordProperties props);
        JSValueRef toJSValueRef(std::vector<NFCTagProperties> props);
-       NdefRecordProperties toNdefRecordProperties(JSValueRef value, JSValueRef* exception);
+       JSValueRef toJSValueRef(NdefRecordData arg);
+       bool isNdefRecord(const JSValueRef& arg);
        std::vector<void *> toVectorOfRecordHandles(const JSValueRef& arg);
+       std::string toRecordClassName(NdefRecordData arg);
        void *getRecordHandle(const JSValueRef& arg);
        void *getMessageHandle(const JSValueRef& arg);
        NFCChangedCallback toNFCChangedCallback(const JSValueRef& arg);
index 743bf14..0627aaf 100755 (executable)
@@ -111,7 +111,7 @@ void NFCResponseDispatcher::OnAnswerReceived(const EventTagActionWritePtr &event
        }
        LogDebug("result fail");
 
-       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(cbm->getContext(), JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
+       cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR,"Unknown Error"));
 
 }
 
index 53c7d54..871a19e 100755 (executable)
 #include <dpl/log/log.h>
 #include <Commons/plugin_initializer_def.h>
 #include "JSNFCManager.h"
+#include "JSNdefMessage.h"
+#include "JSNdefRecord.h"
+#include "JSNdefRecordText.h"
+#include "JSNdefRecordURI.h"
+#include "JSNdefRecordMedia.h"
 
 void on_widget_start_callback(int widgetId, JavaScriptContext context, const engine_interface_t *interface)
 {
@@ -33,5 +38,10 @@ PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
 
 PLUGIN_CLASS_MAP_BEGIN
 PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "nfc", TizenApis::Tizen1_0::JSNFCManager::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "NDEFMessage", TizenApis::Tizen1_0::JSNdefMessage::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "NDEFRecord", TizenApis::Tizen1_0::JSNdefRecord::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "NDEFRecordText", TizenApis::Tizen1_0::JSNdefRecordText::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "NDEFRecordURI", TizenApis::Tizen1_0::JSNdefRecordURI::getClassRef(), NULL)
+PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN, "NDEFRecordMedia", TizenApis::Tizen1_0::JSNdefRecordMedia::getClassRef(), NULL)
 PLUGIN_CLASS_MAP_END
 
index bf802d3..0b0448f 100755 (executable)
@@ -39,6 +39,8 @@ using namespace WrtDeviceApis::CommonsJavaScript;
 namespace TizenApis {
 namespace Tizen1_0 {
 
+static const double PI = 3.141592;
+
 struct SensorConnection {
     sensor_type_e type;
     int status;
@@ -520,6 +522,11 @@ static void sensor_cb_orientation(sensor_data_accuracy_e accuracy, float alpha,
     }
 
     JSSensorDataEvent* data = new JSSensorDataEvent(ctx, JSSENSOR_REASON_WATCH, scon->type);
+
+    alpha = alpha * ( PI / 180 );
+    beta = beta * ( PI / 180 );
+    gamma = gamma * ( PI / 180 );
+
     data->set(accuracy, g_get_monotonic_time(), alpha, beta, gamma);
     processEvent(ctx, scon, SENSOR_LISTENER_DATA, data->makeJSObj());
 }
@@ -598,6 +605,9 @@ JSValueRef JSSensorConnection::read(JSContextRef ctx, JSObjectRef object, JSObje
             data->set(acc, g_get_monotonic_time(), x, y, z);
             break;
         case SENSOR_ORIENTATION:
+            x = x * ( PI / 180 );
+            y = y * ( PI / 180 );
+            z = z * ( PI / 180 );
             sensor_orientation_read_data(scon->handle, &acc, &x, &y, &z);
             data->set(acc, g_get_monotonic_time(), x, y, z);
             break;
index 5411d8e..d41b654 100644 (file)
@@ -120,14 +120,10 @@ JSValueRef JSSysteminfo::isSupported(JSContextRef context, JSObjectRef object, J
     Converter converter(context);
     Validator check(context, exception);
     
-    if (argumentCount < 1) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
-    }
-    if (argumentCount > 0 && JSValueIsObject(context, arguments[0])) {
-        LogError("wrong argument");
+    if (argumentCount > 1 || argumentCount == 0) {
+        LogError("argument count is not correct");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
-    }    
+    }
 
     Try
     {
@@ -143,6 +139,10 @@ JSValueRef JSSysteminfo::isSupported(JSContextRef context, JSObjectRef object, J
         LogError("Error on conversion");
         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
     }
+    Catch(InvalidArgumentException) {
+        LogError("JSSysteminfo::get InvalidArgumentException");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter");
+    }
 
     return JSValueMakeUndefined(context);
 }
@@ -164,19 +164,19 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     }
 
     if (argumentCount == 0 || argumentCount > 4) {
-        LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+        LogError("argument count is not correct");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
     }
 
     if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !check.isCallback(arguments[1])) {
         LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+        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::INVALID_VALUES_ERROR, "invalid value error");
+            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
         }
     }
 
@@ -218,19 +218,19 @@ JSValueRef JSSysteminfo::getPropertyValue(JSContextRef context, JSObjectRef obje
     
     Catch(PendingOperationException) {
         LogError("JSSysteminfo::get PendingOperationException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
     }
     Catch(ConversionException) {
         LogError("JSSysteminfo::get ConversionException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"));
     }
     Catch(InvalidArgumentException) {
         LogError("JSSysteminfo::get InvalidArgumentException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
     }
     Catch(WrtDeviceApis::Commons::Exception) {
         LogError("JSSysteminfo::get Exception");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknown error"));
     }
     return JSValueMakeUndefined(context);
 }
@@ -257,18 +257,18 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
 
     if (argumentCount == 0 || argumentCount > 4) {
         LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
+        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
     }
 
     if (!JSValueIsNull(context, arguments[1]) && !JSValueIsUndefined(context, arguments[1]) && !check.isCallback(arguments[1])) {
         LogError("wrong argument");
-        return JSTizenExceptionFactory::postException(context, exception, JSTizenException::INVALID_VALUES_ERROR, "invalid value error");
+        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::INVALID_VALUES_ERROR, "invalid value error");
+            return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error");
         }
     }
 
@@ -312,19 +312,19 @@ JSValueRef JSSysteminfo::addPropertyValueChangeListener(JSContextRef context, JS
     
     Catch(PendingOperationException) {
         LogError("JSSysteminfo::get PendingOperationException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
     }
     Catch(ConversionException) {
         LogError("JSSysteminfo::get ConversionException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "type mismatch error"));
     }
     Catch(InvalidArgumentException) {
         LogError("JSSysteminfo::get InvalidArgumentException");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR, "invalid parameter"));
     }
     Catch(WrtDeviceApis::Commons::Exception) {
         LogError("JSSysteminfo::get Exception");
-        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::INVALID_VALUES_ERROR,"invalid parameter"));
+        cbm->callOnError(JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "unknown error"));
     }
     return JSValueMakeUndefined(context);    
 }
@@ -340,11 +340,12 @@ JSValueRef JSSysteminfo::removePropertyValueChangeListener(JSContextRef context,
     
     Converter converter(context);
 
-    if (argumentCount == 0) {
-        return JSValueMakeUndefined(context);
-    } else if (argumentCount != 1 || (argumentCount > 0 && JSValueIsObject(context, arguments[0]))) {
-        LogError("wrong argument");
+    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");
     }
 
     Try {
index 815d801..efd2910 100755 (executable)
@@ -63,7 +63,7 @@ JSClassDefinition JSTZDate::m_classInfo =
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     constructor, //CallAsConstructor,
-    NULL, //HasInstance,
+    hasInstance, //HasInstance,
     NULL  //ConvertToType
 };
 
@@ -338,6 +338,14 @@ const JSClassDefinition* JSTZDate::getClassInfo()
     return &m_classInfo;
 }
 
+bool JSTZDate::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
 JSValueRef JSTZDate::getTimezone(JSContextRef context, JSObjectRef function,
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
        LogDebug("entered");
index 4d15f27..a89766a 100755 (executable)
@@ -80,6 +80,14 @@ private:
 
     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, 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 JSValueRef getTimezone(JSContextRef context, JSObjectRef function, 
             JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
     static JSValueRef toTimezone(JSContextRef context, JSObjectRef function, 
index 1398b09..cfb1971 100755 (executable)
@@ -53,18 +53,21 @@ JSClassDefinition JSTimeDuration::m_classInfo = {
     finalize,
     NULL, //HasProperty,
     NULL, //GetProperty,
-    NULL, //SetProperty,
+    setProperty, //SetProperty,
     NULL, //DeleteProperty,
     NULL, //GetPropertyNames,
     NULL, //CallAsFunction,
     constructor, //CallAsConstructor,
-    NULL,
+    hasInstance,
     NULL, //ConvertToType
 };
 
 
 JSStaticFunction JSTimeDuration::m_function[] = {
     {"difference",           JSTimeDuration::difference,            kJSPropertyAttributeNone},
+    {"equalsTo",           JSTimeDuration::equalsTo,            kJSPropertyAttributeNone},
+    {"lessThan",           JSTimeDuration::lessThan,            kJSPropertyAttributeNone},
+    {"greaterThan",           JSTimeDuration::greaterThan,            kJSPropertyAttributeNone},
 };
 
 JSStaticValue JSTimeDuration::m_property[] =
@@ -182,12 +185,16 @@ bool JSTimeDuration::setProperty(JSContextRef context, JSObjectRef object,
                return true;
        } Catch (NullPointerException) {
                LogError("NullPointerException: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        } 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 (WrtDeviceApis::Commons::Exception) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
        }
        return false;
 }
@@ -256,10 +263,17 @@ JSObjectRef JSTimeDuration::constructor(JSContextRef ctx, JSObjectRef constructo
        return NULL;
 }
 
-JSValueRef JSTimeDuration::difference(JSContextRef context, JSObjectRef function, 
-       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
-       LogDebug("Entered");
-       Try {
+bool JSTimeDuration::hasInstance(JSContextRef context,
+        JSObjectRef constructor,
+        JSValueRef possibleInstance,
+        JSValueRef* exception)
+{
+    return JSValueIsObjectOfClass(context, possibleInstance, getClassRef());
+}
+
+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));
 
                if (argumentCount != 1) {
@@ -287,7 +301,109 @@ JSValueRef JSTimeDuration::difference(JSContextRef context, JSObjectRef function
                        diff.unit = first.unit;
                        diff.length = first.length - secondLength;
                }
-               return converter.makeDurationObject(diff);
+
+       switch (type) {
+               case EQUALSTO:
+               {
+                       if (diff.length == 0)
+                               return converter.toJSValueRef(TRUE);
+                       else
+                               return converter.toJSValueRef(FALSE);
+               }
+               case LESSTHAN:
+               {
+                       if (diff.length < 0)
+                               return converter.toJSValueRef(TRUE);
+                       else
+                               return converter.toJSValueRef(FALSE);
+               }
+               case GREATERTHAN:
+               {
+                       if (diff.length > 0)
+                               return converter.toJSValueRef(TRUE);
+                       else
+                               return converter.toJSValueRef(FALSE);
+               }
+               case DIFFERENCE:
+               default:
+                       return converter.makeDurationObject(diff);
+       }
+}
+
+JSValueRef JSTimeDuration::difference(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
+       LogDebug("Entered");
+       Try {
+               return diffTimeDuration(context, thisObject, argumentCount, arguments, exception, DIFFERENCE);
+       } Catch(ConversionException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } 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 (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSTimeDuration::equalsTo(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
+       LogDebug("Entered");
+       Try {
+               return diffTimeDuration(context, thisObject, argumentCount, arguments, exception, EQUALSTO);
+       } Catch(ConversionException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } 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 (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSTimeDuration::lessThan(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
+       LogDebug("Entered");
+       Try {
+               return diffTimeDuration(context, thisObject, argumentCount, arguments, exception, LESSTHAN);
+       } Catch(ConversionException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
+       } 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 (PlatformException) {
+               LogError("Exception: " << _rethrown_exception.GetMessage());
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+       } Catch (WrtDeviceApis::Commons::Exception) {
+               return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");                    
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::UNKNOWN_ERROR, "Unknown Error");
+}
+
+JSValueRef JSTimeDuration::greaterThan(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception) {
+       LogDebug("Entered");
+       Try {
+               return diffTimeDuration(context, thisObject, argumentCount, arguments, exception, GREATERTHAN);
        } Catch(ConversionException) {
                LogError("Exception: " << _rethrown_exception.GetMessage());
                return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type Mismatch");
index 14f588a..797af9a 100755 (executable)
@@ -52,6 +52,12 @@ class JSTimeDuration
     static const JSClassRef getClassRef();
     static JSObjectRef createJSObject(JSContextRef context, const Api::TimeUtil::DurationProperties &durations);
   private:
+       enum CompareType {
+               DIFFERENCE,
+               EQUALSTO,
+               LESSTHAN,
+               GREATERTHAN
+               };
     /**
      * The callback invoked when an object is first created.
      */
@@ -74,8 +80,23 @@ class JSTimeDuration
 
     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, 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 JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
        JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+    static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+    static JSValueRef lessThan(JSContextRef context, JSObjectRef function, 
+       JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+    static JSValueRef greaterThan(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 bb0a650..b41a720 100755 (executable)
@@ -8,12 +8,24 @@ include_directories(
 )
 
 set(SRCS
+  ${SRCS_PLATFORM_API_FILTER}
   JSTizen.cpp
+  JSAttributeFilter.cpp
+  JSAttributeRangeFilter.cpp
+  JSCompositeFilter.cpp
+  JSAbstractFilterArray.cpp
+  JSSortMode.cpp
+  FilterConverter.cpp
+  JSSimpleCoordinates.cpp
   JSFeature.cpp
   JSFeatureParam.cpp
   plugin_initializer.cpp
   plugin_config.cpp
   PluginOnDemandPriv.cpp
+  ../Common/JSTizenException.cpp
+  ../Common/TizenExceptionData.cpp
+  ../Common/JSTizenExceptionFactory.cpp
+  ../Common/JSGlobalContextFactory.cpp
 )
 
 add_library(${TARGET_NAME} SHARED ${SRCS})
index b0f3bc1..e6c978a 100755 (executable)
 #include <dpl/log/log.h>
 #include <CommonsJavaScript/ScopedJSStringRef.h>
 #include <CommonsJavaScript/Validator.h>
+#include <CommonsJavaScript/JSUtils.h>
+#include "JSAttributeFilter.h"
+#include "JSAttributeRangeFilter.h"
+#include "JSCompositeFilter.h"
+#include "JSAbstractFilterArray.h"
+#include "JSSortMode.h"
 #include "FilterConverter.h"
 
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE                          "type"
@@ -33,7 +39,6 @@
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME                "attributeName"
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG                    "matchFlag"
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUES          "matchValues"
-#define TIZEN_FILTER_CONVERTER_ATTRIBUTE_CASE_SENSITIVE                "caseSensitive"
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE         "initialValue"
 #define TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE                     "endValue"
 
@@ -57,19 +62,11 @@ FilterConverter::~FilterConverter()
        LogDebug("entered");
 }
 
-MatchFlagArrayPtr FilterConverter::toMatchFlagArray(JSValueRef matchFlagArray)
-{
-       MatchFlagArrayPtr result;
-       Try {
-               result = MatchFlagArrayPtr(new MatchFlagArray(toVectorOfStrings(matchFlagArray)));
-       } Catch(ConversionException) {
-               ThrowMsg(InvalidArgumentException, "AttributeFilter.matchFlags has invalid type value.");
-       }
-       return result;
-}
-
 JSValueRef FilterConverter::toJSValueRef(FilterPtr arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "Filter is NULL.");
+
        JSValueRef result = NULL;
 
        if(arg->getFilterType() == UNION_FILTER || arg->getFilterType() == INTERSECTION_FILTER)
@@ -97,7 +94,26 @@ JSValueRef FilterConverter::toJSValueRef(FilterPtr arg)
 FilterPtr FilterConverter::toFilter(const JSValueRef& arg)
 {
        if(arg == NULL)
-               ThrowMsg(NullPointerException, "Filter is NULL.");
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsObject(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Filter is not object.");
+
+       if(JSCompositeFilter::isObjectOfClass(m_context, arg))
+               return DPL::StaticPointerCast<IFilter>(JSCompositeFilter::getCompositeFilter(m_context, arg));
+
+       if(JSAttributeFilter::isObjectOfClass(m_context, arg))
+               return DPL::StaticPointerCast<IFilter>(JSAttributeFilter::getAttributeFilter(m_context, arg));
+
+       if(JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
+               return DPL::StaticPointerCast<IFilter>(JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg));
+
+       ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+       return FilterPtr(NULL);
+
+#if 0 // User object will not be given any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
 
        if(!JSValueIsObject(m_context, arg))
                ThrowMsg(InvalidArgumentException, "Filter is not object.");
@@ -126,10 +142,83 @@ FilterPtr FilterConverter::toFilter(const JSValueRef& arg)
 
        ThrowMsg(InvalidArgumentException, "Not a Filter.");
        return FilterPtr(NULL);
+#endif
+}
+
+JSValueRef FilterConverter::toJSValueRef(const FilterArrayPtr& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "FilterArray is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAbstractFilterArray::getClassRef(), arg);
+
+#if 0 // User object will not be given any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "FilterArray is NULL.");
+
+       int size = arg->size();
+
+       JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
+       if (!resultObject)
+               ThrowMsg(ConversionException, "Can not create array object.");
+
+       for(int i = 0; i < size; i++)
+       {
+               JSValueRef jsvalue = toJSValueRef(arg->at(i));
+               if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
+                       ThrowMsg(ConversionException, "Can not fill filter array.");
+       }
+
+       return static_cast<JSValueRef>(resultObject);
+#endif
+}
+
+FilterArrayPtr FilterConverter::toFilterArray(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(JSAbstractFilterArray::isObjectOfClass(m_context, arg))
+               return JSAbstractFilterArray::getAbstractFilterArray(m_context, arg);
+
+       if(!JSIsArrayValue(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "JSValueRef is not Array.");
+
+       FilterArrayPtr retVal;
+
+       JSObjectRef obj = toJSObjectRef(arg);
+       retVal = FilterArrayPtr(new FilterArray());
+
+       unsigned int length = JSGetArrayLength(m_context, obj);
+       for(unsigned int i=0; i<length; i++)
+       {
+               JSValueRef value = JSGetArrayElement(m_context, obj, i);
+
+               if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
+                       ThrowMsg(InvalidArgumentException, "CompositeFilter.filters has null elements.");
+               }
+
+               FilterPtr filter;
+               Try {
+                       filter = toFilter(value);
+               } Catch (Exception) {
+                       ThrowMsg(InvalidArgumentException, "Element is not an AbstractFilter (" << i << ")");
+               }
+
+               retVal->push_back(filter);
+       }
+
+       return retVal;
 }
 
 JSValueRef FilterConverter::toJSValueRef(const CompositeFilterPtr& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "CompositeFilter is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSCompositeFilter::getClassRef(), arg);
+
+#if 0 // User object will not be given any more.
        JSObjectRef resultObject = JSObjectMake(m_context, NULL, NULL);
 
        ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE));
@@ -156,10 +245,25 @@ JSValueRef FilterConverter::toJSValueRef(const CompositeFilterPtr& arg)
                        kJSPropertyAttributeNone, NULL);
 
        return static_cast<JSValueRef>(resultObject);
+#endif
 }
 
 CompositeFilterPtr FilterConverter::toCompositeFilter(const JSValueRef& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSCompositeFilter::isObjectOfClass(m_context, arg))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+
+       return JSCompositeFilter::getCompositeFilter(m_context, arg);
+
+#if 0 // User object will not be given any more.
+       // If arg is platform object
+       if(JSCompositeFilter::isObjectOfClass(m_context, arg))
+               return JSCompositeFilter::getCompositeFilter(m_context, arg);
+
+       // If arg is use object
        JSObjectRef jsObject = toJSObjectRef(arg);
 
        ScopedJSStringRef typeStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_TYPE));
@@ -185,10 +289,17 @@ CompositeFilterPtr FilterConverter::toCompositeFilter(const JSValueRef& arg)
                ThrowMsg(InvalidArgumentException, "CompositeFilter.filters array size is 0.");
 
        return CompositeFilterPtr(new CompositeFilter(filterType, filters));
+#endif
 }
 
 JSValueRef FilterConverter::toJSValueRef(const AttributeFilterPtr& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "AttributeFilter is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAttributeFilter::getClassRef(), arg);
+
+#if 0 // User object will not be given any more.
        AnyTypeConverterFactory::ConverterType converter =
                        AnyTypeConverterFactory::getConverter(m_context);
 
@@ -215,18 +326,26 @@ JSValueRef FilterConverter::toJSValueRef(const AttributeFilterPtr& arg)
                        matchValuesValue,
                        kJSPropertyAttributeNone, NULL);
 
-       ScopedJSStringRef caseSensitiveStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_CASE_SENSITIVE));
-       JSValueRef caseSensitiveValue = converter->toJSValueRef(arg->getCaseSensitive());
-       JSObjectSetProperty(m_context, resultObject,
-                       caseSensitiveStr.get(),
-                       caseSensitiveValue,
-                       kJSPropertyAttributeNone, NULL);
-
        return static_cast<JSValueRef>(resultObject);
+#endif
 }
 
 AttributeFilterPtr FilterConverter::toAttributeFilter(const JSValueRef& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSAttributeFilter::isObjectOfClass(m_context, arg))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+
+       return JSAttributeFilter::getAttributeFilter(m_context, arg);
+
+#if 0 // User object will not be given any more.
+       // If arg is platform object
+       if(JSAttributeFilter::isObjectOfClass(m_context, arg))
+               return JSAttributeFilter::getAttributeFilter(m_context, arg);
+
+       // If arg is user object
        JSObjectRef jsObject = toJSObjectRef(arg);
 
        ScopedJSStringRef attributeNameStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME));
@@ -239,20 +358,20 @@ AttributeFilterPtr FilterConverter::toAttributeFilter(const JSValueRef& arg)
 
        ScopedJSStringRef matchFlagStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG));
        JSValueRef matchFlagValue = JSObjectGetProperty(m_context, jsObject, matchFlagStr.get(), NULL);
-       string matchFlag;
+       MatchFlag matchFlag;
        if(JSValueIsUndefined(m_context, matchFlagValue)) {
-               matchFlag = "EXACTLY";
+               matchFlag = MATCH_EXACTLY;
        } else if(!JSValueIsString(m_context, matchFlagValue)) {
                ThrowMsg(InvalidArgumentException, "AttributeFilter.matchFlag is not string.");
        } else {
-               matchFlag = toString(matchFlagValue);
+               matchFlag = toMatchFlag(matchFlagValue);
        }
 
        ScopedJSStringRef matchValuesStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUES));
        JSValueRef matchValuesValue = JSObjectGetProperty(m_context, jsObject, matchValuesStr.get(), NULL);
        AnyArrayPtr matchValues(NULL);
 
-       if(matchFlag == "EXISTS") {
+       if(matchFlag == MATCH_EXISTS) {
                //matchValues = AnyArrayPtr(NULL);
        } else if(JSValueIsUndefined(m_context, matchValuesValue)) {
                ThrowMsg(InvalidArgumentException, "AttributeFilter.matchValues is undefined.");
@@ -262,26 +381,18 @@ AttributeFilterPtr FilterConverter::toAttributeFilter(const JSValueRef& arg)
                matchValues = toAnyArray(matchValuesValue);
        }
 
-       ScopedJSStringRef caseSensitiveStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_CASE_SENSITIVE));
-       JSValueRef caseSensitiveValue = JSObjectGetProperty(m_context, jsObject, caseSensitiveStr.get(), NULL);
-       bool caseSensitive;
-       if(JSValueIsUndefined(m_context, caseSensitiveValue)) {
-               if(matchFlag == "EXACTLY")
-                       caseSensitive = true;
-               else
-                       caseSensitive = false;
-       } else {
-               if(!JSValueIsBoolean(m_context, caseSensitiveValue)) {
-                       ThrowMsg(InvalidArgumentException, "AttributeFilter.caseSensitive is not boolean.");
-               }
-               caseSensitive = toBool(caseSensitiveValue);
-       }
-
-       return AttributeFilterPtr(new AttributeFilter(attributeName, matchValues, matchFlag, caseSensitive));
+       return AttributeFilterPtr(new AttributeFilter(attributeName, matchFlag, matchValues));
+#endif
 }
 
 JSValueRef FilterConverter::toJSValueRef(const AttributeRangeFilterPtr& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "AttributeRangeFilter is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSAttributeRangeFilter::getClassRef(), arg);
+
+#if 0 // User object will not be given any more.
        AnyTypeConverterFactory::ConverterType converter =
                        AnyTypeConverterFactory::getConverter(m_context);
 
@@ -309,10 +420,24 @@ JSValueRef FilterConverter::toJSValueRef(const AttributeRangeFilterPtr& arg)
                        kJSPropertyAttributeNone, NULL);
 
        return static_cast<JSValueRef>(resultObject);
+#endif
 }
 
 AttributeRangeFilterPtr FilterConverter::toAttributeRangeFilter(const JSValueRef& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+
+       return JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg);
+#if 0 // User object will not be given any more.
+       // If arg is platform object
+       if(JSAttributeRangeFilter::isObjectOfClass(m_context, arg))
+               return JSAttributeRangeFilter::getAttributeRangeFilter(m_context, arg);
+
+       // If arg is user object
        AnyTypeConverterFactory::ConverterType converter =
                        AnyTypeConverterFactory::getConverter(m_context);
 
@@ -330,21 +455,31 @@ AttributeRangeFilterPtr FilterConverter::toAttributeRangeFilter(const JSValueRef
        JSValueRef initialValueValue = JSObjectGetProperty(m_context, jsObject, initialValueStr.get(), NULL);
        AnyPtr initialValue(NULL);
        if(!JSValueIsUndefined(m_context, initialValueValue) && !JSValueIsNull(m_context, initialValueValue)) {
-               initialValue = converter->toAny(initialValueValue, PrimitiveType_Int);
+               initialValue = converter->toAny(initialValueValue);
        }
 
        ScopedJSStringRef endValueStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_END_VALUE));
        JSValueRef endValueValue = JSObjectGetProperty(m_context, jsObject, endValueStr.get(), NULL);
        AnyPtr endValue(NULL);
        if(!JSValueIsUndefined(m_context, endValueValue) && !JSValueIsNull(m_context, endValueValue)) {
-               endValue = converter->toAny(endValueValue, PrimitiveType_Int);
+               endValue = converter->toAny(endValueValue);
        }
 
        return AttributeRangeFilterPtr(new AttributeRangeFilter(attributeName, initialValue, endValue));
+#endif
 }
 
 JSValueRef FilterConverter::toJSValueRef(const SortModePtr& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "SortMode is NULL.");
+
+       return WrtDeviceApis::CommonsJavaScript::JSUtils::makeObject(m_context, JSSortMode::getClassRef(), arg);
+
+#if 0 // User object will not be given any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "SortMode is NULL.");
+
        JSObjectRef resultObject = JSObjectMake(m_context, NULL, NULL);
 
        ScopedJSStringRef attributeNameStr(JSStringCreateWithUTF8CString(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME));
@@ -371,10 +506,22 @@ JSValueRef FilterConverter::toJSValueRef(const SortModePtr& arg)
                        kJSPropertyAttributeNone, NULL);
 
        return static_cast<JSValueRef>(resultObject);
+#endif
 }
 
 SortModePtr FilterConverter::toSortMode(const JSValueRef& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSSortMode::isObjectOfClass(m_context, arg))
+               ThrowMsg(WrtDeviceApis::Commons::ConversionException, "Wrong attribute");
+
+       return JSSortMode::getSortMode(m_context, arg);
+#if 0 // User object will not be given any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
        BasicValidator validator = ValidatorFactory<Validator>::getValidator(m_context);
 
        if(validator->checkArrayKeys(m_compositeFilterAttrs, arg)) {
@@ -406,10 +553,15 @@ SortModePtr FilterConverter::toSortMode(const JSValueRef& arg)
                ThrowMsg(InvalidArgumentException, "SortMode.attributeName is empty string.");
 
        return SortModePtr(new SortMode(attributeName, sortOrder));
+#endif
 }
 
 JSValueRef FilterConverter::toJSValueRef(const SortModeArrayPtr& arg)
 {
+       // Not used any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "SortModeArray is NULL.");
+
        int size = arg->size();
 
        JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
@@ -428,6 +580,10 @@ JSValueRef FilterConverter::toJSValueRef(const SortModeArrayPtr& arg)
 
 SortModeArrayPtr FilterConverter::toSortModeArray(const JSValueRef& arg)
 {
+       // Not used any more.
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
        if(!JSIsArrayValue(m_context, arg))
                ThrowMsg(InvalidArgumentException, "Not an array type.");
 
@@ -451,8 +607,35 @@ SortModeArrayPtr FilterConverter::toSortModeArray(const JSValueRef& arg)
        return sortModeArray;
 }
 
+JSValueRef FilterConverter::toJSValueRef(const AnyPtr& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "Any is NULL.");
+
+       AnyTypeConverterFactory::ConverterType converter =
+                       AnyTypeConverterFactory::getConverter(m_context);
+
+       return converter->toJSValueRef(arg);
+}
+
+AnyPtr FilterConverter::toAny(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       AnyArrayPtr retVal;
+
+       AnyTypeConverterFactory::ConverterType converter =
+                       AnyTypeConverterFactory::getConverter(m_context);
+
+       return converter->toAny(arg);
+}
+
 JSValueRef FilterConverter::toJSValueRef(const AnyArrayPtr& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "AnyArray is NULL.");
+
        AnyTypeConverterFactory::ConverterType converter =
                        AnyTypeConverterFactory::getConverter(m_context);
 
@@ -474,6 +657,9 @@ JSValueRef FilterConverter::toJSValueRef(const AnyArrayPtr& arg)
 
 AnyArrayPtr FilterConverter::toAnyArray(const JSValueRef& arg)
 {
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
        AnyArrayPtr retVal;
 
        retVal = AnyArrayPtr(new AnyArray());
@@ -490,7 +676,7 @@ AnyArrayPtr FilterConverter::toAnyArray(const JSValueRef& arg)
                if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
                        ThrowMsg(InvalidArgumentException, "IDFilter.ids has null elements.");
                }
-               AnyPtr any = converter->toAny(value, PrimitiveType_Int);
+               AnyPtr any = converter->toAny(value);
 
                retVal->push_back(any);
        }
@@ -498,46 +684,125 @@ AnyArrayPtr FilterConverter::toAnyArray(const JSValueRef& arg)
        return retVal;
 }
 
-JSValueRef FilterConverter::toJSValueRef(const FilterArrayPtr& arg)
+JSValueRef FilterConverter::toJSValueRef(const FilterType& arg)
 {
-       int size = arg->size();
+       string compositeFilterTypeStr;
 
-       JSObjectRef resultObject = JSCreateArrayObject(m_context, 0, NULL);
-       if (!resultObject)
-               ThrowMsg(ConversionException, "Can not create array object.");
+       if(arg == UNION_FILTER)
+               compositeFilterTypeStr = "UNION";
+       else if(arg == INTERSECTION_FILTER)
+               compositeFilterTypeStr = "INTERSECTION";
+       else
+               ThrowMsg(ConversionException, "Can not create CompositeFilterType.");
 
-       for(int i = 0; i < size; i++)
-       {
-               JSValueRef jsvalue = toJSValueRef(arg->at(i));
-               if (!JSSetArrayElement(m_context, resultObject, i, jsvalue))
-                       ThrowMsg(ConversionException, "Can not fill filter array.");
-       }
+       return toJSValueRef(compositeFilterTypeStr);
+}
 
-       return static_cast<JSValueRef>(resultObject);
+FilterType FilterConverter::toCompositeFilterType(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string compositeFilterTypeStr = toString(arg);
+       FilterType compositeFilterType;
+
+       if(compositeFilterTypeStr == "UNION")
+               compositeFilterType = UNION_FILTER;
+       else if(compositeFilterTypeStr == "INTERSECTION")
+               compositeFilterType = INTERSECTION_FILTER;
+       else
+               ThrowMsg(InvalidArgumentException, "CompositeFilterType cannot have " << compositeFilterTypeStr);
+
+       return compositeFilterType;
 }
 
-FilterArrayPtr FilterConverter::toFilterArray(const JSValueRef& arg)
+JSValueRef FilterConverter::toJSValueRef(const MatchFlag& arg)
 {
-       FilterArrayPtr retVal;
+       string matchFlagStr;
+
+       if(arg == MATCH_EXACTLY)
+               matchFlagStr = "EXACTLY";
+       else if(arg == MATCH_FULLSTRING)
+               matchFlagStr = "FULLSTRING";
+       else if(arg == MATCH_CONTAINS)
+               matchFlagStr = "CONTAINS";
+       else if(arg == MATCH_STARTSWITH)
+               matchFlagStr = "STARTSWITH";
+       else if(arg == MATCH_ENDSWITH)
+               matchFlagStr = "ENDSWITH";
+       else if(arg == MATCH_EXISTS)
+               matchFlagStr = "EXISTS";
+       else
+               ThrowMsg(ConversionException, "Can not create MatchFlag.");
 
-       JSObjectRef obj = toJSObjectRef(arg);
-       retVal = FilterArrayPtr(new FilterArray());
+       return toJSValueRef(matchFlagStr);
+}
 
-       unsigned int length = JSGetArrayLength(m_context, obj);
-       for(unsigned int i=0; i<length; i++)
-       {
-               JSValueRef value = JSGetArrayElement(m_context, obj, i);
+MatchFlag FilterConverter::toMatchFlag(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string matchFlagStr = toString(arg);
+       MatchFlag matchFlag;
+
+       if(matchFlagStr == "EXACTLY")
+               matchFlag = MATCH_EXACTLY;
+       else if(matchFlagStr == "FULLSTRING")
+               matchFlag = MATCH_FULLSTRING;
+       else if(matchFlagStr == "CONTAINS")
+               matchFlag = MATCH_CONTAINS;
+       else if(matchFlagStr == "STARTSWITH")
+               matchFlag = MATCH_STARTSWITH;
+       else if(matchFlagStr == "ENDSWITH")
+               matchFlag = MATCH_ENDSWITH;
+       else if(matchFlagStr == "EXISTS")
+               matchFlag = MATCH_EXISTS;
+       else
+               ThrowMsg(InvalidArgumentException, "FilterMatchFlag cannot have " << matchFlagStr);
 
-               if(JSValueIsNull(m_context, value) ||  JSValueIsUndefined(m_context, value)) {
-                       ThrowMsg(InvalidArgumentException, "CompositeFilter.filters has null elements.");
-               }
+       return matchFlag;
+}
 
-               FilterPtr filter = toFilter(value);
+JSValueRef FilterConverter::toJSValueRef(const SortOrder& arg)
+{
+       string sortOrderStr;
 
-               retVal->push_back(filter);
-       }
+       if(arg == ASCENDING_SORT_ORDER)
+               sortOrderStr = "ASC";
+       else if(arg == DESCENDING_SORT_ORDER)
+               sortOrderStr = "DESC";
+       else
+               ThrowMsg(ConversionException, "Can not create SortModeOrder.");
 
-       return retVal;
+       return toJSValueRef(sortOrderStr);
+}
+
+SortOrder FilterConverter::toSortOrder(const JSValueRef& arg)
+{
+       if(arg == NULL)
+               ThrowMsg(NullPointerException, "JSValueRef is NULL.");
+
+       if(!JSValueIsString(m_context, arg))
+               ThrowMsg(InvalidArgumentException, "Value is not an string.");
+
+       string sortOrderStr = toString(arg);
+       SortOrder sortOrder;
+
+       if(sortOrderStr == "ASC")
+               sortOrder = ASCENDING_SORT_ORDER;
+       else if(sortOrderStr == "DESC")
+               sortOrder = DESCENDING_SORT_ORDER;
+       else
+               ThrowMsg(InvalidArgumentException, "SortModeOrder cannot have " << sortOrderStr);
+
+       return sortOrder;
 }
 
 void FilterConverter::initFilterAttrs()
@@ -548,7 +813,6 @@ void FilterConverter::initFilterAttrs()
        m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME);
        m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_FLAG);
        m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_MATCH_VALUES);
-       m_attributeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_CASE_SENSITIVE);
 
        m_attributeRangeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_ATTRIBUTE_NAME);
        m_attributeRangeFilterAttrs.push_back(TIZEN_FILTER_CONVERTER_ATTRIBUTE_INITIAL_VALUE);
index 9d9f675..ce8fd1f 100755 (executable)
@@ -45,11 +45,12 @@ public:
        explicit FilterConverter(JSContextRef context);
        virtual ~FilterConverter();
 
-       TizenApis::Api::Tizen::MatchFlagArrayPtr toMatchFlagArray(JSValueRef matchFlagArray);
-
        JSValueRef toJSValueRef(TizenApis::Api::Tizen::FilterPtr arg);
        TizenApis::Api::Tizen::FilterPtr toFilter(const JSValueRef& arg);
 
+       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::FilterArrayPtr& arg);
+       TizenApis::Api::Tizen::FilterArrayPtr toFilterArray(const JSValueRef& arg);
+
        JSValueRef toJSValueRef(const TizenApis::Api::Tizen::CompositeFilterPtr& arg);
        TizenApis::Api::Tizen::CompositeFilterPtr toCompositeFilter(const JSValueRef& arg);
 
@@ -65,11 +66,20 @@ public:
        JSValueRef toJSValueRef(const TizenApis::Api::Tizen::SortModeArrayPtr& arg);
        TizenApis::Api::Tizen::SortModeArrayPtr toSortModeArray(const JSValueRef& arg);
 
+       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::AnyPtr& arg);
+       TizenApis::Api::Tizen::AnyPtr toAny(const JSValueRef& arg);
+
        JSValueRef toJSValueRef(const TizenApis::Api::Tizen::AnyArrayPtr& arg);
        TizenApis::Api::Tizen::AnyArrayPtr toAnyArray(const JSValueRef& arg);
 
-       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::FilterArrayPtr& arg);
-       TizenApis::Api::Tizen::FilterArrayPtr toFilterArray(const JSValueRef& arg);
+       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::FilterType& arg);
+       TizenApis::Api::Tizen::FilterType toCompositeFilterType(const JSValueRef& arg);
+
+       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::MatchFlag& arg);
+       TizenApis::Api::Tizen::MatchFlag toMatchFlag(const JSValueRef& arg);
+
+       JSValueRef toJSValueRef(const TizenApis::Api::Tizen::SortOrder& arg);
+       TizenApis::Api::Tizen::SortOrder toSortOrder(const JSValueRef& arg);
 
 private:
        std::vector<std::string> m_compositeFilterAttrs;
diff --git a/src/standards/Tizen/Tizen/JSAbstractFilterArray.cpp b/src/standards/Tizen/Tizen/JSAbstractFilterArray.cpp
new file mode 100755 (executable)
index 0000000..ca08b8a
--- /dev/null
@@ -0,0 +1,608 @@
+/*
+ * 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        JSAbstractFilterArray.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#include <algorithm>
+#include <dpl/log/log.h>
+#include <CommonsJavaScript/ScopedJSStringRef.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include "FilterConverter.h"
+#include "JSAbstractFilterArray.h"
+
+#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"
+#define FUNCTION_CONSTRUCTOR "constructor"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+
+JSClassDefinition JSAbstractFilterArray::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 JSAbstractFilterArray::m_property[] = {
+       { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSAbstractFilterArray::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 },
+       { FUNCTION_CONSTRUCTOR, constructor, kJSPropertyAttributeNone },
+       { 0, 0, 0 }
+};
+
+JSClassRef JSAbstractFilterArray::m_jsClassRef = JSClassCreate(
+               JSAbstractFilterArray::getClassInfo());
+
+JSValueRef JSAbstractFilterArray::getLength(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       //LogDebug("enter");
+       Try
+       {
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               FilterArrayPtr filters = priv->getObject();
+               if (filters) {
+                       FilterConverterFactory::ConverterType converter =
+                                       FilterConverterFactory::getConverter(context);
+                       return converter->toJSValueRef(filters->size());
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid conversion");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAbstractFilterArray::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+FilterArrayPtr JSAbstractFilterArray::getAbstractFilterArray(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSAbstractFilterArrayPriv *priv = static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+JSObjectRef JSAbstractFilterArray::createArray(JSContextRef context,
+               const FilterArrayPtr &filters)
+{
+       JSAbstractFilterArrayPriv *priv = new JSAbstractFilterArrayPriv(context, filters);
+       return JSObjectMake(context, getClassRef(), priv);
+}
+
+const JSClassDefinition* JSAbstractFilterArray::getClassInfo()
+{
+       return &(m_classInfo);
+}
+
+JSClassRef JSAbstractFilterArray::getClassRef()
+{
+       if (!m_jsClassRef) {
+               m_jsClassRef = JSClassCreate(&m_classInfo);
+       }
+       return m_jsClassRef;
+}
+
+void JSAbstractFilterArray::initialize(JSContextRef context,
+               JSObjectRef object)
+{
+       //LogDebug("enter");
+}
+
+void JSAbstractFilterArray::finalize(JSObjectRef object)
+{
+       //LogDebug("enter");
+       JSAbstractFilterArrayPriv* priv =
+               static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+       delete priv;
+       JSObjectSetPrivate(object, NULL);
+}
+
+bool JSAbstractFilterArray::hasProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName)
+{
+       //LogDebug("enter");
+       FilterConverterFactory::ConverterType converter =
+                       FilterConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               FilterArrayPtr filters = priv->getObject();
+               if (index < filters->size()) {
+                       return true;
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               //not reporting error is intended
+       }
+       return false;
+}
+
+JSValueRef JSAbstractFilterArray::getProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       //LogDebug("enter");
+       FilterConverterFactory::ConverterType converter =
+                       FilterConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               FilterArrayPtr filters = priv->getObject();
+               if (index < filters->size()) {
+                       FilterPtr result = filters->at(index);
+                       if (result) {
+                               return converter->toJSValueRef(result);
+                       }
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("invalid property");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAbstractFilterArray::setProperty(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       //LogDebug("enter");
+       FilterConverterFactory::ConverterType converter =
+                       FilterConverterFactory::getConverter(context);
+       Try
+       {
+               size_t index = converter->toSizeT(propertyName);
+               FilterPtr filter;
+               if (!JSValueIsUndefined(context, value)) {
+                       filter = converter->toFilter(value);
+               }
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(object));
+               if (!priv) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               FilterArrayPtr filters = priv->getObject();
+               if (!filters) {
+                       Throw(WrtDeviceApis::Commons::NullPointerException);
+               }
+               if (filters->size() <= index) {
+                       filters->resize(index + 1);
+               }
+               (*filters)[index] = filter;
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+               JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       }
+       return false;
+}
+
+JSValueRef JSAbstractFilterArray::concat(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("enter");
+       Try
+       {
+               FilterArrayPtr filters = FilterArrayPtr(new FilterArray());
+               JSAbstractFilterArrayPriv *newPrivateObject = new JSAbstractFilterArrayPriv(context, filters);
+               JSValueRef result = JSObjectMake(context, getClassRef(), newPrivateObject);
+
+               //copy current filters
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               for (size_t i = 0; i < currentWebSites->size(); ++i) {
+                       filters->push_back(currentWebSites->at(i));
+               }
+
+               //copy submitted arrays
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       if (!JSIsArrayValue(context, arguments[i])) {
+                               Throw(WrtDeviceApis::Commons::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);
+                               filters->push_back(converter->toFilter(att));
+                       }
+               }
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSAbstractFilterArray::join(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               std::string result;
+               std::string separator(",");
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
+                       separator = converter->toString(arguments[0]);
+               }
+               for (size_t i = 0; i < currentWebSites->size(); ++i) {
+                       if (i != 0) {
+                               result += separator;
+                       }
+                       //FIXME : to be changed to support join
+                       //result += currentWebSites->at(i);
+               }
+               return converter->toJSValueRef(result);
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSAbstractFilterArray::pop(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               if (currentWebSites->size() > 0) {
+                       FilterPtr result = currentWebSites->at(
+                                       currentWebSites->size() - 1);
+                       currentWebSites->pop_back();
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::push(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               for (size_t i = 0; i < argumentCount; ++i) {
+                       currentWebSites->push_back(converter->toFilter(arguments[i]));
+               }
+               return converter->toJSValueRef(currentWebSites->size());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSAbstractFilterArray::reverse(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               std::reverse(currentWebSites->begin(), currentWebSites->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::shift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               if (currentWebSites->size() > 0) {
+                       FilterPtr result = currentWebSites->at(0);
+                       currentWebSites->erase(currentWebSites->begin());
+                       return converter->toJSValueRef(result);
+               }
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::slice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("enter");
+       Try
+       {
+               if (argumentCount < 1) {
+                       return JSValueMakeUndefined(context);
+               }
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               FilterArrayPtr filters = FilterArrayPtr(new FilterArray());
+               JSAbstractFilterArrayPriv *newPrivateObject = new JSAbstractFilterArrayPriv(
+                               context,
+                               filters);
+               JSValueRef result = JSObjectMake(context,
+                                                                                getClassRef(), newPrivateObject);
+
+               //copy current filters
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               std::size_t first = converter->toSizeT(arguments[0]);
+               std::size_t last = currentWebSites->size() - 1;
+               if (argumentCount > 1) {
+                       last = converter->toSizeT(arguments[1]);
+                       if (last >= currentWebSites->size()) {
+                               last = currentWebSites->size() - 1;
+                       }
+               }
+               if (first < 0) {
+                       first = 0;
+               }
+               for (size_t i = first; i <= last; ++i) {
+                       filters->push_back(currentWebSites->at(i));
+               }
+
+               return result;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+}
+
+JSValueRef JSAbstractFilterArray::sort(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               JSAbstractFilterArrayPriv* priv =
+                       static_cast<JSAbstractFilterArrayPriv*>(JSObjectGetPrivate(thisObject));
+               FilterArrayPtr currentWebSites = priv->getObject();
+               std::sort(currentWebSites->begin(), currentWebSites->end());
+               return thisObject;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogError("error occured");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::splice(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::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 JSAbstractFilterArray::unshift(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::valueOf(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       //LogDebug("entered");
+       return JSValueMakeUndefined(context);
+}
+
+JSValueRef JSAbstractFilterArray::constructor(JSContextRef context,
+               JSObjectRef function,
+               JSObjectRef thisObject,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       // To determine this object as array
+       WrtDeviceApis::CommonsJavaScript::ScopedJSStringRef json(JSStringCreateWithUTF8CString("[]"));
+       JSValueRef array = JSValueMakeFromJSONString(context, json.get());
+       WrtDeviceApis::CommonsJavaScript::ScopedJSStringRef constructorStr(JSStringCreateWithUTF8CString("constructor"));
+       JSObjectRef arrayObject = JSValueToObject(context, array, NULL);
+       JSValueRef constructorValue = JSObjectGetProperty(context, arrayObject, constructorStr.get(), NULL);
+       return constructorValue;
+}
+
+} // Contact
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSAbstractFilterArray.h b/src/standards/Tizen/Tizen/JSAbstractFilterArray.h
new file mode 100755 (executable)
index 0000000..be1d3fb
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+ * 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        JSAbstractFilterArray.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief
+ */
+
+#ifndef _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
+#define _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <API/Filter/IFilter.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT< TizenApis::Api::Tizen::FilterArrayPtr >::Type JSAbstractFilterArrayPriv;
+
+class JSAbstractFilterArray
+{
+public:
+
+       static const JSClassDefinition* getClassInfo();
+
+       static JSClassRef getClassRef();
+
+       static JSObjectRef createArray(JSContextRef context,
+                       const TizenApis::Api::Tizen::FilterArrayPtr &filterArray);
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::FilterArrayPtr getAbstractFilterArray(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);
+
+       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 JSValueRef constructor(JSContextRef context,
+                       JSObjectRef function,
+                       JSObjectRef thisObject,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static bool checkValue(const std::string &value);
+
+       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[];
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_ABSTRACT_FILTER_ARRAY_H_
diff --git a/src/standards/Tizen/Tizen/JSAttributeFilter.cpp b/src/standards/Tizen/Tizen/JSAttributeFilter.cpp
new file mode 100755 (executable)
index 0000000..e09b675
--- /dev/null
@@ -0,0 +1,402 @@
+/*
+ * 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        JSAttributeFilter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Implementation of the JSAttributeFilter class
+ */
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <API/Filter/AttributeFilter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSGlobalContextFactory.h>
+#include "FilterConverter.h"
+#include "JSAttributeFilter.h"
+
+#define ATTRIBUTE_FILTER_CLASS_NAME "AttributeFilter"
+
+#define ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME "attributeName"
+#define ATTRIBUTE_FILTER_ATTR_MATCH_FLAG "matchFlag"
+#define ATTRIBUTE_FILTER_ATTR_MATCH_VALUES "matchValues"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSAttributeFilter::m_classRef = NULL;
+
+JSClassDefinition JSAttributeFilter::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       ATTRIBUTE_FILTER_CLASS_NAME,
+       NULL,
+       m_property,
+       m_functions,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSAttributeFilter::m_property[] = {
+       { ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME, getAttributeName, setAttributeName, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_MATCH_FLAG, getMatchFlag, setMatchFlag, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_MATCH_VALUES, getMatchValues, setMatchValues, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSAttributeFilter::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSAttributeFilter::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+bool JSAttributeFilter::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+AttributeFilterPtr JSAttributeFilter::getAttributeFilter(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSAttributeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+//     if (!JSObjectGetPrivate(object))
+//     {
+//             AttributeFilterPtr coord(new AttributeFilter(""));
+//             JSAttributeFilterPriv *priv = new JSAttributeFilterPriv(context, AttributeFilterPtr(coord));
+//             if (!JSObjectSetPrivate(object, priv)) {
+//                     delete priv;
+//             }
+//     }
+}
+
+void JSAttributeFilter::Finalize(JSObjectRef object)
+{
+       JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
+
+       if (priv != NULL)
+       {
+               delete (priv);
+       }
+
+       priv = NULL;
+}
+
+JSObjectRef JSAttributeFilter::createJSObject(JSContextRef context, AttributeFilterPtr privateData)
+{
+       JSAttributeFilterPriv *priv = new JSAttributeFilterPriv(context, privateData);
+       JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsObjectRef) {
+               LogError("object creation error");
+               return NULL;
+       }
+       return jsObjectRef;
+}
+
+AttributeFilterPtr JSAttributeFilter::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       AttributeFilterPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSAttributeFilter::constructor(JSContextRef context,
+               JSObjectRef constructor,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+//     JSAttributeFilterPriv *priv = static_cast<JSAttributeFilterPriv*>(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 || argumentCount > 3)
+                       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.");
+               }
+
+               // 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");
+               return NULL;
+       }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+
+       std::string attributeName;
+       MatchFlag matchFlag;
+       AnyArrayPtr matchValues;
+
+       Try {
+               attributeName = converter->toString(arguments[0]);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               matchFlag = MATCH_EXACTLY;
+               if(argumentCount >= 2)
+               {
+                       if(JSValueIsString(gContext, arguments[1]))
+                               matchFlag = converter->toMatchFlag(arguments[1]);
+               }
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               if(argumentCount >= 3)
+               {
+                       if(JSValueIsNull(gContext, arguments[2]))
+                               matchValues = AnyArrayPtr(new AnyArray());
+                       else if(JSIsArrayValue(gContext, arguments[2]))
+                               matchValues = converter->toAnyArray(arguments[2]);
+                       else
+                       {
+                               matchValues = AnyArrayPtr(new AnyArray());
+                               matchValues->push_back(converter->toAny(arguments[2]));
+                       }
+               }
+               else
+               {
+                       matchValues = AnyArrayPtr(new AnyArray());
+               }
+
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       AttributeFilterPtr attributeFilter(new AttributeFilter(attributeName, matchFlag, matchValues));
+
+       JSObjectRef jsobject;
+
+       Try {
+               jsobject = createJSObject(gContext, attributeFilter);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       return jsobject;
+}
+
+JSValueRef JSAttributeFilter::getAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeFilter->getAttributeName());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeFilter::setAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeFilter->setAttributeName(converter->toString(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSAttributeFilter::getMatchFlag(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeFilter->getMatchFlag());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeFilter::setMatchFlag(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeFilter->setMatchFlag(converter->toMatchFlag(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSAttributeFilter::getMatchValues(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeFilter->getMatchValues());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeFilter::setMatchValues(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeFilterPtr attributeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeFilter->setMatchValues(converter->toAnyArray(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSAttributeFilter.h b/src/standards/Tizen/Tizen/JSAttributeFilter.h
new file mode 100755 (executable)
index 0000000..5ada992
--- /dev/null
@@ -0,0 +1,127 @@
+/*
+ * 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        JSAttributeFilter.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSAttributeFilter class
+ */
+
+#ifndef _TIZEN_TIZEN_JS_ATTRIBUTE_FILTER_H_
+#define _TIZEN_TIZEN_JS_ATTRIBUTE_FILTER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Filter/AttributeFilter.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Tizen::AttributeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAttributeFilterPriv;
+
+class JSAttributeFilter {
+public:
+       /*
+        * This initializes this JS class in the JS Engine.
+        */
+       static JSClassRef getClassRef();
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::AttributeFilterPtr getAttributeFilter(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 JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Tizen::AttributeFilterPtr privateData);
+
+       static TizenApis::Api::Tizen::AttributeFilterPtr getPrivData(JSObjectRef object);
+
+       static JSObjectRef constructor(JSContextRef context,
+                       JSObjectRef constructor,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef getAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getMatchFlag(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setMatchFlag(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getMatchValues(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setMatchValues(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_ATTRIBUTE_FILTER_H_
diff --git a/src/standards/Tizen/Tizen/JSAttributeRangeFilter.cpp b/src/standards/Tizen/Tizen/JSAttributeRangeFilter.cpp
new file mode 100755 (executable)
index 0000000..f7a5ee7
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * 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        JSAttributeRangeFilter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Implementation of the JSAttributeRangeFilter class
+ */
+
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <API/Filter/AttributeRangeFilter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSGlobalContextFactory.h>
+#include "FilterConverter.h"
+#include "JSAttributeRangeFilter.h"
+
+#define ATTRIBUTE_RANGE_FILTER_CLASS_NAME "AttributeRangeFilter"
+
+#define ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME "attributeName"
+#define ATTRIBUTE_FILTER_ATTR_INITIAL_VALUE "initialValue"
+#define ATTRIBUTE_FILTER_ATTR_END_VALUE "endValue"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSAttributeRangeFilter::m_classRef = NULL;
+
+JSClassDefinition JSAttributeRangeFilter::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       ATTRIBUTE_RANGE_FILTER_CLASS_NAME,
+       NULL,
+       m_property,
+       m_functions,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSAttributeRangeFilter::m_property[] = {
+       { ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME, getAttributeName, setAttributeName, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_INITIAL_VALUE, getInitialValue, setInitialValue, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_END_VALUE, getEndValue, setEndValue, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSAttributeRangeFilter::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSAttributeRangeFilter::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+bool JSAttributeRangeFilter::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+AttributeRangeFilterPtr JSAttributeRangeFilter::getAttributeRangeFilter(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSAttributeRangeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+//     if (!JSObjectGetPrivate(object))
+//     {
+//             AttributeRangeFilterPtr coord(new AttributeRangeFilter(""));
+//             JSAttributeRangeFilterPriv *priv = new JSAttributeRangeFilterPriv(context, AttributeRangeFilterPtr(coord));
+//             if (!JSObjectSetPrivate(object, priv)) {
+//                     delete priv;
+//             }
+//     }
+}
+
+void JSAttributeRangeFilter::Finalize(JSObjectRef object)
+{
+       JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
+
+       if (priv != NULL)
+       {
+               delete (priv);
+       }
+
+       priv = NULL;
+}
+
+JSObjectRef JSAttributeRangeFilter::createJSObject(JSContextRef context, AttributeRangeFilterPtr privateData)
+{
+       JSAttributeRangeFilterPriv *priv = new JSAttributeRangeFilterPriv(context, privateData);
+       JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsObjectRef) {
+               LogError("object creation error");
+               return NULL;
+       }
+       return jsObjectRef;
+}
+
+AttributeRangeFilterPtr JSAttributeRangeFilter::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       AttributeRangeFilterPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
+               JSObjectRef constructor,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+//     JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(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(gContext, exception);
+       Try {
+               if (argumentCount < 2 || argumentCount > 3)
+                       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(JSValueIsNull(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+               }
+
+               if (argumentCount == 3)
+               {
+                       if(JSValueIsNull(gContext, arguments[1]) && JSValueIsNull(gContext, arguments[2]))
+                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+               }
+
+       } Catch(Exception ) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+
+       std::string attributeName;
+       AnyPtr initialValue;
+       AnyPtr endValue;
+
+       Try {
+               if(argumentCount >= 2)
+                       initialValue = converter->toAny(arguments[1]);
+               else
+                       initialValue = AnyPtr(new Any());
+
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               if(argumentCount >= 3)
+                       endValue = converter->toAny(arguments[2]);
+               else
+                       endValue = AnyPtr(new Any());
+
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       AttributeRangeFilterPtr attributeRangeFilter(new AttributeRangeFilter(attributeName, initialValue, endValue));
+
+       JSObjectRef jsobject;
+
+       Try {
+               jsobject = createJSObject(gContext, attributeRangeFilter);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       return jsobject;
+}
+
+JSValueRef JSAttributeRangeFilter::getAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeRangeFilter->getAttributeName());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeRangeFilter::setAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeRangeFilter->setAttributeName(converter->toString(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSAttributeRangeFilter::getInitialValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeRangeFilter->getInitialValue());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeRangeFilter::setInitialValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeRangeFilter->setInitialValue(converter->toAny(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSAttributeRangeFilter::getEndValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               return converter->toJSValueRef(attributeRangeFilter->getEndValue());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSAttributeRangeFilter::setEndValue(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               AttributeRangeFilterPtr attributeRangeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               attributeRangeFilter->setEndValue(converter->toAny(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSAttributeRangeFilter.h b/src/standards/Tizen/Tizen/JSAttributeRangeFilter.h
new file mode 100755 (executable)
index 0000000..2f38883
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * 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        JSAttributeRangeFilter.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSAttributeRangeFilter class
+ */
+
+#ifndef _TIZEN_TIZEN_JS_ATTRIBUTE_RANGE_FILTER_H_
+#define _TIZEN_TIZEN_JS_ATTRIBUTE_RANGE_FILTER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Filter/AttributeRangeFilter.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Tizen::AttributeRangeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSAttributeRangeFilterPriv;
+
+class JSAttributeRangeFilter {
+public:
+       /*
+       * This initializes this JS class in the JS Engine.
+       */
+       static JSClassRef getClassRef();
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::AttributeRangeFilterPtr getAttributeRangeFilter(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 JSObjectRef createJSObject(JSContextRef context,
+                       TizenApis::Api::Tizen::AttributeRangeFilterPtr privateData);
+
+       static TizenApis::Api::Tizen::AttributeRangeFilterPtr getPrivData(JSObjectRef object);
+
+       static JSObjectRef constructor(JSContextRef context,
+                       JSObjectRef constructor,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef getAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getInitialValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setInitialValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getEndValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setEndValue(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_ATTRIBUTE_RANGE_FILTER_H_
diff --git a/src/standards/Tizen/Tizen/JSCompositeFilter.cpp b/src/standards/Tizen/Tizen/JSCompositeFilter.cpp
new file mode 100755 (executable)
index 0000000..20ce956
--- /dev/null
@@ -0,0 +1,336 @@
+/*
+ * 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        JSCompositeFilter.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Implementation of the JSCompositeFilter class
+ */
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <API/Filter/CompositeFilter.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSGlobalContextFactory.h>
+#include "FilterConverter.h"
+#include "JSAbstractFilterArray.h"
+#include "JSCompositeFilter.h"
+
+#define ATTRIBUTE_FILTER_CLASS_NAME "CompositeFilter"
+
+#define ATTRIBUTE_FILTER_ATTR_TYPE "type"
+#define ATTRIBUTE_FILTER_ATTR_FILTERS "filters"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSCompositeFilter::m_classRef = NULL;
+
+JSClassDefinition JSCompositeFilter::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       ATTRIBUTE_FILTER_CLASS_NAME,
+       NULL,
+       m_property,
+       m_functions,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSCompositeFilter::m_property[] = {
+       { ATTRIBUTE_FILTER_ATTR_TYPE, getType, setType, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_FILTERS, getFilters, setFilters, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSCompositeFilter::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSCompositeFilter::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+bool JSCompositeFilter::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+CompositeFilterPtr JSCompositeFilter::getCompositeFilter(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSCompositeFilter::Initialize(JSContextRef context, JSObjectRef object)
+{
+//     if (!JSObjectGetPrivate(object))
+//     {
+//             CompositeFilterPtr coord(new CompositeFilter(""));
+//             JSCompositeFilterPriv *priv = new JSCompositeFilterPriv(context, CompositeFilterPtr(coord));
+//             if (!JSObjectSetPrivate(object, priv)) {
+//                     delete priv;
+//             }
+//     }
+}
+
+void JSCompositeFilter::Finalize(JSObjectRef object)
+{
+       JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+
+       if (priv != NULL)
+       {
+               delete (priv);
+       }
+
+       priv = NULL;
+}
+
+JSObjectRef JSCompositeFilter::createJSObject(JSContextRef context, CompositeFilterPtr privateData)
+{
+       JSCompositeFilterPriv *priv = new JSCompositeFilterPriv(context, privateData);
+       JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsObjectRef) {
+               LogError("object creation error");
+               return NULL;
+       }
+       return jsObjectRef;
+}
+
+CompositeFilterPtr JSCompositeFilter::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       CompositeFilterPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSCompositeFilter::constructor(JSContextRef context,
+               JSObjectRef constructor,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+//     JSCompositeFilterPriv *priv = static_cast<JSCompositeFilterPriv*>(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(gContext, exception);
+       Try {
+               if (argumentCount < 1 || argumentCount > 3)
+                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+
+               if (!JSValueIsString(gContext, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
+
+               if (argumentCount >= 2)
+               {
+                       if (!JSValueIsObject(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+                               ThrowMsg(InvalidArgumentException, "2nd argument is not object.");
+               }
+
+               // 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");
+               return NULL;
+       }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+
+       FilterType type;
+       FilterArrayPtr filters;
+
+       Try {
+               type = converter->toCompositeFilterType(arguments[0]);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               if(argumentCount >= 2)
+               {
+                       if(!JSValueIsNull(gContext, arguments[1]))
+                               filters = converter->toFilterArray(arguments[1]);
+                       else
+                               filters = FilterArrayPtr(new FilterArray());
+               }
+               else
+                       filters = FilterArrayPtr(new FilterArray());
+
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       CompositeFilterPtr compositeFilter(new CompositeFilter(type, filters));
+
+       JSObjectRef jsobject;
+
+       Try {
+               jsobject = createJSObject(gContext, compositeFilter);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       return jsobject;
+}
+
+JSValueRef JSCompositeFilter::getType(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               CompositeFilterPtr compositeFilter = getPrivData(object);
+               return converter->toJSValueRef(compositeFilter->getFilterType());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSCompositeFilter::setType(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               CompositeFilterPtr compositeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               compositeFilter->setFilterType(converter->toCompositeFilterType(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSCompositeFilter::getFilters(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               CompositeFilterPtr compositeFilter = getPrivData(object);
+               return converter->toJSValueRef(compositeFilter->getFilters());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSCompositeFilter::setFilters(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               CompositeFilterPtr compositeFilter = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               compositeFilter->setFilters(converter->toFilterArray(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSCompositeFilter.h b/src/standards/Tizen/Tizen/JSCompositeFilter.h
new file mode 100755 (executable)
index 0000000..8acb0d6
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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        JSCompositeFilter.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSCompositeFilter class
+ */
+
+#ifndef _TIZEN_TIZEN_JS_COMPOSITE_FILTER_H_
+#define _TIZEN_TIZEN_JS_COMPOSITE_FILTER_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Filter/CompositeFilter.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Tizen::CompositeFilterPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSCompositeFilterPriv;
+
+class JSCompositeFilter {
+public:
+       /*
+        * This initializes this JS class in the JS Engine.
+        */
+       static JSClassRef getClassRef();
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::CompositeFilterPtr getCompositeFilter(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 JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Tizen::CompositeFilterPtr privateData);
+
+       static TizenApis::Api::Tizen::CompositeFilterPtr getPrivData(JSObjectRef object);
+
+       static JSObjectRef constructor(JSContextRef context,
+                       JSObjectRef constructor,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef getType(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setType(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getFilters(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setFilters(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_COMPOSITE_FILTER_H_
diff --git a/src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp b/src/standards/Tizen/Tizen/JSSimpleCoordinates.cpp
new file mode 100755 (executable)
index 0000000..5764384
--- /dev/null
@@ -0,0 +1,326 @@
+/*
+ * 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        JSSimpleCoordinates.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Implementation of the JSSimpleCoordinates class
+ */
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <API/Filter/SimpleCoordinates.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSGlobalContextFactory.h>
+#include "FilterConverter.h"
+#include "JSSimpleCoordinates.h"
+
+#define ATTRIBUTE_FILTER_CLASS_NAME "SimpleCoordinates"
+
+#define ATTRIBUTE_FILTER_ATTR_LATITUDE "latitude"
+#define ATTRIBUTE_FILTER_ATTR_LONGITUDE "longitude"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSSimpleCoordinates::m_classRef = NULL;
+
+JSClassDefinition JSSimpleCoordinates::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       ATTRIBUTE_FILTER_CLASS_NAME,
+       NULL,
+       m_property,
+       m_functions,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSSimpleCoordinates::m_property[] = {
+       { ATTRIBUTE_FILTER_ATTR_LATITUDE, getLatitude, setLatitude, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_LONGITUDE, getLongitude, setLongitude, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSSimpleCoordinates::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSSimpleCoordinates::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+bool JSSimpleCoordinates::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+SimpleCoordinatesPtr JSSimpleCoordinates::getSimpleCoordinates(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSSimpleCoordinates::Initialize(JSContextRef context, JSObjectRef object)
+{
+       if (!JSObjectGetPrivate(object))
+       {
+               SimpleCoordinatesPtr coord(new SimpleCoordinates(0.0, 0.0));
+               JSSimpleCoordinatesPriv *priv = new JSSimpleCoordinatesPriv(context, SimpleCoordinatesPtr(coord));
+               if (!JSObjectSetPrivate(object, priv)) {
+                       delete priv;
+               }
+       }
+}
+
+void JSSimpleCoordinates::Finalize(JSObjectRef object)
+{
+       JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
+       printf("JSSimpleCoordinates::Finalize\n");
+
+       if (priv != NULL)
+       {
+               delete (priv);
+       }
+
+       priv = NULL;
+}
+
+JSObjectRef JSSimpleCoordinates::createJSObject(JSContextRef context, SimpleCoordinatesPtr privateData)
+{
+       JSSimpleCoordinatesPriv *priv = new JSSimpleCoordinatesPriv(context, privateData);
+       JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsObjectRef) {
+               LogError("object creation error");
+               return NULL;
+       }
+       return jsObjectRef;
+}
+
+SimpleCoordinatesPtr JSSimpleCoordinates::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       SimpleCoordinatesPtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSSimpleCoordinates::constructor(JSContextRef context,
+               JSObjectRef constructor,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+       printf("context : 0x%08x\n", (unsigned int)context);
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+       JSSimpleCoordinatesPriv *priv = static_cast<JSSimpleCoordinatesPriv*>(JSObjectGetPrivate(constructor));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       JSContextRef gContext = priv->getContext();
+
+       printf("tContaxt : 0x%08x\n", (unsigned int)priv->getContext());
+       //JSGlobalContextRef gContext = JSGlobalContextFactory::getInstance()->get();
+       printf("gContext : 0x%08x\n", (unsigned int)gContext);
+
+       BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
+       Try {
+               if (argumentCount != 2)
+                       ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
+
+               if (!JSValueIsNumber(gContext, arguments[0]))
+                       ThrowMsg(InvalidArgumentException, "1st argument is not string.");
+
+               if (!JSValueIsNumber(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;
+       }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+
+       double latitude;
+       double longitude;
+
+       Try {
+               latitude = converter->toDouble(arguments[0]);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               longitude = converter->toDouble(arguments[1]);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *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;
+
+       Try {
+               jsobject = createJSObject(gContext, simpleCoordinates);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       return jsobject;
+}
+
+JSValueRef JSSimpleCoordinates::getLatitude(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               SimpleCoordinatesPtr simpleCoordinates = getPrivData(object);
+               return converter->toJSValueRef(simpleCoordinates->getLatitude());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSSimpleCoordinates::setLatitude(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               SimpleCoordinatesPtr simpleCoordinates = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               simpleCoordinates->setLatitude(converter->toDouble(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSSimpleCoordinates::getLongitude(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               SimpleCoordinatesPtr simpleCoordinates = getPrivData(object);
+               return converter->toJSValueRef(simpleCoordinates->getLongitude());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSSimpleCoordinates::setLongitude(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               SimpleCoordinatesPtr simpleCoordinates = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               simpleCoordinates->setLongitude(converter->toDouble(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSSimpleCoordinates.h b/src/standards/Tizen/Tizen/JSSimpleCoordinates.h
new file mode 100755 (executable)
index 0000000..d619036
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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        JSSimpleCoordinates.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSSimpleCoordinates class
+ */
+
+#ifndef _TIZEN_TIZEN_JS_SIMPLE_COORDINATES_H_
+#define _TIZEN_TIZEN_JS_SIMPLE_COORDINATES_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Filter/SimpleCoordinates.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Tizen::SimpleCoordinatesPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSSimpleCoordinatesPriv;
+
+class JSSimpleCoordinates {
+public:
+       /*
+        * This initializes this JS class in the JS Engine.
+        */
+       static JSClassRef getClassRef();
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::SimpleCoordinatesPtr getSimpleCoordinates(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 JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Tizen::SimpleCoordinatesPtr privateData);
+
+       static TizenApis::Api::Tizen::SimpleCoordinatesPtr getPrivData(JSObjectRef object);
+
+       static JSObjectRef constructor(JSContextRef context,
+                       JSObjectRef constructor,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef getLatitude(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setLatitude(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getLongitude(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setLongitude(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_SIMPLE_COORDINATES_H_
diff --git a/src/standards/Tizen/Tizen/JSSortMode.cpp b/src/standards/Tizen/Tizen/JSSortMode.cpp
new file mode 100755 (executable)
index 0000000..26746bb
--- /dev/null
@@ -0,0 +1,331 @@
+/*
+ * 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        JSSortMode.cpp
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Implementation of the JSSortMode class
+ */
+
+#include <string>
+#include <dpl/log/log.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/Converter.h>
+#include <CommonsJavaScript/Validator.h>
+#include <API/Filter/SortMode.h>
+#include <Tizen/Common/JSTizenExceptionFactory.h>
+#include <Tizen/Common/JSTizenException.h>
+#include <Tizen/Common/JSGlobalContextFactory.h>
+#include "FilterConverter.h"
+#include "JSSortMode.h"
+
+#define ATTRIBUTE_FILTER_CLASS_NAME "SortMode"
+
+#define ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME "attributeName"
+#define ATTRIBUTE_FILTER_ATTR_ORDER "order"
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+using namespace TizenApis::Commons;
+using namespace TizenApis::Api::Tizen;
+using namespace WrtDeviceApis::Commons;
+using namespace WrtDeviceApis::CommonsJavaScript;
+
+JSClassRef JSSortMode::m_classRef = NULL;
+
+JSClassDefinition JSSortMode::m_classInfo =
+{
+       0,
+       kJSClassAttributeNone,
+       ATTRIBUTE_FILTER_CLASS_NAME,
+       NULL,
+       m_property,
+       m_functions,
+       Initialize,
+       Finalize,
+       NULL, //hasProperty,
+       NULL, //GetProperty,
+       NULL, //SetProperty,
+       NULL, //DeleteProperty,
+       NULL, //getPropertyNames,
+       NULL, //CallAsFunction,
+       constructor, //CallAsConstructor,
+       NULL, //HasInstance,
+       NULL, //ConvertToType,
+};
+
+JSStaticValue JSSortMode::m_property[] = {
+       { ATTRIBUTE_FILTER_ATTR_ATTRIBUTE_NAME, getAttributeName, setAttributeName, kJSPropertyAttributeNone },
+       { ATTRIBUTE_FILTER_ATTR_ORDER, getOrder, setOrder, kJSPropertyAttributeNone },
+       { 0, 0, 0, 0 }
+};
+
+JSStaticFunction JSSortMode::m_functions[] =
+{
+       { 0, 0, 0 }
+};
+
+JSClassRef JSSortMode::getClassRef() {
+       if (!m_classRef) {
+               m_classRef = JSClassCreate(&m_classInfo);
+       }
+       return m_classRef;
+}
+
+bool JSSortMode::isObjectOfClass(JSContextRef context, JSValueRef value)
+{
+       return JSValueIsObjectOfClass(context, value, getClassRef());
+}
+
+SortModePtr JSSortMode::getSortMode(JSContextRef context, JSValueRef value)
+{
+       if (!isObjectOfClass(context, value)) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSObjectRef object = JSValueToObject(context, value, NULL);
+       if (!object) {
+               Throw(WrtDeviceApis::Commons::InvalidArgumentException);
+       }
+       JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               Throw(WrtDeviceApis::Commons::NullPointerException);
+       }
+       return priv->getObject();
+}
+
+void JSSortMode::Initialize(JSContextRef context, JSObjectRef object)
+{
+//     if (!JSObjectGetPrivate(object))
+//     {
+//             SortModePtr coord(new SortMode(""));
+//             JSSortModePriv *priv = new JSSortModePriv(context, SortModePtr(coord));
+//             if (!JSObjectSetPrivate(object, priv)) {
+//                     delete priv;
+//             }
+//     }
+}
+
+void JSSortMode::Finalize(JSObjectRef object)
+{
+       JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
+
+       if (priv != NULL)
+       {
+               delete (priv);
+       }
+
+       priv = NULL;
+}
+
+JSObjectRef JSSortMode::createJSObject(JSContextRef context, SortModePtr privateData)
+{
+       JSSortModePriv *priv = new JSSortModePriv(context, privateData);
+       JSObjectRef jsObjectRef = JSObjectMake(context, getClassRef(), static_cast<void*>(priv));
+       if (NULL == jsObjectRef) {
+               LogError("object creation error");
+               return NULL;
+       }
+       return jsObjectRef;
+}
+
+SortModePtr JSSortMode::getPrivData(JSObjectRef object)
+{
+       LogDebug("entered");
+       JSSortModePriv *priv = static_cast<JSSortModePriv*>(JSObjectGetPrivate(object));
+       if (!priv) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       SortModePtr result = priv->getObject();
+       if (!result) {
+               ThrowMsg(WrtDeviceApis::Commons::NullPointerException, "Private object is null");
+       }
+       return result;
+}
+
+JSObjectRef JSSortMode::constructor(JSContextRef context,
+               JSObjectRef constructor,
+               size_t argumentCount,
+               const JSValueRef arguments[],
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+//     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
+
+//     JSSortModePriv *priv = static_cast<JSSortModePriv*>(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(gContext, 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.");
+               }
+
+               // 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");
+               return NULL;
+       }
+
+       FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
+
+       std::string attributeName;
+       SortOrder sortOrder;
+
+       Try {
+               attributeName = converter->toString(arguments[0]);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       Try {
+               sortOrder = ASCENDING_SORT_ORDER;
+               if(argumentCount >= 2)
+               {
+                       if(JSValueIsString(gContext, arguments[1]))
+                               sortOrder = converter->toSortOrder(arguments[1]);
+               }
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       SortModePtr sortMode(new SortMode(attributeName, sortOrder));
+
+       JSObjectRef jsobject;
+
+       Try {
+               jsobject = createJSObject(gContext, sortMode);
+       } Catch(Exception) {
+               LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
+               *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
+               return NULL;
+       }
+
+       return jsobject;
+}
+
+JSValueRef JSSortMode::getAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               SortModePtr sortMode = getPrivData(object);
+               return converter->toJSValueRef(sortMode->getAttributeName());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSSortMode::setAttributeName(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               SortModePtr sortMode = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               sortMode->setAttributeName(converter->toString(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+JSValueRef JSSortMode::getOrder(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef* exception)
+{
+       LogDebug("entered");
+       Try
+       {
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               SortModePtr sortMode = getPrivData(object);
+               return converter->toJSValueRef(sortMode->getOrder());
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to get incorrect value");
+       }
+       return JSValueMakeUndefined(context);
+}
+
+bool JSSortMode::setOrder(JSContextRef context,
+               JSObjectRef object,
+               JSStringRef propertyName,
+               JSValueRef value,
+               JSValueRef* exception)
+{
+       Try
+       {
+               SortModePtr sortMode = getPrivData(object);
+               FilterConverterFactory::ConverterType converter =
+                               FilterConverterFactory::getConverter(context);
+               sortMode->setOrder(converter->toSortOrder(value));
+               return true;
+       }
+       Catch(WrtDeviceApis::Commons::Exception)
+       {
+               LogWarning("trying to set incorrect value");
+       }
+
+       JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
+       return false;
+}
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
diff --git a/src/standards/Tizen/Tizen/JSSortMode.h b/src/standards/Tizen/Tizen/JSSortMode.h
new file mode 100755 (executable)
index 0000000..eda44bc
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * 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        JSSortMode.h
+ * @author      Kisub Song (kisubs.song@samsung.com)
+ * @version     0.1
+ * @brief       Declaration of the JSSortMode class
+ */
+
+#ifndef _TIZEN_TIZEN_JS_SORT_MODE_H_
+#define _TIZEN_TIZEN_JS_SORT_MODE_H_
+
+#include <JavaScriptCore/JavaScript.h>
+#include <dpl/shared_ptr.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include <Commons/IEvent.h>
+#include <API/Filter/SortMode.h>
+
+namespace TizenApis {
+namespace Tizen1_0 {
+namespace Tizen {
+
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<TizenApis::Api::Tizen::SortModePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSSortModePriv;
+
+class JSSortMode {
+public:
+       /*
+        * This initializes this JS class in the JS Engine.
+        */
+       static JSClassRef getClassRef();
+
+       static bool isObjectOfClass(JSContextRef context, JSValueRef value);
+
+       static TizenApis::Api::Tizen::SortModePtr getSortMode(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 JSObjectRef createJSObject(JSContextRef context, TizenApis::Api::Tizen::SortModePtr privateData);
+
+       static TizenApis::Api::Tizen::SortModePtr getPrivData(JSObjectRef object);
+
+       static JSObjectRef constructor(JSContextRef context,
+                       JSObjectRef constructor,
+                       size_t argumentCount,
+                       const JSValueRef arguments[],
+                       JSValueRef* exception);
+
+       static JSValueRef getAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setAttributeName(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+
+       static JSValueRef getOrder(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef* exception);
+
+       static bool setOrder(JSContextRef context,
+                       JSObjectRef object,
+                       JSStringRef propertyName,
+                       JSValueRef value,
+                       JSValueRef* exception);
+};
+
+} // Tizen
+} // Tizen1_0
+} // TizenApis
+
+#endif // _TIZEN_TIZEN_JS_SORT_MODE_H_
index a2f091a..f3d3bc3 100755 (executable)
 #include <Commons/WrtWrapper/WrtWrappersMgr.h>
 #include <Commons/Exception.h>
 #include "JSTizen.h"
+#include "JSAttributeFilter.h"
+#include "JSAttributeRangeFilter.h"
+#include "JSCompositeFilter.h"
+#include "JSSortMode.h"
+#include "JSSimpleCoordinates.h"
 
 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
 
@@ -65,6 +70,26 @@ PLUGIN_CLASS_MAP_BEGIN
                                OBJECT_TIZEN,
                                TizenApis::Tizen1_0::Tizen::JSTizen::getClassRef(),
                                NULL)
+    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+                               "AttributeFilter",
+                               TizenApis::Tizen1_0::Tizen::JSAttributeFilter::getClassRef(),
+                               NULL)
+    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+                               "AttributeRangeFilter",
+                               TizenApis::Tizen1_0::Tizen::JSAttributeRangeFilter::getClassRef(),
+                               NULL)
+    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+                               "CompositeFilter",
+                               TizenApis::Tizen1_0::Tizen::JSCompositeFilter::getClassRef(),
+                               NULL)
+    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+                               "SortMode",
+                               TizenApis::Tizen1_0::Tizen::JSSortMode::getClassRef(),
+                               NULL)
+    PLUGIN_CLASS_MAP_ADD_CLASS(WRT_JS_EXTENSION_OBJECT_TIZEN,
+                               "SimpleCoordinates",
+                               TizenApis::Tizen1_0::Tizen::JSSimpleCoordinates::getClassRef(),
+                               NULL)
 PLUGIN_CLASS_MAP_END
 
 #undef OBJECT_TIZEN